
Have I got my maths wrong? The following code causes rotation around the xaxis, but flips 180 degrees around the x axis at some point instead of completing a whole 360 degrees.
_light.Position.Y = Camera.Position.Y = (float)Math.Sin(_cameraAngleRadians)
* 50f;
_light.Position.Z = Camera.Position.Z = (float)Math.Cos(_cameraAngleRadians)
* 50f;



Correction:
Have I got my maths wrong? The following code causes rotation around the xaxis, but flips 180 degrees around the
y axis at some point instead of completing a whole 360 degrees around x.
_light.Position.Y = Camera.Position.Y = (float)Math.Sin(_cameraAngleRadians)
* 50f;
_light.Position.Z = Camera.Position.Z = (float)Math.Cos(_cameraAngleRadians)
* 50f;



I lack the mathematical explanation, but I'll try to explain what is happening.
When you rotate around the Y axis like you do, when the position and lookat are close to aligned and that is the same as what is defined as UP, the calculations will result in what can be seen as a flip on the X. What it is actually doing is trying to
maintain UP and the camera rotates to achieve this. If change the radians slowly, you should see the effect better.



Hi, it doesn’t happen when I rotate around the X axis. Is there a solution to it?
Kind Regards
Mark


Oct 22, 2009 at 10:03 AM
Edited Oct 22, 2009 at 10:04 AM

It doesn't happen because UP is never aligned and represents the same direction as the cameras direction.
You might be able to avoid it by calculating the UP vector I guess every frame. Something like this (not tested) :
var up = Vector.Normalize(Camera.Target  Camera.Position);
Camera.Up = up;
Only problem is that at this point you can't set the Up vector directly on the Camera. It is calculated from the Roll. I can put an item in the backlog for enabling the change of the UP vector.

