Calculating the clockwise angle between 2 3d vectors

Started by
6 comments, last by sark 21 years, 8 months ago
I have a 3d model. This 3d model has a direction vector, with x and z components (i dont want it moving across the y plane, so thats always zero). To make sure my model is facing in the direction it moves in, i need to find out the angle between the normalized direction vector and a vector with an X component of 1.0f and Z of 1.0f. I''ve tried using arc cos(dot product of the two vectors) But this only gives me an angle which could be clockwise or anticlockwise... I hope i''ve made sense. I can draw diagrams if i havent.
Advertisement
If I am not mistaken, using acos will always turn up a CCW-related number, becasue CCW is the direction positive angles go.

So you would take that number and convert it to CW- I don`t know the algorithim off the top of my head...

~V''lion

Bugle4d
~V'lionBugle4d

The dot product always gives the shortest angle between two vectors and is always between 0-180. It never indicates that it is CW or CCW.
If y-component is zero[becomes 2D case]. Then cross-product will always in y-diretion. The sign(+ or -) of y-component indicates CW or CCW direction.

Alam
-- Learning never ends --
Alam-- Learning never ends --

The dot product always gives the shortest angle between two vectors and is always between 0-180. It never indicates that it is CW or CCW.
If y-component is zero[becomes 2D case]. Then cross-product will always in y-diretion. The sign(+ or -) of y-component indicates CW or CCW direction.

I am intrested to know the direction if vectors are 3D and have nonzero x,y,z components.

Alam
-- Learning never ends --
Alam-- Learning never ends --
In general 3d, doesn''t clockwise and anti-clockwise depend entirely upon the observers position?
E.g. a ferris wheel is spinning clockwise. Now I walk over to the other side and look back at it. What way is it spinning? It''s spinning anti-clockwise.
You can say that vertices are ordered CW or CCW, because you have the normal as a reference direction.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
If you have a vector U that you know is pointing in the "CW direction", then

if((V X N) . (U X N) > 0) V is clockwise else V is CCW

As others have mentionned clockwise and CCW don''t make much sense in 3D.

Cédric
You can only determine CW/CCW direction by knowing the axis of rotation. On one vector it would by CW, and on the opposite vector (parallel, but facing the other direction) it would be CCW.
It's not what you're taught, it's what you learn.
Thanks guys, i think i got it now. Also, i should have said "CW and CCW when looking down the Y axis", sorry.

This topic is closed to new replies.

Advertisement