Advertisement

Stupid rotation question

Started by October 10, 2002 12:36 AM
1 comment, last by Abdhl Al Hazred 22 years, 4 months ago
I have a frustration problem... I want the find the angle beteen the vector from the object to the point where I click the with the mouse. How to do it? I know the objects position and direction. This is how I think I should do:
  

pkObject->m_fDstRadAngleCWZ = (float) atan( 
(pkObject->m_kClickPos.y - pkObject->m_kPos.y) / (pkObject->m_kClickPos.x - pkObject->m_kPos.x) );    

if( pkObject->m_kClickPos.x < pkObject->m_kPos.x )
   pkObject->m_fDstRadAngleCWZ -= D3DX_PI;

  
It works but the angle is not between (0 to 2 pi) but (0.5 to -0.5 pi). I can´t use that angle! Please help!
When the stars are right they will awake...
if(angle<0.0f) angle+=2.0f*M_PI;
Advertisement
Thank you! It works perfect now!

This topic is closed to new replies.

Advertisement