How to compute 2 parallel points from 2 given points
Through 2 given points runs a line (K1 and K3). I want to compute (find) 2 others points (X1,X2), which are parallel to given points. Al开发者_Go百科so I have center point(K2) between first and last point on this line.
Illustration
I have K1,K2 and K3
How to find X1 and X2? I'm coding in C# in WPF, and I don't know how to solve this problem... please, help me
Roberto
The vector tangential to your original line has the components
t_1 = K3_1 - K1_1
t_2 = K3_2 - K1_2
A normal vector to this line would be
n_1 = t_2
n_2 = -t_1
The length of the vector n
is equal to the distance from K1
to K2
. Since you actually want a quarter of this distance, your final result is
X1_1 = K1_1 + 0.25 * n_1
X1_2 = K1_2 + 0.25 * n_2
X2_1 = K2_1 + 0.25 * n_1
X2_2 = K2_2 + 0.25 * n_2
Note that you could choose the opposite sign for n
, in which case you'd end up with a parallel line translated by the same distance in the opposite direction.
精彩评论