Compare points coordinates and cull some based on that

Hi there,

I have a polyline defined by 7 points which can move in a specified way. Later on there will be a lot more points. They can overlap each other, get between two other points, or next to them, etc.

When a point (or more) arrives between two others or next to them in a way, so they are aligned on the same theoretical line, I would like to remove the one that has the middle index of the three. Here is the example:

Not necessarily the point in the middle by position, but the point(s) in the middle by index.
For this I should compare the points’ coordinates and if two or the coordinates are matching with at least two other points’ coordinates in the same directions, one should be removed. I need a general solution that works with any number of points and arrangement. (I know, in this case it’d be enough to use the cull duplicates component with “cull all” setting, but in some cases it doesn’t do the thing I want)

Any idea how to do this? I have something I started but then I got confused :smiley: The first part of the GH file is just for the points and to show how I move them. The second half is the question only.

Thanks a lot in advance for any help. (18.7 KB)