Quaternion Scaling

I'm writing a simply physics engine for a game I'm working on (it's simple enough that a full physics engine isn't justified), and I'm trying to scale the angular velocity (a quaternion) by the frame time (in seconds) when I integrate it into the rotation of a physics node. The end result should be that the angular velocity represents the rotation the node will make in a second rather than the rotation each frame.

Right now, I'm trying to do it with this:

Quaternion rotation = node.getAngularVelocity().mult(timePerFrame);
rotation = node.getLocalRotation().mult(rotation);

The problem is that with this approach, the quaternion seems to go to zero after a few frames, which seems to break quaternion math. Normalizing the quaternion seems to just remove the effect completely, so I'm wondering what I should be doing.
Any help would be greatly appreciated, even it it's just telling me I'm an idiot and I should be doing something else.

first off:

debio264 said:


will save you statements and variables (not object creation) at each frame. and does the same, which might be wrong  :wink:

next, if you want to add a portion of a rotation each frame you can use the method Quaternion.slerp(). In you rcase you should slerp from an initial quaternion:

private static final Quaternion quat = new Quaternion();
private static final Quaternion tmpQuat = new Quaternion();
node.getLocalRotation().multLocal(tmpQuat.slerp(quat, node.getAngularVelocity(), timePerFrame);

Thanks, slerp is exactly what I was looking for.