I just read this post Determine which side of a line a point lies. This would help me to solve a part of my problem. I would like to know if a point is left, right, above or under a line. In my drawing you can see and hopefully imagine what I want to do. The two black circles connected by a black line are the result of my algorithm. The red straight line should illustrate that this is going to another circle. The left black circle which is connected with doted red line with the grey and black circle is the last one of my algorithm output. I want to determine now if my last circle to connect after the algorithm is where? If it is left from the last one I want to determine this (e.g. grey and black circle with red doted lines) and connect the last circle with them. If it it is near by the second last I want to remove the last circle and connect directly the second last circle, like I did in the example with the orange circle. The same if the line is coming from the other side or from top or bottom or anywhere.
How can I determine if my circle is above or under the last circle or second last circle, receptively? The question I mentioned in the beginning of the post just answer if it is left or right of a line. Thats not enough for me, because I need to know if it is also above or under a line and the last circle is near to the last circle connected by the line or near by the second last circle.
EDIT: The circles are illustrating points. I get a line with points on it. The line might not straight. After I got this I insert another point (illustrated by a circle here grey, orange or black connected with a doted line)anywhere near the end of the line, which finish with a point (illustrated by a black circle which is connected with another circle by a black line. So if add a circle like the orange I do not want that the line ends up where it ends now, no it should end at the point with the red and black lines. From this point the line should be connected to the orange circle. So the new connection is red line - black circle - orange circle. All other things are removed. That is not done if the new inserted point is on the position of the grey circle. Then the connection from the last point (black circle connected with black line to the other black circle with the red line) is going to the grey circle and nothing will be removed.