/// <summary> /// Effectue une rotation de la matrice. /// </summary> /// <param name="rotation">Rotation à effectuer.</param> public void Rotate(eRotation rotation) { switch (rotation) { case eRotation.Rotation90: Transpose(); Reflection(eDirection.Horizontal); break; case eRotation.Rotation180: float[] newData = new float[Rows * Columns]; for (int i = 0; i < Data.Length; i++) { newData[Data.Length - i - 1] = Data[i]; } Data = newData; break; case eRotation.Rotation270: Transpose(); Reflection(eDirection.Vertical); break; default: throw new Exception("This case of rotation isn't supported."); } }
/// <summary> /// Retourne une nouvelle matrice correspondant au résultat de la rotation de la matrice passée en paramètre. /// </summary> /// <param name="pMatrix">Matrice contenant les données qui doivent être pivotées.</param> /// <param name="rotation">Rotation à effectuer.</param> /// <returns>Matrice résultante de la rotation de la matrice passée en paramètre.</returns> public static Matrix Rotate(Matrix pMatrix, eRotation rotation) { Matrix result = pMatrix.Copy(); result.Rotate(rotation); return(result); }