Intersection of a Ray with a Line and a Plane
The purpose of this paper is to build another "tool" towards more complex intersection calculations based on the Point-Normal form of a line and a plane.
This will simply show how to determine the intersection point of a ray with an
infinite line or plane as well as the distance to this "hit" point.
written and derived by Kenny Hoff (Oct. 3, 1995)
based on parametric form of a ray and Point-Normal form of a line and a plane
Intersection with a Line
Given the following:
- An infinite line in Point-Normal form defined as n.p=D where n is the "inside" normal vector to the line, p is any point on the line, and D is the distance along the normal vector to the line (if this doesn't make sense, be sure to read the previous paper "Point-Normal Form of a Line and a Plane"):
LINE: n.p=D
- A ray defined parametrically as p(t) = s + d*t where p(t) is a point on the line at "time" t, s is the starting point, and d is the direction vector of the ray. For example, the line from A to B can be defined parametrically as p(t) = A + (B-A)*t where 0<=t<=1 and p(t) are all of the points on the line from A to B; however, if t is allowed to go beyond these boundaries (in a positive direction) it will define an infinite ray in the direction from A to B:
RAY: p(t) = s + d*t
We can easily determine the "hit time" t where the ray intersects the line by substituting the parametric ray function into the point-normal form of the line.
Since p(t) defines a point on the ray at time t and the Point-Normal equation defines all points p on the line, substituting this value into the equation results in a function of t that can be used to determine the "hit time" t where the ray's point satisfies the Point-Normal equation of the line:
n.p = D
n.p(t) = D
n.(s+d*t) = D
(n.s) + (n.d)*t = D
HitTime t = (D-(n.s)) / (n.d) = distance to point of intersection
NOTE: if (n.d = 0) the ray and the line or plane do not intersect (because
the ray and the line or plane are parallel since the normal n is
perpendicular to the ray direction d).
Also, if the HitTime t is negative, the ray has intersected a line or
plane in the opposite direction (should be ignored).
The "hit time" also refers to the distance to the from the ray's starting point s to the intersection point. So now what is the intersection point? We can simply evaluate the parametric function of the ray at the hit time t:
point of intersection = p(HitTime t) = s + d*(HitTime t)
Intersection with a Plane
Believe it or not, the point of intersection and the distance to the intersection is determined exactly the same as with a line. Alas, the beauty of vector-based calculations! The only difference is that the Point-Normal form represents a plane (instead of a line). The line intersection can be thought of as two-dimensional, but it can be two or three; however, the plane intersection must be three-dimensional.
PLANE: n.p=D
Except, now n is the normal to the plane and D is the distance along the normal to the plane.