   Angle between view vector and point
  Hello,I've been trying to calculate the angle between the view vector and another point, in order to determine to what degree the point is to the left or the right of the centre of the screen.I know I can just use the dot product in 2d but I'm not sure how in 3d. At the moment, I've got the vectors:D3DXVECTOR3 vEyePt(0.0f,80,-0.1f );D3DXVECTOR3 vLookatPt( 0.0, 0.0f, 0.0f );D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );D3DXVECTOR3 objPos;but these can all change at run time. I think i probably need to incorporate the up vector somehow but dont know how. I was hoping to just get deduce a value between with 0 for the centre of the screen, negative numbers to the left, and positive numbers to the rightThanks for any help.   
  how come you spend ages trying to figure something out, then the moment you post the problem on a message board you get it working...I was right about the up vector, needed to dot the pos vector with the cross of the view and up vectors.   ;  Its the same in 3D as for 2Ddirobj = objectpos - vieworigin;dir.normalize();forward.normalize();angle = dir.dotproduct(forward);You can use the forward vector since this one is pointing straight through the center of your screen   ;Quote:Original post by likeregularchickensHello,I've been trying to calculate the angle between the view vector and another point, in order to determine to what degree the point is to the left or the right of the centre of the screen.There's an easier way to do this.  Multiply the point by your camera's view-projection matrix (use D3DXVec3TransformCoord).  If the x coordinate of the result is negative, its on the left, otherwise, its on the right.;Quote:Original post by BasirorIts the same in 3D as for 2Ddirobj = objectpos - vieworigin;dir.normalize();forward.normalize();angle = dir.dotproduct(forward);You can use the forward vector since this one is pointing straight through the center of your screenActually, its:angle = acos ( dir.dotproduct() )