I have two points in 3D space; let's call them $A=(a_x, a_y, a_z)$ and $B=(b_x, b_y, b_z).$

Now, I need to place a third point, let's call it $C=(c_x, c_y, c_z)$, which lies on the line between $A$ and $B$ and is some known distance from $A$.

Is there some easy way I can get the $c_x, c_y, c_z$ coordinates knowing the distance from $C$ to $A$?

I would easily be able to do this in 2D, but I never worked with 3D space and I can't seem to figure it out.



It's quite similar to 2D space. Consider a vector $v = B-A$ which you can imagine is the direction from $A$ to $B$. Hence for any point $C$ between $A$ and $B$ (inclusive of $A$ and $B$).

$$C = A + tv$$

where $t = 0$ implies $C = A$ and $t = 1$ implies $C = B$ and $t \in (0,1)$ are all the points in between (one of which is the desired $C$). As you can see, this representation is independent of the dimension of your space.

So, what's the value of $t$? Well, let the known distance from $A$ to $C$ be $d_{AC}$. Now, the distance between $A$ and $B$ or $d_{AB}$ is the magnitude of $v$ or $|v|$ which is nothing but

$$d_{AB} = |v| = \sqrt{(a_x-b_x)^2+(a_y-b_y)^2+(a_z-b_z)^2}$$

(You can see that this formula for the Euclidean distance between two points is similar in 2D as well)

Therefore, $t = \large \frac{d_{AC}}{d_{AB}}$ and substituting $t$ and $v$ in the previous formula for $C$, we have:

$$C = A + \frac{d_{AC}}{\sqrt{(a_x-b_x)^2+(a_y-b_y)^2+(a_z-b_z)^2}}(B-A)$$

  • $\begingroup$ @Jacob: I suspect that the question intended $x$, $y$, and $z$ to be subscripts. $\endgroup$ – André Nicolas Jun 20 '11 at 18:50
  • 1
    $\begingroup$ @Jacob: I hope you don't mind; I added the subscripts, centered your formulas...feel free to edit or roll-back to suit your taste. $\endgroup$ – amWhy Jun 20 '11 at 19:11
  • $\begingroup$ @amWhy: Thanks for changing the OP as well! $\endgroup$ – Jacob Jun 20 '11 at 19:18
  • $\begingroup$ @Jacob: Not a problem - I realized you were trying to "speak in the same language" as the post, for consistency, so I adjusted both... $\endgroup$ – amWhy Jun 20 '11 at 19:33
  • 1
    $\begingroup$ @meh: if you found the answer provided by Jacob helpful, there are two things you should consider: (1) you can "up vote" it (click on the upward arrow to the left of the answer, (2) and as the "asker" of the question, if an answer (or one of a number of answers) is helpful in answering your question, you're the only one who can click on the check mark to the left of the question to accept it. (Just some things to know about this site.) $\endgroup$ – amWhy Jun 20 '11 at 21:32

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.