0

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)?

Filburt
  • 17,626
  • 12
  • 64
  • 115
user1222017
  • 121
  • 1
  • 2
  • 5
  • Exact duplicate of http://stackoverflow.com/questions/9368436/3d-perpendicular-point-on-line-from-3d-point. Voting to close. – andand Feb 21 '12 at 03: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 09:15

3 Answers3

4

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.

Eric Bainville
  • 9,738
  • 1
  • 25
  • 27
0

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)

daniel
  • 157
  • 1
  • 1
0

If you know how to intersect a Sphere with a Line3D, you can "bubble out" (inflate) p3 by giving it a sufficient radius. Then intersect Sphere with Line3D. The solution p4 is the midpoint of the two intersection points, by symmetry.

pbierre
  • 276
  • 1
  • 8