   Rotation again: Why is this standard calculation not working?
  I have a 3D space, with y always staying the same for my objects. The objects are placed like this: (x,1,z);I want to rotate the "objectToRotate" to face the "targetObject". In 2D space, the following works in a every project, but now I suddenly get wrong results.The idea behind this: Angle between x axis and object vector subtracted from the other objects' angle results in the included angle. Only thing to do therefore, is to add the angle to the "objectToRotate" rotation.float angle =(atan2(objectToRotate.z,objectToRotate.x)-atan2(targetObject.z,targetObject.x))*180/3.14159;if (angle < 0 )angle += 2*3.14159;objectToRotate.yAngle += angle;Are there other ways to do this? This doesnt seem to work at all.(actually the objectToRotate seems to rotate in circles, maybe because of floating point errors)How would I go about if the "y" coordinates of the objects could change?   
  You seem to be mixing degrees and radians. Forget about degrees and use radians everywhere. Your life will be easier.Well, your life will be even easier when you stop thinking in angles and start thinking in vectors, but that's a harder transition to make.   ;  Well that's my smallest problem, but you are right of course. (the angle was off by ~6 degrees.)   ;Quote:Original post by MeaiWell that's my smallest problem, but you are right of course. (the angle was off by ~6 degrees.)Perhaps you can show us a complete small program that shows a case where it doesn't do what you expected, together with a description of what you expected... It's hard to help with just what you posted.   ;  As alvaro described, you mixed degrees and radians inconsistently.float angle =atan2(...)*180/3.14159;  << measuring in degreeif (angle < 0 )angle += 2*3.14159;  << but wrongly adding 2PI to wrap around the negative degreeYou probably wants to add 360 instead.   