Mathematics: Line line Intersection - VinMeld/2D-Raycasting GitHub Wiki

A line can be defined as having two points: (x1, y1), and (x2, y2), and the point where two lines intersect is called the point of intersection, described as Px and Py.

Point of intersection

Using the following equation, we can determine whether the point of intersection is inside the domain and range or not. If the value of t is between 0 and 1, the POI is within the domain and range of the first line. Similarly, if the value of u is between 0 and 1, the POI is within the domain and range of the second line.

POI in relation to domain and range

With the values of t and u calculated, we can determine where the lines intersect. t and u, alongside the coordinates of both points, can also be used to calculate the point of intersection using the following equation.

Equation of POI

⚠️ **GitHub.com Fallback** ⚠️