Point-line distance (fixed)
posted by Dan S.
The line l is defined by vectors o and v as above; the point is the vector p.

If we draw a line from p to the closest point of l, it will be perpendicular to l. Call this closest point q.

Since q is on l, there is a t value such that

q = tv + o


Since the line from p to q is perpendicular to l,

dot(v, p-q) = 0


The following identities are helpful:

dot(a, b+c) = dot(a,b) +  dot(a,c)

dot(a, sb) = (s)(dot(a,b))


Thus,

(dot(v,p) - dot(v,q)) = 0

dot(v,p) - dot(v,(vt+o)) = 0

dot(v,p) = dot(v,vt+o))

dot(v,p) = dot(v,vt) + dot(v,o)

dot(v,p) = t * dot(v,v) + dot(v,o)

t = \frac{dot(v,p)}{dot(v,v) + dot(v,o)}
Reply to this post
Submit Reply
Title: Your Name:
Wrap equations in [EQ]equation here[/EQ] tags, and inline equations in [IEQ][/IEQ] tags.