I am trying to claculate the angle of vectors in degrees. But I don't know where the origin of coordinates is in case of calculating the angle. So far, I use something like this:
degree = 180*(atan2(vector.back().y - vector.front().y, vector.back().x - vector.front().x))/M_PI
But the result is always positive, even if the x
or y
values are decreasing.
My questions are:
- Where is the origin and orientation of the angular 2D plane? Is it top left corner?
- How can I correctly calculate the angle of a vector?