# Perpendicular point on line from 3D point

This question has been asked before in reference to 2D. This question extends it to 3D. How do I find the perpendicular intersected point on a line from a point in 3D space?. If my line is defined by points (x1,y1,z1) & (x2,y2,z2) and I have a point (x3,y3,z3) in space. How do I find the perpendicular intersection of point (x4,y4,z4) on the line from (x3,y3,z3)?

-
Exact duplicate of stackoverflow.com/questions/9368436/…. Voting to close. – andand Feb 21 '12 at 3:59
If this is in some way different from the apparently identical question you asked 43 minutes earlier, you should edit this question to explain the difference, otherwise it will pretty shortly be closed. – AakashM Feb 21 '12 at 9:15

You want to find P4 on the P1,P2 line, i.e. `P4=a*P1+b*P2` for some non-zero pair of scalars (a,b), such that P4-P3 is orthogonal to P2-P1. This condition can be written `dot(P4-P3,P2-P1)=0`. Replacing P4, you get `a*dot(P1-P3,P2-P1)+b*dot(P2-P3,P2-P1)=0`. So you can take:

``````a = dot(P2-P3,P2-P1)
b = -dot(P1-P3,P2-P1)
``````

`dot(u,v)` is the vector dot product: sum u_i v_i. This works in any dimension, giving the intersection of line P1,P2 by the perpendicular hyperplane containing P3.

-

I did the calculation:
a = (x3-x2)(x2-x1) + (y3-y2)(y2-y1) + (z3-z2)(z1-z3)
b = -(x1-x3)
(x2-x1) - (y1-y3)(y2-y1) - (z1-z3)(z2-z1)

P4 (point of intersection) = (ax1+bx2, ay1+by2, az1+bz2)
where:
P1 = (x1, y1, z1)
P2 = (x2, y2, z2)
P3 = (x3, y3, z3)

-
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}