Get RigidBodyControls velocity in relation to the local axes

Hello there,

Is there a way to get the 3 velocities of a RigidBodyControl in the local directions x, y and z? In other words:
If I have a block with dimensions (10, 1, 2), how can I get the velocity in x, y and z, in relation to the blocks local axis, regardless of its rotation? I want the component of the velocity in the 10-unit direction, as well as the velocity in the 1-unit and 2-unit direction.

myShipsPhysics.getLinearVelocity() does give the x, y and z component in World, but not local to the controls axes. I have tried something like:
[java]speedVector.set(myShipsPhysics.getPhysicsRotation().normalizeLocal().mult(myShipsPhysics.getLinearVelocity()));
[/java]and then use speedVector.x or .y or .z but it’s not succesfull. I have the feeling this should be the way to go, but just don’t know how exactly.

Setting the myShipsPhysics.setApplyPhysicsLocal(true) does work, but entirely screws up the rest of my code and also requires more nodes and more work on having the additional parent node follow the myShipsPhysics. Either I do something wrong with this, or it is just not the way to go :-?

Anyway, if there is an easy way of getting the local velocity components, I would be very happy!

Just do localRotation.mult(velocityVector)

Hmm… I don’t get it: What is this ‘localRotation’ you are talking about?

I found this topic, but that’s not the same as what I am trying to achieve. I need the velocity to calculate friction in different directions. I just don’t see it…

When you have an object in water, it has different friction forces in different directions, depending on the exposed surface (or area) perpendicular to that direction. I need to calculate the individual friction force in x, y and z direction, based on these areas and the speed in that particular direction. Since the object rotates in the water, I need the speed relative to the objects axes, not to world axis.

Would your ‘localRotation’ mean something like
myShipsPhysics.getPhysicsRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(0,0,1))) which I then can multiply with myShipsPhysics.getLinearVelocity, like:
[java]myShipsPhysics.getPhysicsRotation().mult(new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(0,0,1))) .mult(myShipsPhysics.getLinearVelocity());[/java] ???