Given unit vector 0.5, 0.5 how could I find the angle (its direction),
is it
cos(x) + sin(y)?
To calculate the angle between two vectors in a 2D space: Find the dot product of the vectors. Divide the dot product by the magnitude of the first vector. Divide the resultant by the magnitude of the second vector.
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
#include <cmath> double x = 0.5; double y = 0.5; double angleInRadians = std::atan2(y, x); double angleInDegrees = (angleInRadians / M_PI) * 180.0;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With