Make it thin, make it red
A line goes to infinity in both directions.
A line segment a portion of a line and have two endpoints.
A ray is a directed line segment. It has a start and then extends infinitely in one direction.
Parametric representation of rays. p(t) = p0 + td. t goes from 0 to 1.
2D Lines Equations
y = mx + b.
m is slope and b is y intercept
Ax + Bx = d
Signed distance to a 2D line
Closest point to a 2D Line
Intersection point of two 2D Lines
Closest Point on a ray
Ray: p(t) = porg + td
d is unit vector and t goes from to l ( length of ray ).
q is point we wish to check with.
t for closest point on line is then is then t = d·(q - porg )
If t<0 or t > l then closest point is outside ray.
Intersection of two lines in 2D and 3D.
Intersection of ray and plane.
ray: p(t) = porg + td
plane: p * n = d
t = d - porg·n / d·n
if d·n is 0 then ray is parallel to plane.
Intersection of ray and circle
Intersection of ray and sphere.
Intersection of ray and AABB.
Intersection of ray and triangle.
Distance Point to Line Segment