title: How do I convert these 3D camera trig equations to work on a new axis
body: <p>The following function calculates the target vector of my FPS camera to put in the OpenGL LookAt method. Camera orientation (in radians) (0,0,0) means the camera is parallel to the z axis looking in the negative direction and the camera right vector is parallel to the x axis in the positive direction.</p>
  
  <pre><code>    static Matrix4 GetViewMatrix()
      {
          Vector3 cameraup = Vector3.Transform(Vector3.UnitY,(Quaternion.FromAxisAngle(LineOfSightVector, Orientation.Z)));
          LineOfSightVector.X = (float)(Math.Sin((float)Orientation.X) * Math.Cos((float)Orientation.Y));
          LineOfSightVector.Y = (float)Math.Sin((float)Orientation.Y);
          LineOfSightVector.Z = (float)(Math.Cos((float)Orientation.X) * Math.Cos((float)Orientation.Y));
          return Matrix4.LookAt(Position, Position + LineOfSightVector, cameraup) * View;  //View = createperspectivefield of view matrix4
      }
  </code></pre>
  
  <p>It works fine when the camera y axis is (0,1,0). However I have introduced a Z  value to my camera orientation (roll).  I use that to get the "cameraup" vector. I now need to adjust the 3 trig equations for the LineOfSightVector to take into account the change in the "up" vector so the camera controls go in the right direction. Can someone please advise me on this.</p>
  
  <p>Thanks  </p>