JAF-Entertainment.de BlogMediaForum
Calculating intersections between two lines in 2D space is a common problem, at least for me. One possible approach to find out if there is an intersection and, if yes, where the collision exactly is uses vector analysis.

Speaking in vectors, a line between two points A and B can be defined the following way:



  • a is the support vector. It is measured from the origin of the coordinate system to point A (A1 stands for the x-coordinate, A2 for the y-coordinate).
  • b is the direction vector. It can be calculated by subtracting the coordinates of B and A.

Together these two vectors form the equation of the line between A and B:



This means that every point on the line can be described as a plus any multiple r of b. Of course points not "between" A and B are also included. To let two lines collide, one just has to equalize the two lines in the above style.

more...
anzeigenKommentare