コード例 #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);
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #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);
 }
コード例 #5
0
        public void Rotate(double thetaX, double thetaY, double thetaZ)
        {
            GraphicsMatrix rotationMatrix = GraphicsMatrix.GetRotationMatrix(thetaX, thetaY, thetaZ);

            this.Rotate(rotationMatrix);
        }
コード例 #6
0
 public void Rotate(GraphicsMatrix rotationMatrix)
 {
     rotationMatrix.Multiply(this);
 }