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

My question is the following

enter image description here

How can I get point $(x3, y3)$ from points $(x1, y1)$ and $(x2, y2)$ ?

The distance of point $(x3, y3)$ from $(x1, y1)$ is $300$.

share|cite|improve this question

migrated from stackoverflow.com Feb 18 '11 at 18:23

This question came from our site for professional and enthusiast programmers.

up vote 9 down vote accepted

Assume

dx = x2 - x1
dy = y2 - y1

Then,

x3 = x1 + dx*k
y3 = y1 + dy*k

The square of distance between p1 and p3 is

(dx^2 + dy^2)*k^2 = 300^2

Now you can find k and then x3 and y3

share|cite|improve this answer
    
It gives me wrong answer – Sami May 26 '14 at 12:50
    
@Sami Can you give an example? – Nikita Rybak Jun 9 '14 at 3:27
    
Sorry its right. It was only my programming language problem. It tired it in javascript. I later came to know that there i had to use Math.pow(x,2) instead of x^2 – Sami Jun 9 '14 at 8:43

defining:

P1 (x1,y1)

and

P2 (x2,y2)

and the distance "d", in the case with the value of 300 units

d = 300

you can define a vector (namely "u") pointing from P1 to P2, using vector subtraction:

u = P2 - P1

(in the way that P2 = P1 + u)

then, you can normalize "u" making it unit norm, we can name that vector "v"

v(ux/norm(u),uy/norm(u))

with

norm(u) = (ux^2+uy^2)^0.5

to obtain the third point (namely P3), you need just to sum a vector with the direction from P1 to P2 with the norm equal to the distance (in case 300 units), in our notation:

P3 = P1 + v * d

Thanks to the illustration, we now that the direction is from P1 to P2. But remember, that only given the distance, are two solutions: the above and with -v (300 units from P1 in the direction from P2 to P1).

That solution is valid for a euclidean space with any number of dimensions (changes only the number of components to normalize and the number of elements to calculate the norm).

share|cite|improve this answer

Your Answer

 
discard

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.