Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a 3D line segment and another 3D position which locate slightly away from the line segment. I want to get the projected line segment (3D) which lies on imaginary 3D line which passes through the mentioned 3D position and parallel to that line segment. I am bit confused to find a way to do it. Any directions please. Thanks.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

So let's say you have a line segment represented by two end points $P_1$ and $P_2$ and an additional point $Q$. We first compute $Q$'s shortest distance vector to the line, meaning the vector that points from the line to $Q$ and is orthogonal to the line.

For this we first take the line vector $\mathbf{p}=P_2-P_1$ and the vector $\mathbf{q}=Q-P_1$ from $P_1$ to $Q$. We then only need to subtract that part from $\mathbf{q}$ that is parallel to the line ($\mathbf{p}$):

$$\mathbf{v}=\mathbf{q}-\frac{\mathbf{q}\cdot\mathbf{p}}{\|\mathbf{p}\|^2}\mathbf{q}$$

And this vector, whose euclidean norm equals $Q$'s shortest distance from the line, is the vector we need to translate our line by:

$$P'_1=P_1+\mathbf{v},\qquad P'_2=P_2+\mathbf{v}$$

share|improve this answer
    
thank you for the valuable comment –  niro Feb 4 '12 at 16:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.