Attached is an update to my distinct_pts node.
UPDATE - I updated this update! See below for the latest version.. You can disregard this note.
Distinct_pts removes duplicate points within a specified sensitivity range. When determining whether two points were the same, the original version only looked at the points' locations.
But points have another property: type. Polyline paths consist only of type 1 points. But curves have type 3 control points and type 2 end points.
Sometimes you can have a type 1 and a type 2 point at the same location. One familiar example is the beginning and end of a circle. If you feed a circle into my original distinct_pts node and reconnect the points, the end point would be removed, resulting in a deflated circle.
The improved version of distinct_pts makes two changes:
- It always leaves the first point alone.
- For all other points, if a type 2 point shares the same location as a type 1 point, the type 2 point will be preferred.
The improved node should behave similarly in most situations, but should do less damage to curved paths.
The demo shows a scatter of 10,000 dots with one black dot remaining in each clump and blue dots, within a radius of 8, removed. This is the same result as my original demo but with one additional black dot (because the first dot was left alone). To the right I show a circle with duplicate points removed (sensitivity 0); but if you render the reconnected circle you will see that no points were removed in this case and the circle remains intact.
One situation where this change might matter is when dealing with the output of a compound node. The compound node sometimes does strange things to a shape, changing direction, adding bits of dust, and sometimes adding duplicate points of varying types. I sometimes use distinct_pts to repair some of this damage, but the original version could do more harm than good. This improved version should do better. But if anyone runs into trouble with it, please let me know!