Angle between two vectors
Here’s the formula to get the angle between two vectors in 2D space.
vector2 diff = target - position; float angle = atan2(diff.y, diff.x); |
Here’s the formula to get the angle between two vectors in 2D space.
vector2 diff = target - position; float angle = atan2(diff.y, diff.x); |
When doing transformations you should use homogeneous notation of vectors and points.
A point is declared as p = (x,y,z,1)
A vector is declared as v = (x,y,z,0)