• Create Account

## glm's angleAxis function creates identity quaternion if angle 0 is passed

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1Aitorman  Members

126
Like
0Likes
Like

Posted 15 September 2012 - 03:07 AM

Hello there!
In my game I have a vec3 that points from the camera to an object i want the camera to follow, so I use this to get the camera's orientation quaternion:

this->cameraRot=glm::angleAxis(0.0f,vector);

If i understand that function correctly, when passing a vector (0.0f,0.0f,-1.0f) for example, it should create a quaternion that orientates the camera to point directly into the depth of the screen with no roll, and for example, with a vector (1.0f,0.0f,0.0f), it should orientate the camera to the right, with no roll too. But i don't know why, that function only creates a quaternion different from the identity quaternion if I pass a value different from 0 to the angle. Why does this happen?

### #2clb  Members

2143
Like
0Likes
Like

Posted 15 September 2012 - 04:00 AM

No, your understanding is off. Angle-axis rotation generates rotation about the given axis, by the given angle. If you don't specify an angle, you'll always get identity back. This is because rotation a zero angle, be it about any axis, of course does not rotate at all.

What you are thinking about is the LookAt rotation. I am not sure what the function signature in glm is, but I'm sure they have a similar function. Use a LookAt rotation to orient one direction vector to face towards another vector.
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

### #3Aitorman  Members

126
Like
0Likes
Like

Posted 15 September 2012 - 06:21 AM

Thank you! My way of thinking seems silly now that I understand what it really does, corrected!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.