本文整理汇总了C#中Matrix4x4.GetDeterminant方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix4x4.GetDeterminant方法的具体用法?C# Matrix4x4.GetDeterminant怎么用?C# Matrix4x4.GetDeterminant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix4x4
的用法示例。
在下文中一共展示了Matrix4x4.GetDeterminant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Matrix4x4DeterminantTest1
public void Matrix4x4DeterminantTest1()
{
Matrix4x4 a = new Matrix4x4();
a.M11 = 5.0f; a.M12 = 2.0f; a.M13 = 8.25f; a.M14 = 1.0f;
a.M21 = 12.0f; a.M22 = 6.8f; a.M23 = 2.14f; a.M24 = 9.6f;
a.M31 = 6.5f; a.M32 = 1.0f; a.M33 = 3.14f; a.M34 = 2.22f;
a.M41 = 0f; a.M42 = 0.86f; a.M43 = 4.0f; a.M44 = 1.0f;
Matrix4x4 i;
Assert.IsTrue(Matrix4x4.Invert(a, out i));
float detA = a.GetDeterminant();
float detI = i.GetDeterminant();
float t = 1.0f / detI;
// only accurate to 3 precision
Assert.IsTrue(System.Math.Abs(detA - t) < 1e-3, "Matrix4x4.GetDeterminant was not set correctly.");
}
示例2: Matrix4x4InvertTest1
public void Matrix4x4InvertTest1()
{
Matrix4x4 a = new Matrix4x4();
a.M11 = 1.0f;
a.M12 = 2.0f;
a.M13 = 3.0f;
a.M14 = 4.0f;
a.M21 = 5.0f;
a.M22 = 6.0f;
a.M23 = 7.0f;
a.M24 = 8.0f;
a.M31 = 9.0f;
a.M32 = 10.0f;
a.M33 = 11.0f;
a.M34 = 12.0f;
a.M41 = 13.0f;
a.M42 = 14.0f;
a.M43 = 15.0f;
a.M44 = 16.0f;
float detA = a.GetDeterminant();
Assert.True(MathHelper.Equal(detA, 0.0f), "Matrix4x4.Invert did not return the expected value.");
Matrix4x4 actual;
Assert.False(Matrix4x4.Invert(a, out actual));
// all the elements in Actual is NaN
Assert.True(
float.IsNaN(actual.M11) && float.IsNaN(actual.M12) && float.IsNaN(actual.M13) && float.IsNaN(actual.M14) &&
float.IsNaN(actual.M21) && float.IsNaN(actual.M22) && float.IsNaN(actual.M23) && float.IsNaN(actual.M24) &&
float.IsNaN(actual.M31) && float.IsNaN(actual.M32) && float.IsNaN(actual.M33) && float.IsNaN(actual.M34) &&
float.IsNaN(actual.M41) && float.IsNaN(actual.M42) && float.IsNaN(actual.M43) && float.IsNaN(actual.M44)
, "Matrix4x4.Invert did not return the expected value.");
}