public void Identity_Dimension0_Exception() { int dimension = 0; Action act = () => Matrice2D.Identite(dimension); act.Should().Throw <ArgumentOutOfRangeException>(); }
public static Matrice2D Translation(float p_x, float p_y, float p_z) { Matrice2D transformation = new Matrice2D(new float [, ] { { 1.0f, 0.0f, 0.0f, p_x }, { 0.0f, 1.0f, 0.0f, p_y }, { 0.0f, 0.0f, 1.0f, p_z }, { 0.0f, 0.0f, 0.0f, 1.0f }, }); return(transformation); }
public static Matrice2D MiseALEchelle(float p_sx, float p_sy, float p_sz) { Matrice2D transformation = new Matrice2D(new float[, ] { { p_sx, 0.0f, 0.0f, 0.0f }, { 0.0f, p_sy, 0.0f, 0.0f }, { 0.0f, 0.0f, p_sz, 0.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, }); return(transformation); }
public void Identity_Dimension1_MatriceIdentite1Ligne1Colonne() { Matrice2D attendue = new Matrice2D(new float[, ] { { 1 }, }); int dimension = 1; Matrice2D identite = Matrice2D.Identite(dimension); identite.Should().Be(attendue); }
public void Identity_Dimension2_MatriceIdentite2Lignes2Colonnes() { Matrice2D attendue = new Matrice2D(new float[, ] { { 1, 0 }, { 0, 1 }, }); int dimension = 2; Matrice2D identite = Matrice2D.Identite(dimension); identite.Should().Be(attendue); }
public static Matrice2D RotationZ(float p_theta) { float costheta = (float)Math.Cos(p_theta); float sintheta = (float)Math.Sin(p_theta); Matrice2D transformation = new Matrice2D(new float[, ] { { costheta, -sintheta, 0.0f, 0.0f }, { sintheta, costheta, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, }); return(transformation); }
public void OperateurMultiplication_Cas23x32_Matrice22() { Matrice2D operande1 = new Matrice2D(new float[, ] { { 1, 2, 0 }, { 4, 3, -1 }, }); Matrice2D operande2 = new Matrice2D(new float[, ] { { 5, 1 }, { 2, 3 }, { 3, 4 }, }); Matrice2D resultatAttendu = new Matrice2D(new float[, ] { { 9, 7 }, { 23, 9 }, }); Matrice2D resultatCalcule = operande1 * operande2; resultatCalcule.Should().Be(resultatAttendu); }
public void OperateurMultiplication_Cas32x23_Matrice33() { Matrice2D operande1 = new Matrice2D(new float[, ] { { 5, 1 }, { 2, 3 }, { 3, 4 }, }); Matrice2D operande2 = new Matrice2D(new float[, ] { { 1, 2, 0 }, { 4, 3, -1 }, }); Matrice2D resultatAttendu = new Matrice2D(new float[, ] { { 9, 13, -1 }, { 14, 13, -3 }, { 19, 18, -4 }, }); Matrice2D resultatCalcule = operande1 * operande2; resultatCalcule.Should().Be(resultatAttendu); }
public static void DemoMatrices() { Console.Out.WriteLine(Matrices.Matrice2D.Identite(5) * (float)Math.PI * 100); Matrice2D operande1 = new Matrice2D(new float[, ] { { 5, 1 }, { 2, 3 }, { 3, 4 }, }); Matrice2D operande2 = new Matrice2D(new float[, ] { { 1, 2, 0 }, { 4, 3, -1 }, }); Matrice2D resultatAttendu = new Matrice2D(new float[, ] { { 9, 13, -1 }, { 14, 13, -3 }, { 19, 18, -4 }, }); Console.Out.WriteLine(operande1); Console.Out.WriteLine('*'); Console.Out.WriteLine(operande2); Console.Out.WriteLine('='); Console.Out.WriteLine(operande1 * operande2); Console.Out.WriteLine(); Console.Out.WriteLine(); Console.Out.WriteLine(operande2); Console.Out.WriteLine('*'); Console.Out.WriteLine(operande1); Console.Out.WriteLine('='); Console.Out.WriteLine(operande2 * operande1); }