bezierjs icon indicating copy to clipboard operation
bezierjs copied to clipboard

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

Open nxjniexiao opened this issue 2 years ago • 4 comments

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 [].

nxjniexiao avatar Mar 08 '22 07:03 nxjniexiao

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

ShaMan123 avatar Jan 17 '24 06:01 ShaMan123

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 avatar Jan 17 '24 06:01 ShaMan123

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

ShaMan123 avatar Jan 17 '24 06:01 ShaMan123

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

ShaMan123 avatar Jan 19 '24 20:01 ShaMan123