#### Archived

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

# Calculating the clockwise angle between 2 3d vectors

This topic is 5875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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

1. 1
2. 2
3. 3
Rutin
22
4. 4
frob
18
5. 5

• 33
• 13
• 10
• 10
• 11
• ### Forum Statistics

• Total Topics
632567
• Total Posts
3007113

×