Exemplo n.º 1
0
        public Matrix3d Orthonormalize()
        {
            Vector3d column    = this.GetColumn(0);
            Vector3d vector3d  = this.GetColumn(1) - Vector3d.Dot(this.GetColumn(1), column) / (column * column) * column;
            Vector3d vector3d2 = this.GetColumn(2) - Vector3d.Dot(this.GetColumn(2), column) / (column * column) * column - Vector3d.Dot(this.GetColumn(2), vector3d) / (vector3d * vector3d) * vector3d;
            Matrix3d matrix3d  = new Matrix3d();

            matrix3d.SetColumn(0, 1.0 / column.Norm * column);
            matrix3d.SetColumn(1, 1.0 / vector3d.Norm * vector3d);
            matrix3d.SetColumn(2, 1.0 / vector3d2.Norm * vector3d2);
            return(matrix3d);
        }
Exemplo n.º 2
0
        public Matrix3d Normalize()
        {
            Matrix3d matrix3d = new Matrix3d();
            Vector3d column   = this.GetColumn(0);
            Vector3d column2  = this.GetColumn(1);
            Vector3d column3  = this.GetColumn(2);
            double   norm     = column.Norm;
            double   norm2    = column2.Norm;
            double   norm3    = column3.Norm;

            if (norm < 4.94065645841247E-324 | norm2 < 4.94065645841247E-324 | norm3 < 4.94065645841247E-324)
            {
                throw new ArithmeticException("Matrix is not normalizable!");
            }
            matrix3d.SetColumn(0, 1.0 / norm * column);
            matrix3d.SetColumn(1, 1.0 / norm2 * column2);
            matrix3d.SetColumn(2, 1.0 / norm3 * column3);
            return(matrix3d);
        }