Exemple #1
0
 public static Matrix2D scaleM(double x, double y)
 {
     Matrix2D matrix = new Matrix2D();
     matrix.elements[0,0] = x;
     matrix.elements[1,1] = y;
     matrix.elements[2,2] = 1;
     return matrix;
 }
Exemple #2
0
 public static Matrix2D operator *(Matrix2D m1, Matrix2D m2)
 {
     Matrix2D matrix = new Matrix2D();
     for (int i = 0; i < 3; i++)
         for (int j = 0; j < 3; j++) {
             double sum = 0;
             for (int k = 0; k < 3; k++)
                 sum += m1.elements[k, j] * m2.elements[i, k];
             matrix.elements[i, j] = sum;
         }
     return matrix;
 }
Exemple #3
0
 public static Matrix2D identityM()
 {
     Matrix2D matrix = new Matrix2D();
     for (int i = 0; i < 3; i++)
         matrix.elements[i, i] = 1;
     return matrix;
 }
Exemple #4
0
 protected void transformVectors(Matrix2D matrix)
 {
     Random randGen = new Random();
     for (int j = 0; j < polygons.Count; j++) {
         ArrayList vertices = (ArrayList)polygons[j];
         for (int i = 0; i < vertices.Count; i++) {
             DoubleVector2 vertexOld = (DoubleVector2)vertices[i];
             vertices.RemoveAt(i);
             DoubleVector2 vertexNew = vertexOld * matrix;
             // add a little random jitter so as to remove the 'horizontal line' bug
             vertexNew.x += randGen.NextDouble() / 100000.0;
             vertexNew.y += randGen.NextDouble() / 100000.0;
             vertices.Insert(i, vertexNew);
         }
     }
     for (int i = 0; i < objects.Count; i++) {
         ElmaObject objectNow = (ElmaObject)objects[i];
         DoubleVector2 vertexOld = new DoubleVector2(objectNow.x, objectNow.y);
         objects.RemoveAt(i);
         DoubleVector2 vertexNew = vertexOld * matrix;
         objectNow.x = vertexNew.x;
         objectNow.y = vertexNew.y;
         objects.Insert(i, objectNow);
     }
     getMinMax();
 }