Giter VIP home page Giter VIP logo

Comments (7)

Pomax avatar Pomax commented on September 12, 2024 1

hi @harjis can you please file this as a new issue. Closed issues should remain closed, to keep single issues tied to single PRs.

from bezierjs.

axefrog avatar axefrog commented on September 12, 2024

Further investigation reveals that the problem is something to do with the fact that my line is a perfectly straight horizontal line. If I vary the y coordinate on either end of the line by even so much as 0.00000001, then the intercept is found. It's only when they're equal that the intercept fails.

from bezierjs.

Pomax avatar Pomax commented on September 12, 2024

hm, that sounds like somewhere the y delta being 0 is leading to bad stuff... division by zero perhaps. Good find!

from bezierjs.

axefrog avatar axefrog commented on September 12, 2024

No worries. Great library overall though, so thanks- it's saved me a tonne of time!

from bezierjs.

dom1n1k avatar dom1n1k commented on September 12, 2024

Vertical lines too.
But it works:

var vertical = {
    p1: { x: x, y: 0 },
    p2: { x: x + 1e-10, y: 1 },
};
bezier.intersects(vertical);

from bezierjs.

harjis avatar harjis commented on September 12, 2024

Hi!

First of all great work with the library! Has saved me a ton of time.

The issue I have is an intersection with cubic bezier curves and straight horizontal bezier curve. My code is as follows:

    const r = 150;
    const k = 0.55228;
    const circleArc = [
      { x: r * 2, y: r }, // Intersection point
      { x: r * 2, y: r + k * r },
      { x: r + k * r, y: r * 2 },
      { x: r, y: r * 2 }
    ];
    const straightLine = [
      { x: r, y: r },
      { x: r * 2, y: r }, //Intersection point
      { x: r * 2 + k * r, y: r },
      { x: r * 4, y: r }
    ];
    const circleArcBezier = new Bezier([...circleArc]);
    const straighLineBezier = new Bezier([...straightLine]);

    console.log(circleArcBezier.intersects(straighLineBezier)); // Empty array

To my understanding the lines should intersect each other at point { x: r * 2, y: r }. Also If I change the straight line even 1px the intersection is detected.

screen shot 2017-06-05 at 10 36 57

I'm not sure if this is the same issue as in #70 so I commented here.

Thanks again for your awesome work!

from bezierjs.

harjis avatar harjis commented on September 12, 2024

Oh yeah and this happens in Chrome Version 58.0.3029.110 (64-bit) and Firefox 53.0.3 (64-bit) at least with version 2.2.3

from bezierjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.