Skip to content

lineSplit doesn't detect all intersections with curved lines #2288

@ianstormtaylor

Description

@ianstormtaylor

Running into a strange bug, but it reproduces reliably. When I have straight lines intersecting a circle, all of the intersections are detected no problem, but when the lines are curved (in this case with a Math.sin) Turf doesn't properly catch all the intersections.

Here's an example with straight lines:

image

And here's the same thing with curvy lines (with misses in red):

image

Here's a p5.js playground link which reproduces the bug in the latest version (6.X) of Turf.

If you change the size of the canvas, the misses change… some sizes have no errors (eg. 400x400) or some have just one (eg. 450x450) or some have many errors (eg. 500x500). It makes me think it has something to do with float-based arithmetic? But that's just a random guess.

What's going on here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions