예제 #1
0
 public static MxMatrix3 operator *(MxMatrix3 mat1, double scalar)
 {
     var ret = new MxMatrix3(0.0);
     ret[0] = mat1[0]*scalar;
     ret[1] = mat1[1]*scalar;
     ret[2] = mat1[2]*scalar;
     return ret;
 }
예제 #2
0
        public static MxMatrix3 operator +(MxMatrix3 mat1, MxMatrix3 mat2)
        {
            var ret = new MxMatrix3(0.0);

            ret[0] = mat1[0] + mat2[0];
            ret[1] = mat1[1] + mat2[1];
            ret[2] = mat1[2] + mat2[2];
            return(ret);
        }
예제 #3
0
        public static MxMatrix3 operator -(MxMatrix3 mat1)
        {
            var ret = new MxMatrix3(0.0);

            ret[0] = -mat1[0];
            ret[1] = -mat1[1];
            ret[2] = -mat1[2];
            return(ret);
        }
예제 #4
0
        public static MxMatrix3 operator *(MxMatrix3 mat1, double scalar)
        {
            var ret = new MxMatrix3(0.0);

            ret[0] = mat1[0] * scalar;
            ret[1] = mat1[1] * scalar;
            ret[2] = mat1[2] * scalar;
            return(ret);
        }
예제 #5
0
        internal bool Optimize(ref MxVector3 vec)
        {
            var invMat = new MxMatrix3(0.0);
            var det    = MxMatrix3.Invert(Tensor, ref invMat);

            if (det.IsSqCloseEnoughTo(0.0))
            {
                return(false);
            }

            vec = -(invMat * Vector);
            return(true);
        }
예제 #6
0
        internal static MxMatrix3 OuterProduct(MxVector3 vec1, MxVector3 vec2)
        {
            var mat = new MxMatrix3(0.0);

            for (var i = 0; i < 3; i++)
            {
                for (var j = 0; j < 3; j++)
                {
                    mat[i, j] = vec1[i] * vec2[j];
                }
            }
            return(mat);
        }
예제 #7
0
        internal static double Invert(MxMatrix3 mat, ref MxMatrix3 inv)
        {
            var adj = Adjoint(mat);
            var det = adj[0] * mat[0];

            if (det.IsCloseEnoughTo(0.0))
            {
                return(0.0);
            }

            inv = (Transpose(adj) / det);
            return(det);
        }
예제 #8
0
        public static MxMatrix3 operator *(MxMatrix3 mat1, MxMatrix3 mat2)
        {
            var mat = new MxMatrix3(0.0);

            for (var i = 0; i < 3; i++)
            {
                for (var j = 0; j < 3; j++)
                {
                    mat[i, j] = mat1[i] * mat2.Column(j);
                }
            }
            return(mat);
        }
예제 #9
0
        public static MxMatrix3 operator /(MxMatrix3 mat1, double scalar)
        {
            if (scalar.IsCloseEnoughTo(0.0))
            {
                return(mat1);
            }
            var invScalar = 1.0 / scalar;

            var ret = new MxMatrix3(0.0);

            ret[0] = mat1[0] * invScalar;
            ret[1] = mat1[1] * invScalar;
            ret[2] = mat1[2] * invScalar;
            return(ret);
        }
예제 #10
0
        internal static MxMatrix3 OuterProduct(MxVector3 vec)
        {
            var mat = new MxMatrix3(0.0);
            var x   = vec[0];
            var y   = vec[1];
            var z   = vec[2];

            mat[0, 0] = x * x;
            mat[0, 1] = x * y;
            mat[0, 2] = x * z;
            mat[1, 0] = mat[0, 1];
            mat[1, 1] = y * y;
            mat[1, 2] = y * z;
            mat[2, 0] = mat[0, 2];
            mat[2, 1] = mat[1, 2];
            mat[2, 2] = z * z;

            return(mat);
        }
예제 #11
0
        public static MxMatrix3 operator /(MxMatrix3 mat1, double scalar)
        {
            if (scalar.IsCloseEnoughTo(0.0)) return mat1;
            var invScalar = 1.0/scalar;

            var ret = new MxMatrix3(0.0);
            ret[0] = mat1[0]*invScalar;
            ret[1] = mat1[1]*invScalar;
            ret[2] = mat1[2]*invScalar;
            return ret;
        }
예제 #12
0
 internal static MxMatrix3 Adjoint(MxMatrix3 mat)
 {
     return new MxMatrix3(mat[1] ^ mat[2],
                          mat[2] ^ mat[0],
                          mat[0] ^ mat[1]);
 }
예제 #13
0
 internal static double Det(MxMatrix3 mat)
 {
     return (mat[0]*(mat[1] ^ mat[2]));
 }
예제 #14
0
 internal static MxMatrix3 OuterProduct(MxVector3 vec1, MxVector3 vec2)
 {
     var mat = new MxMatrix3(0.0);
     for (var i = 0; i < 3; i++)
     {
         for (var j = 0; j < 3; j++)
         {
             mat[i, j] = vec1[i]*vec2[j];
         }
     }
     return mat;
 }
예제 #15
0
 internal static double Trace(MxMatrix3 mat)
 {
     return(mat[0, 0] + mat[1, 1] + mat[2, 2]);
 }
예제 #16
0
 public static MxMatrix3 operator -(MxMatrix3 mat1)
 {
     var ret = new MxMatrix3(0.0);
     ret[0] = -mat1[0];
     ret[1] = -mat1[1];
     ret[2] = -mat1[2];
     return ret;
 }
예제 #17
0
 public static MxMatrix3 operator *(MxMatrix3 mat1, MxMatrix3 mat2)
 {
     var mat = new MxMatrix3(0.0);
     for (var i = 0; i < 3; i++)
     {
         for (var j = 0; j < 3; j++)
         {
             mat[i, j] = mat1[i]*mat2.Column(j);
         }
     }
     return mat;
 }
예제 #18
0
        internal static double Invert(MxMatrix3 mat, ref MxMatrix3 inv)
        {
            var adj = Adjoint(mat);
            var det = adj[0]*mat[0];
            if (det.IsCloseEnoughTo(0.0)) return 0.0;

            inv = (Transpose(adj)/det);
            return det;
        }
예제 #19
0
 internal MxMatrix3(MxMatrix3 mat3)
 {
     rows[0] = new MxVector3((mat3[0])[0], (mat3[0])[1], (mat3[0])[2]);
     rows[1] = new MxVector3((mat3[1])[0], (mat3[1])[1], (mat3[1])[2]);
     rows[2] = new MxVector3((mat3[2])[0], (mat3[2])[1], (mat3[2])[2]);
 }
예제 #20
0
 internal static MxMatrix3 Transpose(MxMatrix3 mat)
 {
     return new MxMatrix3(mat.Column(0), mat.Column(1), mat.Column(2));
 }
예제 #21
0
 internal static double Trace(MxMatrix3 mat)
 {
     return (mat[0, 0] + mat[1, 1] + mat[2, 2]);
 }
예제 #22
0
 internal MxMatrix3(MxMatrix3 mat3)
 {
     rows[0] = new MxVector3((mat3[0])[0], (mat3[0])[1], (mat3[0])[2]);
     rows[1] = new MxVector3((mat3[1])[0], (mat3[1])[1], (mat3[1])[2]);
     rows[2] = new MxVector3((mat3[2])[0], (mat3[2])[1], (mat3[2])[2]);
 }
예제 #23
0
 internal static double Det(MxMatrix3 mat)
 {
     return(mat[0] * (mat[1] ^ mat[2]));
 }
예제 #24
0
 internal static MxMatrix3 Adjoint(MxMatrix3 mat)
 {
     return(new MxMatrix3(mat[1] ^ mat[2],
                          mat[2] ^ mat[0],
                          mat[0] ^ mat[1]));
 }
예제 #25
0
 internal static MxMatrix3 Transpose(MxMatrix3 mat)
 {
     return(new MxMatrix3(mat.Column(0), mat.Column(1), mat.Column(2)));
 }
예제 #26
0
        internal static MxMatrix3 OuterProduct(MxVector3 vec)
        {
            var mat = new MxMatrix3(0.0);
            var x = vec[0];
            var y = vec[1];
            var z = vec[2];

            mat[0, 0] = x*x;
            mat[0, 1] = x*y;
            mat[0, 2] = x*z;
            mat[1, 0] = mat[0, 1];
            mat[1, 1] = y*y;
            mat[1, 2] = y*z;
            mat[2, 0] = mat[0, 2];
            mat[2, 1] = mat[1, 2];
            mat[2, 2] = z*z;

            return mat;
        }
예제 #27
0
        internal bool Optimize(ref MxVector3 vec)
        {
            var invMat = new MxMatrix3(0.0);
            var det = MxMatrix3.Invert(Tensor, ref invMat);
            if (det.IsSqCloseEnoughTo(0.0)) return false;

            vec = -(invMat*Vector);
            return true;
        }
예제 #28
0
 public static MxMatrix3 operator +(MxMatrix3 mat1, MxMatrix3 mat2)
 {
     var ret = new MxMatrix3(0.0);
     ret[0] = mat1[0] + mat2[0];
     ret[1] = mat1[1] + mat2[1];
     ret[2] = mat1[2] + mat2[2];
     return ret;
 }