I have been having trouble with my camera, first encountering the roll tilt that is so many times asked... I fixed that issue by following the instructions at this link: Unwanted roll when rotating camera with pitch and yaw But now I find another issue, whenever I get close to my triangle, pitch becomes roll, and instead of moving up and down the triangle, the camera rotates around the plane of that triangle, see:

Pitch is fine, but as i get close the the triangle, it becomes roll

This is my code, I follow the same logic as the link above!

  float spitch = pitch * camera.sensitivity, syaw = yaw * camera.sensitivity;
  float npitch = Math_Quaternion_GetPitch(camera.rotation) + spitch;
  if(npitch > Math_Degrees_ToRadians(85) || npitch < Math_Degrees_ToRadians(-85)) return;
  Math_Quaternion yaw_quat;
  Math_Quaternion pitch_quat;
  Math_Vec3 up = {0, 1, 0};
  Math_Vec3 left = {1, 0, 0};
  Math_Quaternion_RotationAroundAxis(yaw_quat, up, syaw);
  Math_Quaternion_MultiplyVec3(left, camera.rotation, \* this is out! *\ left);
  Math_Quaternion_RotationAroundAxis(pitch_quat, left, spitch);
  Math_Quaternion_Multiply(pitch_quat, camera.rotation, camera.rotation);
  Math_Quaternion_Multiply(yaw_quat, camera.rotation, camera.rotation);

Edit: Also, switching the quaternion multiplication order or just using a normal pitch yaw roll method fixes the problem, but then the roll problem comes back!

  • \$\begingroup\$ It's a bit tough to get a sense of the motion happening in the animation. Are you able to record one with a visible horizon/sky to use as a global up/down reference? \$\endgroup\$
    – DMGregory
    Mar 11, 2018 at 21:12
  • \$\begingroup\$ I fixed it by omiting the multiplyVec3(left... line and just using left as (1, 0, 0); \$\endgroup\$
    – Whiteclaws
    Mar 11, 2018 at 21:20
  • \$\begingroup\$ You can accept your own answer. \$\endgroup\$
    – Theraot
    Aug 5, 2019 at 18:57

1 Answer 1


I fixed it by omiting the multiplyVec3(left... line and just using left as (1, 0, 0); Edit: I just clumsily moved the code, made a mistake and it solved the issue, but I believe I'm locking the rotation around the x and y axis hence left and up instead of rotating my object relative to the quaternion's own up and left vectors... I'm not sure why it fixes the problem but it does!

  • 6
    \$\begingroup\$ This answer would be even better if it included some insight into why this fixes the issue, to help others who run into similar problems. \$\endgroup\$
    – DMGregory
    Mar 11, 2018 at 23:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .