public void Perspective() { for (int i = 0; i < count; i++) { float a, b, c, d; a = UnityEngine.Random.Range(-10F, 10F); b = UnityEngine.Random.Range(-10F, 10F); c = UnityEngine.Random.Range(-10F, 10F); d = UnityEngine.Random.Range(-10F, 10F); Matrix4x4 value = Matrix4x4.Perspective(a, b, c, d); Matrix4x4d valued = Matrix4x4d.Perspective(a, b, c, d); Assert.True(Approximate(value, valued)); } }
// [Test] public void Planed_ProjectionFrustum() { Matrix4x4d projectionMatrix = Matrix4x4d.Perspective(90.0f, 1.0f, 1.0f, 10.0f); Matrix4x4d modelMatrix = Matrix4x4d.Identity; Matrix4x4d frustumMatrix = projectionMatrix * modelMatrix; Planed planeL = Planed.GetFrustumLeftPlane(frustumMatrix); Planed planeR = Planed.GetFrustumRightPlane(frustumMatrix); Planed planeB = Planed.GetFrustumBottomPlane(frustumMatrix); Planed planeT = Planed.GetFrustumTopPlane(frustumMatrix); Planed planeN = Planed.GetFrustumNearPlane(frustumMatrix); Assert.IsTrue(planeN.GetDistance(new Vertex3d(0.0f, 0.0f, -5.0f)) > 0.0f); Planed planeF = Planed.GetFrustumFarPlane(frustumMatrix); // Assert.IsTrue(planeF.GetDistance(new Vertex3d(0.0f, 0.0f, -5.0f)) > 0.0f); }