I've been trying to find an optimal way to detect collision for an application I've been developing lately, here's the problem in the simplest context:
The mouse positions in which the left mouse button was pressed are saved to a pointer which then when the left mouse button is released, is linked into a linked list structure (A Linked List Structure was preferred to a simple array because of the beneficial implementation ease of an Undo-Redo system) for example in the image above there are 3 different items in the list being: The always empty head and 2 pointers.
The lines between the yellow points are achieved by simply drawing line segments between every consecutive point.
The current and unwanted collision algorithm checks for collision between every yellow point and red line and colors the ones which were deduced to have been colliding into blue.
What I want is to actually detect every intersection point of a red and a green line (Shown above) which by the means of the currently employed algorithm is impossible and I lack the necessities to further improve it.
What I ask of anyone willing to help is only to refer me to a couple of collision-detection algorithms which might be used to achieve the results I seek.
Thanks in advance.
If I was not deceived by my own perception a ray casting algorithm sounds like it could do the job but I wanted to hear some alternatives as well if there are any.
I don't know how this never occurred to me before, but I just fixed it by checking collisions between the red lines and and the line segments marked by the consecutive yellow dots.
Elaboration:
Each consecutive yellow dot pair forms a line segment which's function can be derived by many means, I then solve for the intersection points of the function by setting either the function to a certain y value (for the horizontal lines) or setting the x variable in f(x) to a certain x value (for the vertical lines).