# Rotate according global axis c++ Quaternion

I'm trying to rotate a camera in c++ but all I succeeded to do is rotate the object himself or rotate the camera around the object i can't figure it out. What I want is rotate the camera on itself without moving it.

For example to rotate left, I did this:

camera.orientation = (Quaternion<float>(1,Direction<float,3>({0,-1,0}))*camera.orientation).to_norm();


Each time I draw, i apply the transformation below to all the point of the object.

transformation = cameraProj.getInverse() * (translation * (scale * rotation))


where camera.orientation is a quaternion and 1 is the angle.

I'm using apparently the global axis but it feels like the camera isn't at the origin while it's well 0,0,0.

Here a sample of what happens when i rotate to the left: https://www.youtube.com/watch?v=g4XsO08iqEw&feature=youtu.be

Thank you

• Have you tried exchanging the order of multiplication? – DMGregory Dec 1 '18 at 13:02
• Yes I did it changes the way of rotation but not as expected. when the camera is at a position (0,0,0), the environnement will turn around the camera if i'm using global axis, will not it ? – Antigone Dec 1 '18 at 13:20
• Can you describe the symptoms that are unexpected? – DMGregory Dec 1 '18 at 13:22
• Here what happens when i want to rotate to the left: youtube.com/watch?v=g4XsO08iqEw&feature=youtu.be I never touch to the camera position when i draw, i only transform the object. Do i have to do something else ? – Antigone Dec 1 '18 at 13:48
• Also, no matter what action i do (rotate, scale...) I always transform the object with this: transformation = cameraProj.getInverse() * (translation * (scale * rotation)). Would it be the problem ? – Antigone Dec 1 '18 at 14:45