BEPUutilities2.Matrix3x3.Invert C# (CSharp) Method

Invert() private method

private Invert ( Matrix3x3 &m, Matrix3x3 &inverse ) : void
m Matrix3x3
inverse Matrix3x3
return void
        public static void Invert(ref Matrix3x3 m, out Matrix3x3 inverse)
        {
            //Current implementation of cross far from optimal without shuffles, and even then this has some room for improvement.
            //Inverts should be really rare, so it's not too concerning. Use the scalar version when possible until ryujit improves (and we improve this implementation).
            Vector3 yz, zx, xy;
            Vector3x.Cross(ref m.Y, ref m.Z, out yz);
            Vector3x.Cross(ref m.Z, ref m.X, out zx);
            Vector3x.Cross(ref m.X, ref m.Y, out xy);
            var inverseDeterminant = 1f / Vector3.Dot(m.X, yz);
            inverse.X = yz * inverseDeterminant;
            inverse.Y = zx * inverseDeterminant;
            inverse.Z = xy * inverseDeterminant;
            Transpose(ref inverse, out inverse);
        }

Usage Example

Exemplo n.º 1
0
 public static void Invert(ref AffineTransform transform, out AffineTransform inverse)
 {
     Matrix3x3.Invert(ref transform.LinearTransform, out inverse.LinearTransform);
     Matrix3x3.Transform(ref transform.Translation, ref inverse.LinearTransform, out inverse.Translation);
     inverse.Translation = -inverse.Translation;
 }