I’ve discovered what seems to be either an oddity in the Quat class or an issue with quaternions that I could use a solution to:
Consider the following (tested using 1.8.1, I think that it was):
from panda3d.core import Quat, Vec3
quat1 = Quat()
quat2 = Quat()
quat1.setHpr(Vec3(0, 0, 0))
quat2.setHpr(Vec3(0, 0, 90))
print quat1.angleDeg(quat2)
Note that the two Quats differ only in the component specified by “roll”, but that they do differ.
The output, for me, at least, seems to be a very small number – in other words, the result seems to be that they are considered to be more or less the same rotation, when one would expect a 90-degree angle between them.
On the other hand,
Is this an issue in either Quat.setHpr or Quat.angleDeg, or is it a quaternion issue? (I’ll confess that my knowledge of quaternions is somewhat superficial.)
For context, I’m attempting to slerp between two Quats based on time; since the process is intended to respond to user input, I would prefer to not use a LerpQuatInterval. I’m currently attempting to calculate the appropriate ratio to pass to my slerp method by calculating the angle between the desired Quat and the current Quat, and then defining the ratio to be my maximum rotation for this frame divided by the above angle (and skipping the slerp if the angle is less than that maximum rotation). Unfortunately, since roll is included in the angles that compose my Quats, I’m finding that in cases in which there is significant difference in roll but little difference in heading or pitch, the angle returned is very small and so either the slerp runs very quickly or is skipped entirely.
If this is a quaternion issue, then what might I do about it?
My thanks for any help given.