dadadude
asked on
Geometric direction vectors
I have a problem with the following formula i don't know if it's correct:
i have the following vectors: P1 = (x1,y1), P2 = (x2,y2).
the formula is the following:
P1 - P2 / || P1 - P2 || where ||.|| is the norm.
i did the following.
(x1-x2)/ sqrt[(x1-x2)^2 + (y1-y2)^2]
(y1-y2)/ sqrt[(x1-x2)^2 + (y1-y2)^2]
is that the right way to do it???
i have the following vectors: P1 = (x1,y1), P2 = (x2,y2).
the formula is the following:
P1 - P2 / || P1 - P2 || where ||.|| is the norm.
i did the following.
(x1-x2)/ sqrt[(x1-x2)^2 + (y1-y2)^2]
(y1-y2)/ sqrt[(x1-x2)^2 + (y1-y2)^2]
is that the right way to do it???
Yes, provided that you want the normalized vector difference pointing from P2 to P1.
ASKER
can you pleae explain more the formula? just a simple explanation.
i didn't understand why they are substracting the vectors then dividing by the norm. is it just like u said to normilize?
i didn't understand why they are substracting the vectors then dividing by the norm. is it just like u said to normilize?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A small typo - Missed trailing ||
P1-P2/||P1-P2|| vector is the solid line, i.e., a vector pointing in the same direction, but only 1 unit long.
+ <- - - - -<-----+
P1 P2
P1-P2/||P1-P2|| vector is the solid line, i.e., a vector pointing in the same direction, but only 1 unit long.
+ <- - - - -<-----+
P1 P2