# Pitch becomes yaw as camera gets near object

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:

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;
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);
Math_Quaternion_Normalize(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!

• 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? – DMGregory Mar 11 '18 at 21:12
• I fixed it by omiting the multiplyVec3(left... line and just using left as (1, 0, 0); – Whiteclaws Mar 11 '18 at 21:20