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: