Documentation

Unity Engine

Download Unity

Unity Engine

ComputeLocalToWorldAngularVelocities

Computes the angular velocity of each bone in world space, from two consecutive streams of the same rig.
Read time 1 minuteLast updated 4 hours ago

Definition

ComputeLocalToWorldAngularVelocities(float4x4, float4x4, AnimationStream, AnimationStream, float, NativeArray<float3>)

public static void ComputeLocalToWorldAngularVelocities(float4x4 localToWorld, float4x4 previousLocalToWorld, ref AnimationStream input, ref AnimationStream previousInput, float deltaTime, NativeArray<float3> outAngularVelocities)

Parameters

localToWorld

The
LocalToWorld
matrix of the character at the time of
input
.

previousLocalToWorld

The
LocalToWorld
matrix of the character at the time of
previousInput
.

The stream for the current update.

previousInput

The stream for the previous update. It must use the same rig as
input
.

deltaTime

Time between the two streams, in seconds. It must be greater than zero.

outAngularVelocities

Receives the angular velocity of each bone, in radians per second. The length must be equal to the bone count of the rig.

Remarks

The world rotation of a bone is its
LocalToCharacter
rotation combined with the rotation of the
LocalToWorld
matrix. For each bone, the function computes the rotation that goes from the previous world rotation to the current one, and divides its angle by the elapsed time. The result points along the rotation axis, and its length is the speed in radians per second. The function uses the shortest rotation, so a bone that turns more than half a turn in one update gets a velocity in the opposite direction. The function ignores the translation and scale of the matrices.