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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yes, provided that you want the normalized vector difference pointing from P2 to P1.
dadadudeAuthor 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?
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Game Programming

From novice to tech pro — start learning today.