Angle from 2D unit vector?

jmasterx picture jmasterx · Jun 6, 2011 · Viewed 69.2k times · Source

Given unit vector 0.5, 0.5 how could I find the angle (its direction),

is it

cos(x) + sin(y)?

Answer

mpenkov picture mpenkov · Jun 6, 2011

Given y and x, the angle with the x axis is given by:

atan2(y,x)

With (0.5, 0.5) the angle is:

radians:

In [2]: math.atan2(0.5,0.5)
Out[2]: 0.7853981633974483

degrees:

In [3]: math.atan2(0.5, 0.5)*180/math.pi
Out[3]: 45.0