Beispiel #1
0
        static void Main(string[] args)
        {
            //Declare a 4x4 matrix
            Matrix44 <double> m44 = new Matrix44 <double>(6, -7, 10, 4, 0, 3, -1, 8, 0, 5, -7, 0, 1, 2, 7, 6);
            //Declare an identity matrix
            Matrix44 <double> id4 = Matrix44 <double> .Identity(1.0);

            Console.WriteLine(m44);
            Matrix44 <double> d = m44.Inverse(1.0);

            Console.WriteLine("\n" + d * m44);
            Console.WriteLine(m44 * id4 == m44); //True
            Console.WriteLine(id4 * m44 == m44); //True

            //Declare a 3x3 matrix
            Matrix33 <double> m33 = new Matrix33 <double>(6, -7, 10, 0, 3, -1, 0, 5, 2);

            Matrix33 <double> m33Inv = m33.Inverse(1.0);
            Matrix33 <double> c      = m33 * m33Inv;

            Console.WriteLine("\n" + c);                              //True

            Console.WriteLine(c == Matrix33 <double> .Identity(1.0)); //True
            Console.WriteLine(m44);                                   //True

            Console.ReadKey();
        }
        private static void OwnFunction()
        {
            Vector3 forw = new Vector3(0.5f, 0f, 0.5f).Normalize();

            PrintAngle(forw, 0);
            for (int i = 1; i < 10; i++)
            {
                Vector3 newForward = Matrix33.forYRotation(Math.PI / 4).TransformVector(forw);
                PrintAngle(newForward, i);
                forw = newForward;
            }
        }
 public static Matrix33 forYRotation(double radians)
 {
     Matrix33 matrix = new Matrix33();
     // ROW 1
     matrix.row1.x = (float)Math.Cos(radians);
     matrix.row1.y = 0f;
     matrix.row1.z = (float)Math.Sin(radians);
     // ROW 2
     matrix.row2.x = 0f;
     matrix.row2.y = 1f;
     matrix.row2.z = 0f;
     // ROW 3
     matrix.row3.x = -((float)Math.Sin(radians));
     matrix.row3.y = 0f;
     matrix.row3.z = (float)Math.Cos(radians);
     return matrix;
 }
        public static Matrix33 forYRotation(double radians)
        {
            Matrix33 matrix = new Matrix33();

            // ROW 1
            matrix.row1.x = (float)Math.Cos(radians);
            matrix.row1.y = 0f;
            matrix.row1.z = (float)Math.Sin(radians);
            // ROW 2
            matrix.row2.x = 0f;
            matrix.row2.y = 1f;
            matrix.row2.z = 0f;
            // ROW 3
            matrix.row3.x = -((float)Math.Sin(radians));
            matrix.row3.y = 0f;
            matrix.row3.z = (float)Math.Cos(radians);
            return(matrix);
        }