12
$\begingroup$

I have a Line going through points B and C; how do I find the perpendicular distance to A?

$$A= (4,2,1)$$ $$B= (1,0,1)$$ $$C = (1,2,0)$$

enter image description here

$\endgroup$
4
$\begingroup$

Hint: A point on the line BC is described by $t B + (1-t)C$, $t\in {\Bbb R}$. Try to minimize its distance to $A$

$\endgroup$
12
$\begingroup$

Intuitively, you want the distance between the point A and the point on the line BC that is closest to A. And the point on the line that you are looking for is exactly the projection of A on the line. The projection can be computed using the dot product (which is sometimes referred to as "projection product").

So you can compute the direction vector $\mathbb{d}$ of the line $BC$. This is the difference of $B$ and $C$, divided by their distance:

$$\mathbb{d} = (C-B) / ||C-B||$$

Then you can define a vector from $B$ to $A$:

$$\mathbb{v} = A - B$$

Computing the dot product between this vector and the direction vector will give you the the distance between $B$ and the projection of $A$ on $BC$:

$$ t = \mathbb{v} \cdot \mathbb{d}$$

The actual projection $P$ of $A$ on $BC$ is then given as

$$P = B + t \cdot \mathbb{d}$$

And finally, the distance that you have been looking for is

$$|| P - A||$$

Perpendicular

Of course, this could be written in a somewhat shorter form. It has the advantages of giving you exactly the closest point on the line (which may be a nice add-on to computing only the distance), and it can be implemented easily. Some pseudocode:

double computeDistance(vec3 A, vec3 B, vec3 C) {
    vec3 d = (C - B) / C.distance(B);
    vec3 v = A - B;
    double t = v.dot(d);
    vec3 P = B + t * d;
    return P.distance(A);
}
$\endgroup$
  • $\begingroup$ Shouldn't it be v=A-B, not B-A? A vector "from B to A" is A-B. $\endgroup$ – user1318499 Aug 4 '17 at 6:23
  • $\begingroup$ @user1318499 Indeed, thanks, fixed $\endgroup$ – Marco13 Aug 4 '17 at 12:41
8
$\begingroup$

If you are familiar with cross-product, you can get the required distance by calculating $$\frac{|\overrightarrow{BA}\times\overrightarrow{BC}|}{|\overrightarrow{BC}|}$$

$\endgroup$
4
$\begingroup$

You can parameterize the line (and you don't even need to worry about the fact that it’s a segment):

$$B-C=\langle 0,-2,1 \rangle$$ so the line is $$\langle 1,0,1 \rangle+ t\ \langle 0,-2,1 \rangle$$

So for some value of $t$, call it $k$, the vector from $A$ to $\langle 1,-2k,1+k \rangle$ is orthogonal to $\langle 0,-2,1 \rangle$. Thus

$$(\langle 1,-2k,1+k \rangle-\langle 4,2,1\rangle)\cdot \langle 0,-2,1\rangle=0$$

$$\langle -3,-2k-2,k \rangle\cdot \langle 0,-2,1\rangle=0$$

$$4k+4+k=0$$

$$k=-\frac{4}{5}$$

so now you should be able to find the point.

$\endgroup$
2
$\begingroup$

Arbitrary point on the line: $(1, 2t , -t)$ for $t \in \mathbb R$. The line is parallel to the vector $\vec{BC} = <0,2,-1>$.

If $D(1, 2t_0,-t_0)$ is the point on the line closest to $A$, we must have $\vec{AD} \bullet \vec{BC} =0$ (because $\vec{AD}$ must be perpendicular to the line)

$\endgroup$
2
$\begingroup$

By translation, we may assume one of the points (say $C$) is the origin (which is to say, consider $A-C$ and $B-C$ instead). Then, the question is what is the distance between a vector $A$ and the orthogonal projection of $A$ onto the subspace spanned by the vector $B$. Let $s=(a_1b_1+a_2b_2+a_3b_3)/(b_1^2+b_2^2+b_3^2)$. Then, the distance is this formula: $\sqrt{(a_1-sb_1)^2+(a_2-sb_2)^2+(a_3-sb_3)^2}$. This is $\lVert A-\frac{A\cdot B}{B\cdot B}B\rVert$.

$\endgroup$
2
$\begingroup$

Another approach (a very low-tech solution). By the Pythagorean theorem we have $$ AB=\sqrt{13},\qquad AC=\sqrt{10},\qquad BC=\sqrt{5}\tag{1}$$ hence $ABC$ is an acute triangle (since $AB^2<AC^2+BC^2$ and so on) and by calling $H_A$ the projection of $A$ on $BC$, we also have $$ H_A B^2 - H_A C^2 = AB^2 - AC^2 = 3 \tag{2}$$ Since $H_A B + H_A C = BC = \sqrt{5}$, from $(2)$ it follows that $H_A B-H_A C = \frac{3}{\sqrt{5}}$, so: $$ H_A B = \frac{4\sqrt{5}}{5}\qquad H_A C = \frac{\sqrt{5}}{5}\tag{3}$$ and: $$\boxed{\phantom{\sum_{j=1}^{n^2}} H_A = \frac{4}{5}C+\frac{1}{5}B = \color{red}{\left(\frac{5}{5};\frac{8}{5};\frac{1}{5}\right)},\qquad AH_A^2 = AC^2-H_A C^2 = \color{red}{\frac{49}{5}}\phantom{\sum_{j=1}^{n^2}}}\tag{4} $$

$\endgroup$
0
$\begingroup$

Playing with the solutions, I built this simulation one of them:

Using a vector equation of the line through $BC$. And Pythagoras's theorem to get the distance from $A$ to a point in the line.

Minimised by using the point where the derivative equals 0.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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