# 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???
###### Who is Participating?

Commented:
P1 - P2 means to subtract the two vectors from each other.
|| P1 - P2 || calculates the length of difference vector, i.e. the two vectors subtracted from each other.
Dividing a vcetor by its norm/length means to normalize it. The resulting vector will have length = 1.

A simple case (perhaps too simple):

P1-P2 vector
+ <---------------+
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
0

Commented:
Yes, provided that you want the normalized vector difference pointing from P2 to P1.
0

Author Commented:
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?
0

Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.