Ejemplo n.º 1
0
        // theta is in degrees
        public static GraphicsMatrix GetRotationMatrix(double thetaX, double thetaY, double thetaZ)
        {
            double         c    = Math.PI / 180;
            double         radX = c * thetaX;
            double         radY = c * thetaY;
            double         radZ = c * thetaZ;
            GraphicsMatrix x    = new GraphicsMatrix(new double[4, 4] {
                { 1, 0, 0, 0 },
                { 0, Math.Cos(radX), Math.Sin(radX), 0 },
                { 0, -1 * Math.Sin(radX), Math.Cos(radX), 0 },
                { 0, 0, 0, 1 }
            });

            GraphicsMatrix y = new GraphicsMatrix(new double [4, 4] {
                { Math.Cos(radY), 0, Math.Sin(radY), 0 },
                { 0, 1, 0, 0 },
                { -1 * Math.Sin(radY), 0, Math.Cos(radY), 0 },
                { 0, 0, 0, 1 }
            });

            GraphicsMatrix z = new GraphicsMatrix(new double[4, 4] {
                { Math.Cos(radZ), Math.Sin(radZ), 0, 0 },
                { -1 * Math.Sin(radZ), Math.Cos(radZ), 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 }
            });

            y.Multiply(x);
            z.Multiply(x);
            return(x);
        }
Ejemplo n.º 2
0
        /* static methods */
        public static GraphicsMatrix GetIdentity(int dimensions)
        {
            double[,] matrixOut = new double[dimensions, dimensions];
            int i;

            for (i = 0; i < dimensions; i++)
            {
                matrixOut[i, i] = 1;
            }
            GraphicsMatrix gmOut = new GraphicsMatrix(matrixOut);

            return(gmOut);
        }
Ejemplo n.º 3
0
        public void Multiply(GraphicsMatrix matrix)
        {
            // the product
            double[,] matrixOut = new double[4, matrix.Cols];
            int row, col, index;

            for (row = 0; row < 4; row++)
            {
                for (col = 0; col < matrix.Cols; col++)
                {
                    double sum = 0;
                    for (index = 0; index < this.Cols; index++)
                    {
                        sum += this.Matrix[row, index] * matrix.Matrix[index, col];
                    }
                    matrixOut[row, col] = sum;
                }
            }
            matrix.Matrix = matrixOut;
        }
Ejemplo n.º 4
0
 public void Rotate(double x, double y, double z, GraphicsMatrix rotationMatrix)
 {
     this.Translate(-x, -y, -z);
     this.Rotate(rotationMatrix);
     this.Translate(x, y, z);
 }
Ejemplo n.º 5
0
        public void Rotate(double thetaX, double thetaY, double thetaZ)
        {
            GraphicsMatrix rotationMatrix = GraphicsMatrix.GetRotationMatrix(thetaX, thetaY, thetaZ);

            this.Rotate(rotationMatrix);
        }
Ejemplo n.º 6
0
 public void Rotate(GraphicsMatrix rotationMatrix)
 {
     rotationMatrix.Multiply(this);
 }