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

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

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

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