Hello,

I’m working on a research project and got bugged in a corner, if anyone can give some guidelines it would be very appreciated. The values I’m trying to extract are in right hand system.

So lets say I have a Cube and there are forces applied to it (like water and buoyancy or gravity and

elasticity/resilience). I need to know what is the velocity, acceleration, angular velocity and angular acceleration and rotation matrix of the Cube. I accept 2 relative points World(W) and Body(B).

So if I got everything about Unity right. velocity is simple:

x’(B),y’(B),z’(B) - which is exactly rigidbody.velocity Vector3.

same goes for angular Velocity it would be equal to rigidbody.angularVelocity Vector3.

Next come the accelerations - since Unity does not provide a Vector for those (or does it?) I assumed I need to calculate them.

So a acceleration Vector would be a function derived from last object velocity:

Vector3 acceleration = (ownerRB.velocity - lastVelocity) / Time.fixedDeltaTime;

Same for angular acceleration

Vector3 angularAcceleration = (ownerRB.angularVelocity - lastAngularVelocity) / Time.fixedDeltaTime;

I’m assuming that speeds are m/s and radians/s while accelerations m/s2 and radians/s2

Please correct me if I’m wrong anywhere.

So now comes the biggest pinch I have :

I need a Matrix of directional cosines aka World to Body Rotation Matrix which is a 3x3 matrix.

What would be the most effective way to obtain this? I see that unity provides something like

rigidbody.transform.worldToLocalMatrix - however it seems it is not helpful.

So the next method I assume would be best is to calculate this from eulerAngles (which is a pain)

Assuming that Xb = Rw->b * Xw and Rw->b^T = Rw->b^-1 = Rb->w

So My Matrix would look like the below(? I’m absolutley not sure about it)

m00 = cos(z)*cos(x)+sin(z)*sin(y)*sin(x)

m01 = cos(x)*sin(z)*sin(y)-sin(x)*cos(z)

m02 = cos(y)*sin(z)

m10 = cos(y)*sin(x)

m11 = cos(x)*cos(y)

m12 = -sin(y)

m20 = sin(x)*cos(z)*sin(y)-sin(z)*cos(x)

m21 = sin(z)*sin(x)+cos(x)*cos(z)*sin(y)

m22 = cos(y)*cos(z)

If anyone could help with getting around those transformation this would be appreciated.