Reputation: 593
I am using a GLM quaternion to represent an orientation for an object.
Basically, I would like to add the ability to extract the angle of an axis from the quat. I don't know if this is what I need to do; but a use for this would be trying to spin the cube on the y axis, to increment the angle I need to get the old angle first, right? So
cube.setOrientation(cube.getAngleOnAxis(0, 1, 0) + 5);
And that should spin the cube by five degrees, right?
The issue I have is implementing the getAngleOnAxis function. Is there a GLM function that can extract the angle?
I'm not certain I've actually thought of the right solution so it would be great if someone with experience can explain this simpler. Thanks!
Upvotes: 0
Views: 479
Reputation: 473537
to increment the angle I need to get the old angle first, right?
No. The whole point of using a quaternion is to not have to do that. You simply multiply a new quaternion into the old one, normalize the result, and that's your new orientation.
Upvotes: 2