Archived

This topic is now archived and is closed to further replies.

sark

Calculating the clockwise angle between 2 3d vectors

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 --

Share this post


Link to post
Share on other sites

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 --

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Thanks guys, i think i got it now. Also, i should have said "CW and CCW when looking down the Y axis", sorry.

Share this post


Link to post
Share on other sites