private void RotateMatrix() { Matrix rotatedMatrix = modifiedVerticesMatrix.Duplicate(); for (int i = 0; i < listRotationDimension.Length; i++) { Matrix rotationMatrix = MatrixRotationND.Rotation(angle, dimension, listRotationDimension[i].x, listRotationDimension[i].y); rotatedMatrix = Matrix.StupidMultiply(rotatedMatrix, rotationMatrix); } rotatedVertices = new Vector3[rotatedMatrix.rows]; for (int i = 0; i < rotatedMatrix.rows; i++) { rotatedVertices[i] = dimensionReader.NDtoVector3(rotatedMatrix.GetRow(i)) * size; } }
protected Vector3[] RotateMatrix(float angle) { //Rotate the verticies matrix Matrix rotatedMatrix = modifiedVerticesMatrix.Duplicate(); for (int i = 0; i < listRotationDimension.Length; i++) { Matrix rotationMatrix = MatrixRotationND.Rotation(angle, dimension, listRotationDimension[i].x, listRotationDimension[i].y); rotatedMatrix = Matrix.StupidMultiply(rotatedMatrix, rotationMatrix); } Vector3[] rotatedVertices = new Vector3[rotatedMatrix.rows]; //Convert matrix to 3D coordinate for (int i = 0; i < rotatedMatrix.rows; i++) { rotatedVertices[i] = dimensionReader.NDtoVector3(rotatedMatrix.GetRow(i)) * size; } return(rotatedVertices); }
public Matrix RotatePartialMatrix(Matrix matrix) { //Concept /* On rotate une matrice par l'angle et les dimensions * Si on rotate par la 2ieme dimension, il y a 4 vertex * Donc on alterne en 4 vertex de la matrice orinal et de la rotated * * Si on rotate par la 3ième, il y a 8 vertex.. même chose * Si on rotate par la Nième dimension, il y a (2 ^ n) vertex */ Matrix partialRotatedMatrix = new Matrix(matrix.rows, matrix.cols); Matrix rotationMatrix = MatrixRotationND.Rotation(angle * Mathf.Deg2Rad, matrix.cols, rotationAroundDimension.x, rotationAroundDimension.y); Matrix fullyRotatedMatrix = Matrix.StupidMultiply(matrix, rotationMatrix); int twoPowerOfDimension = (int)Mathf.Pow(2, dimension); bool takeFromOriginal = true; int internalCounter = 0; for (int i = 0; i < matrix.rows; i++) { if (takeFromOriginal) { partialRotatedMatrix.SetRow(i, matrix.GetRow(i)); } else { partialRotatedMatrix.SetRow(i, fullyRotatedMatrix.GetRow(i)); } internalCounter++; if (internalCounter == twoPowerOfDimension) { internalCounter = 0; takeFromOriginal = !takeFromOriginal; } } return(partialRotatedMatrix); }