The shortest distance between two points is a line, so just move that x point of units along the line connecting the two points.
Edit: I didn’t want to give the specifics of the answer if this is homework, but it is simple enough to be illustrated without being too spoiler-y.
Suppose you have two points A = (x 1 , y 1 ) and B = (x 2 , y 2 ). A line including these two points has the equation
(x 1 , y 1 ) + t? (x 2 - x 1 , y 2 - y 1 )
where t is some parameter. Note that for t = 1 point indicated in the line is B , and for t = 0 point indicated in the line is A
Now you want to move B to B' , a point that is the new distance d from A :
AB' B (+)---------------------(+)-----------(+) <
Point B' , like any other point on the line, is also determined by the equation that we showed earlier. But what value do we use t ? Well, when t is 1, the equation points to B , which is |AB| units from A Thus, the value of t that B' indicates is t = d/|AB| .
Solution for | AB | and the inclusion of this in the above equation is left as an exercise for the reader.
John feminella
source share