-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
compare_positions could take an optional epsilon parameter to avoid problems that naturally occur when trying to compare floating point values.
In other words, simply replace
( $pos1->[$dim] != $pos2->[$dim] )
with
( abs($pos1->[$dim] - $pos2->[$dim]) > $epsilon * $pos1->[$dim] )
If $epsilon defaults to 0 then you'd have the same behaviour as now, but that's a little buggy. A better default would be 2.22044604925031e-16. I grabbed that as a typical epsilon value from here.
As an extra optional parameter users could pass in larger values to compare polygons to see if they're 'near enough' the same, e.g., after round-tripping through storage that might use single precision floating point values, or conversion to numeric strings with a limited number of decimal places.
Metadata
Metadata
Assignees
Labels
No labels