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

enter image description here

I have two lines defined by a point and a vector:

  • $Q(s) = A + s\vec{v}$
  • $P(t) = B + t\vec{u}$

Suppose distance d is given

I want to know $s$ and $t$ for points $P$ and $Q$ in terms of $d$. $d$ is perpendicular to $line(B, \vec{u})$

so I found out (wikipedia):

$$ \begin{aligned} d & = ||(B - Q) - ((B - Q).\vec{u})\vec{u}|| \\ & = ||(B - A - s\vec{v}) - ((B - A - s\vec{v})\cdot\vec{u})\vec{u}|| \\ & = ||(\vec{w} - s\vec{v}) - ((\vec{w} - s\vec{v})\cdot\vec{u})\vec{u} || \end{aligned} $$

Can somebody explain the algebra to write $s$ in terms of $d$

$$s = f(d) = \dots$$

share|cite|improve this question
I wouldn't solve the problem that way, but anyway, your expression can be written as $d=\|[\vec{w} - (\vec{w}\cdot\vec{u})u] - s[\vec{v} - (\vec{v}\cdot\vec{u})u]\|=\|\vec{p}+s\vec{q}\|$ (say). Now, suppose $\vec{q}=a\vec{p}+b\vec{r}$ for some numbers $a,b$ and some $\vec{r}\perp\vec{p}$. Then $d=\|(1+sa)\vec{p}+sb\vec{r}\|$. As $\vec{p}\perp\vec{r}$, we get $d^2=(1+sa)^2\|\vec{p}\|^2+s^2b^2\|\vec{r}\|^2$. Solving this quadratic equation, you get $s$. Now, to find $a,b$ and $\vec{r}$, you may use Gram-Schmidt orthogonalization. – user1551 Nov 20 '12 at 5:32
How would you solve it then? I want to apply it to the following situation: point $A$ is a ball with radius $d$ travelling a distance $\vec{v}$. It may hit a wall $(B, \vec{u})$. I want to calculate whether and where in its trajectory it hits the wall as well as the point of collision on the wall. – Jan Nov 20 '12 at 8:53
up vote 1 down vote accepted

The problem can be solved in another way. Let $F$ be the foot of perpendicular drawn from $A$ to the line $BP$. Then $$ \vec{AF} = \vec{w} - \frac{\vec{w}\cdot\vec{u}}{\|\vec{u}\|^2}\vec{u}. $$ Let $R=A+\lambda\vec{v}$ be the point where the line extending $QA$ meets the line extending $PB$. Then $\vec{AF} \perp \vec{RF} (=\vec{RA}+\vec{AF})$. Hence $$\vec{AF}\cdot(-\lambda\vec{v}+\vec{AF})=0.$$ Solve it to get $\lambda$. Then, by similarity of triangles, we have $$ \frac{d}{\|\vec{AF}\|} = \frac{\|\vec{RQ}\|}{\|\vec{RA}\|} \equiv \frac{\lambda-s}{\lambda},\\ $$ So you may solve for $s$. Finally, $t$ can be solved by observing that: $$ t\vec{u} = \vec{BP} = \textrm{ projection of } \vec{BQ} \textrm{ along } \vec{u} =\left[(s\vec{v}-\vec{w})\cdot\frac{\vec{u}}{\|\vec{u}\|}\right]\frac{\vec{u}}{\|\vec{u}\|}. $$

share|cite|improve this answer

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.