How to update a Quaternion?

I have a Quaternion orientation and another Quaternion for rotation speed. How to update the former with the latter? This is my non-working code:

    Quaternion facing = ...
    Quaternion rotation = ...
    Quaternion nQ=new Quaternion(facing.mult(rotation).mult(tpf));

The wiki is offline btw.

A Quaternion can represent an orientation. I struggle to understand what you mean with “a quaternion for rotation speed” because that is not an orientation and I suspect that it doesn’t actually represent what you think it does.
What you can do is interpolate between two quaternions representing orientations. Say that you have a current orientation and another quaternion representing the desired orientation, then you can do a ‘slerp’ interpolation to find another quaternion inbetween the two.

1 Like

Yeah, applying scaled euler rotation to a quaternion is not 100% straight-forward. I don’t think JME has a built-in for it.

SimMath does it in the Quatd.addScaledVectorLocal() method:

Edit: and note, I got that from a book. I don’t pretend to really understand it but I know it works because my physics engine uses it all. the. time.

1 Like

Thanks, I probably messed up and most likely wanted to do what you’re saying. I will add SimMath and expect to win.

The fun thing is, I probably don’t even need it, since I’m handling 2d shapes and a single float can handle all possible orientations… :stuck_out_tongue: