예제 #1
0
        public void TransformNormal()
        {
            // Random matrix
              Matrix44F transform = new Matrix44F(1, 2, 3, 4,
                                2, 5, 8, 3,
                                7, 6, -1, 1,
                                0, 0, 0, 1);

              Vector3F p3 = new Vector3F(1.0f, 2.0f, 0.5f);
              Vector3F x3 = new Vector3F(-3.4f, 5.5f, -0.5f);
              Vector3F d = (x3 - p3);
              Vector3F n3 = d.Orthonormal1;

              Vector4F p4 = new Vector4F(p3.X, p3.Y, p3.Z, 1.0f);
              Vector4F x4 = new Vector4F(x3.X, x3.Y, x3.Z, 1.0f);
              Vector4F n4 = new Vector4F(n3.X, n3.Y, n3.Z, 0.0f);
              float planeEquation = Vector4F.Dot((x4 - p4), n4);
              Assert.IsTrue(Numeric.IsZero(planeEquation));

              p4 = transform * p4;
              x4 = transform * x4;
              n3 = transform.TransformNormal(n3);
              n4 = new Vector4F(n3.X, n3.Y, n3.Z, 0.0f);
              planeEquation = Vector4F.Dot((x4 - p4), n4);
              Assert.IsTrue(Numeric.IsZero(planeEquation));
        }