Been trying to get the relative angle of two vectors.
However what the code outputs is way off.
Anyone know where im going wrong?
Using two vectors and this line
ofDrawBitmapString(ofToString(point.angle(mouse), 5), 20, 40);
Output should be in degrees as in vec2f states.
Furthermore if you set the two vectors at the same angle but further apart it gives a different value again.
… confused ?
Anyone used it with any success?
I tried creating my own calcs but using set tan and atan don’t even correctly work for me..
What should be a very simple calculation has me stumped.
If you want to get the angle of the mouse relative to the center, using atan2 should get you sorted:
if you want the rotation compared to another point, don’t forget to do the subtraction between the two points(e.g. mouse,other point) first.
If you want to get the angle between 2 vectors in 3D(ofxVec3f) you need to normalize the two vectors then get the acos of the dot product between the vectors
ofxVec3f already gives you this functionality though the angle() and angleRad() methods where the angle returns the angle in degrees and angleRad in radians.
Here’s a basic test, displaying the angle between two random vectors in the console: