Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intersects(line) returns [] When one of Bessel's endpoints is on a horizontal line segment #179

Open
nxjniexiao opened this issue Mar 8, 2022 · 4 comments

Comments

@nxjniexiao
Copy link

Hi!

intersects(line) returns [] When one of Bessel's endpoints is on a horizontal line segment.

It is similar to #76 .

const { Bezier } = require("bezier-js");

const fromPos = [629, 340.5];
const fromPosCP = [791.875, 537.03515625];
const toPosCP = [741.75, 366.5];
const toPos = [920.75, 415.5];

const b = new Bezier([...fromPos, ...fromPosCP, ...toPosCP, ...toPos]);

const line = {
  p1: { x: 900, y: 415.5 },
  p2: { x: 950, y: 415.5 }
};

console.log(b.intersects(line)); // []

Obviously toPos is on the line, but intersects(line) returns [].

@ShaMan123
Copy link

I can reproduce
When I tilt the line a bit it works but an epsilon tilt is not enough

@ShaMan123
Copy link

Ray cast using (0, 1) vector from the center of the beetle
Screenshot 2024-01-17 at 8 27 19

Ray cast using (1, 50) vector from the center of the beetle
Screenshot 2024-01-17 at 8 29 01

@ShaMan123
Copy link

Could it be related to the fact that it this case the intersection occurs at the min/max point of a curve?

@ShaMan123
Copy link

I think I got it wrong
Will update next week with findings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants