I think what I said I needed was misleading. Basically, all I need to know is whether a clockwise or counterclockwise rotation is shortest (between 2 unit vectors). Becuase acos(product), the way it is now, returns absolute values, I don't think if(angle>180)angle-360 will help (even if I set up the code to work with angles, it'd still be the same for both directions of rotation).
EDIT- It's kinda hard to describe. I'm not really working with angles. When I did try to do so, I didn't seem to get any closer to a solution.
I have, by the way, read about dot products on Wikipedia. Apparently the dot product of two perpendicular vectors is 0. So to just rotate the vector by the dot product alone won't work; the scene node translated according to the vector will "orbit" the position it's supposed to reach. I need a bunch of functions that return 0 when the two vectors in question are
parallel, not
perpendicular.
EDIT2- I kinda know how I would do it. Find out the operation needed to map the to-vector onto vector(1.0, 0.0), perform the same operation on the from-vector (the node's orientation), then look at the x component of the returned vector: if it is positive, rotate clockwise, if negative, rotate counter-clockwise. Not sure how exactly at the moment (especially on the first part).
EDIT3- I tried to find the angle that one must rotate the to-vector by to get it to equal (0.0, 1.0), then rotate another temp-vector (set equal to the node's current orientation vector) by that angle, and finally do a check on the Y component of the resulting vector. I thought it was a sound concept, but it doesn't work at all.
Code: Select all
tempVector1.X=newDirection.X;
tempVector1.Y=newDirection.Y;
tempVector2=direction;
tempVector2.rotateXYBy(-tempVector1.getAngle(), vector3df(0.0,0.0,0.0));
if (tempVector2.Y>=0.0)
{
direction.rotateXYBy(10.0*delta, vector3df(0.0, 0.0, 0.0));
}
else
{
direction.rotateXYBy(-10.0*delta, vector3df(0.0, 0.0, 0.0));
}
Can someone
please enlighten me?
EDIT4(haha, the edits are getting ridiculous) I actually got it working using that method (I should've used the angle that you rotate the to-vector to itself, not the negative of it). However, my solution is a bit hackish and presumably not very efficient. I'd still be grateful for input on a simpler method.