11
\$\begingroup\$

I have two points (A, B) and the length of d. How can I find point C?

example

\$\endgroup\$
26
+500
\$\begingroup\$

Compute a vector V from A to B, and normalize it.

V = (B - A) / |B - A|

Since the vector is normalized, it will have a length of one, and it will indicate the direction of B relative to A. If you then scale the vector by d you will have the displacement from A to C

V' = d * V

which you can simply add to A to yield C:

C = V' + A
\$\endgroup\$
1
\$\begingroup\$

In case your d is a ratio instead of a length, e.g 0.5 puts it on equal distance from A and B, you can do the following and avoid a normalization:

C = A * (1 - ratio) + B * ratio
\$\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.