   Angle between 2 vectors
  Hi!I have 2 vectors! Player look-vector and pick vector, and I wanna rotate my player to be look at picked point!I don't do this with D3DXMatrixLookAtLH 'cause this will rotate my player suddenly!I try to get the angle between vectors, but I couldn't!D3DXVECTOR3 dir;D3DXVECTOR3 look;look = GetGameApp()->GetPlayer()->GetLook() - GetGameApp()->GetPlayer()->GetPosition();dir = pPick - GetGameApp()->GetPlayer()->GetPosition();D3DXVec3Normalize( &dir, &dir );D3DXVec3Normalize( &look, &look );GetGameApp()->GetPlayer()->Rotate( 0.0f, D3DXToDegree( acosf( D3DXVec3Dot( &dir, &look ) ) ), 0.0f );   
  Well the reason this is, when you dot product the 2 vectors you DO get the angle between them, but you don't get any info about the plane that angle lies on.IE you dont get enough information to interpolate from one angle to the other.There is a simple way to do what you are trying to do though...Every frame, add the current eye vector and the destination pick vector together and divide them by 2 (basically you are averaging the 2 vectors).Use this vector as your new look vector for D3DXMatrixLookAtLH.This will make it so the camera will rotate to the picked position over time instead of all at once.It will also make it look pretty nice because it will start moving towards it quickly, then slow down and have a very "soft" feel to it which is kind of pleasant.Give it a shot, you won't be disappointed! (:EDIT: i think youll have to re-normalize the vector after you average the 2BTW this is just one way to interpolate between the current eye and destination pick vector.  You can change the way / speed it interpolates at if it moves too fast or you want a different behavior but the underlying principle is usable in a wide variety of scenarios.[Edited by - Atrix256 on May 6, 2010 4:57:00 PM];  also btw, if you cross product your 2 vectors together to get a vector perpendicular to them, you'll have the axis you would have to rotate around to get from one angle to the other if you are more keen on going that route   ;Quote:Original post by Atrix256It will also make it look pretty nice because it will start moving towards it quickly, then slow down and have a very "soft" feel to it which is kind of pleasant.Yep.You can use a weighted average to change the speed of the transition. You can get constant-speed rotation, too, if you make the appropriate adjustment to the weighting at each step (might be trickier than you think). And yes, you should re-normalize after averaging.   ;  Ok!Thanks a lot!   