Accord.Math.Matrix3x3.ExtractYawPitchRoll C# (CSharp) Method

ExtractYawPitchRoll() public method

Extract rotation angles from the rotation matrix.

The routine assumes roll-pitch-yaw rotation order when extracting rotation angle. Using extracted angles with the CreateFromYawPitchRoll should provide same rotation matrix.

The method assumes the provided matrix represent valid rotation matrix.

Sample usage:

// assume we have a rotation matrix created like this float yaw = 10.0f / 180 * Math.PI; float pitch = 30.0f / 180 * Math.PI; float roll = 45.0f / 180 * Math.PI; Matrix3x3 rotationMatrix = Matrix3x3.CreateFromYawPitchRoll( yaw, pitch, roll ); // ... // now somewhere in the code you may want to get rotation // angles back from a matrix assuming same rotation order float extractedYaw; float extractedPitch; float extractedRoll; rotation.ExtractYawPitchRoll( out extractedYaw, out extractedPitch, out extractedRoll );
public ExtractYawPitchRoll ( float &yaw, float &pitch, float &roll ) : void
yaw float Extracted rotation angle around Y axis in radians.
pitch float Extracted rotation angle around X axis in radians.
roll float Extracted rotation angle around Z axis in radians.
return void
        public void ExtractYawPitchRoll( out float yaw, out float pitch, out float roll )
        {
            yaw   = (float) Math.Atan2( V02, V22 );
            pitch = (float) Math.Asin( -V12 );
            roll  = (float) Math.Atan2( V10, V11 );
        }