Function for translating the final coordinates of the line

I have two points at the end of the line.
I need to get the final coordinates of the translation of this line.
The translation will be a parallel line, which is the distance d from the original line.
here is an image of what i need:

enter image description here

So, I need a function through which I can transfer these two points and the distance and get two new coordinates in the returns.
I was stuck with this problem for a while. Any help would be appreciated! Thanks you!

+5
source share
2 answers

The new coordinates will be the resulting vector.

d, , , .

EDIT:

, , . , ..

, d, .

+3

(x2-x1, y2-y1). .

    (-(y2-y1),-(x2-x1)) = (y1-y2,x1-x2). 

,

    A = (y1-y2,x1-x2)/|(y1-y2,x1-x2)|

, d,

    NewPoint = OldPoint + d * A
+2

All Articles