svg-path-commander icon indicating copy to clipboard operation
svg-path-commander copied to clipboard

`getPointAtLength` returns incorrect value for lengths exactly on segment intersections.

Open SelfMadeSystem opened this issue 9 months ago • 3 comments

getPointAtLength returns incorrect value for length exactly on segment intersections. I think the culprit is the if statement

// native `getPointAtLength` behavior when the given distance
// is higher than total length
if (distance > totalLength - DISTANCE_EPSILON) {
  return { x, y };
}

that should only go through if we're at the end of sub path, not at the end of any individual segment.

SelfMadeSystem avatar Mar 08 '25 22:03 SelfMadeSystem

Can't confirm out of my head. What do you suggest?

thednp avatar Mar 09 '25 04:03 thednp

I'm not sure yet. I'm making something pretty complex using this library and I've encountered a few different issues, but I'll have to gather more evidence before I report on them. As for this issue, the problem went away when I copied the function and removed the if statement (but obviously it doesn't work correctly when at the very end of a path).

I'll see if I can provide a few test cases in the coming days

SelfMadeSystem avatar Mar 09 '25 05:03 SelfMadeSystem

I also ran into the same issue. I am sampling a simple path with L commands

darwikey avatar Sep 18 '25 22:09 darwikey