HI All,
How can I calculate direction vector of a line segment, defined by start point (x1, y1) and end point (x2, y2)?
Cheers.
HI All,
How can I calculate direction vector of a line segment, defined by start point (x1, y1) and end point (x2, y2)?
Cheers.
(x2 - x1, y2 - y1)
If you want the unit direction vector, divide each component by sqrt((x2 - x1)² + (y2 - y1)²).
Hi
The direction vector can be represented as (x2 - x1)i + (y2 - y1)j where i and j are unit vectors along x and y axis respectively.
cheers
If you want the vector from the end of vector (x1,y1) to the end of vector (x2,y2), the answer is
(x2-x1, y2-y1) + (x1,y1)
If you want the (unit-length) direction vector, then the answer is
((x2-x1)/L, (y2-y1)/L)
where L=√((x2-x1)² + (y2-y1)²)
(thats $L=\sqrt{(x2-x1)^2 + (y2-y1)^2}$
in LaTeX).