glRotatef(-pitch(), 1.0f, 0, 0); glRotatef(-yaw(), 0.0f, 1.0f, 0); glRotatef(-roll(), 0.0f, 0.0f, 1.0f); glTranslatef(-pos().x, -pos().y, -pos().z);
I have encountered 0 problems with this implementation so far. However, I am starting to implement classes for objects in my 3D world and quickly realized the order of operations would definitely matter, i.e. (X * Y * Z) != (Z * Y * X) for rotations.
It seems the standard solution to this issue and others (Gimbal lock, interpolation, etc.) is to employ quaternions to represent the same information in a different form. I have read several tutorials on quaternions from around the net, and I have a few questions:
1. How do you visualize a quaternion? It's simple to imagine a vector and rotation around a vector. But how do you visualize a + bj + ck + dl? What does each component represent (visually)? For example, I'm having a hard time imagining what adjusting the scalar component or any of the complex parts does to my rotation.
2. I have found several equations for converting a quaternion to a 4x4 matrix. I was therefore considering using a single quaternion to represent my camera instead of the code above. However, I'm not sure I understand how. For example, how are pitch, yaw, roll, and a vector all contained within 4 values? I'm definitely missing something here.
3. Does an implementation using quaternions come with an implicit performance hit? It seems translating provided angles into a quaternion, then into a matrix, and finally multiplying that matrix with the MODELVIEW is expensive.
Edited by Overdunn, 24 October 2012 - 01:02 PM.