Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question
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}$):


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|cite|improve this answer
thank you for the valuable comment – niro Feb 4 '12 at 16:44

Your Answer


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.