Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direction of two points

Some high school math concept has been forgotten, so I ask here.

If I have two points p1(x1,y1), p2(x2,y2), the direction is P1-->p2, that's p1 points to p2. To represent this direction by vector, is it Vector(x2-x1,y2-y1) or Vector(x1-x2, y1-y2)?

By the way, what is the purpose to normalize a vector?

like image 855
Mellon Avatar asked Mar 30 '11 08:03

Mellon


People also ask

What is the formula for direction?

To calculate the direction of the vector v⃗ = (x, y) , use the formula θ = arctan(y/x) , where θ is the smallest angle the vector forms with the horizontal axis, and x and y are the components of the resultant vector.


1 Answers

  • Answer 1: it is Vector(x2-x1,y2-y1)
  • Answer 2: Normalizing means to scale the vector so that its length is 1. It is a useful operation in many computations, for example, normal vectors should be specified normalized for lighting calculations in computer graphics. The normalized vector of v(x,y) is vn(x/Length(v), y/length(v)).

HTH

like image 115
Armen Tsirunyan Avatar answered Sep 27 '22 19:09

Armen Tsirunyan