kuribas / cubicbezier

Haskell library for manipulating cubic bezier curves
BSD 3-Clause "New" or "Revised" License
18 stars 2 forks source link

No output when points are separate by one unit of tolerance. #11

Open lemmih opened 5 years ago

lemmih commented 5 years ago

If two points are separated by one unit of tolerance on the Y-axis then 'union' will both consider them to be separate (in the X struct) /and/ overlapping. This leads to malformed curves in the output structure and the final output is an empty list.

lhs,rhs :: ClosedPath Double lhc = ClosedPath [(Point 2 0,JoinLine) ,(Point 4 3,JoinLine) ,(Point 0 3,JoinLine)] rhs = ClosedPath [(Point 2 0.1,JoinLine) ,(Point 6 1,JoinLine) ,(Point 6 3,JoinLine) ]

*Geom2D.CubicBezier.Overlap> union [lhs,rhs] NonZero 0.1 []

This can be fixed by using (tolerance*2) when creating the X structure.

lemmih commented 5 years ago

A better solution might be to use 'tol/2' when calling 'loopEvents' and then reducing the precision of the generated output curves.