package myGraphics.VectorGrafix; import java.lang.Math; public class Transformation2d extends Matrix2d{ public Transformation2d() { super(); } public Transformation2d(Matrix2d M) { super(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { mterm[i][j] = M.mterm[i][j]; } } } public Transformation2d translate(double Ax, double Ay) { Matrix2d temp = new Matrix2d(); temp.set_term(0, 0, 1.0); temp.set_term(0, 2, Ax); temp.set_term(1, 1, 1.0); temp.set_term(1, 2, Ay); temp.set_term(2, 2, 1.0); return new Transformation2d(temp.multiply(this)); } public Transformation2d scale(double Sx, double Sy) { Matrix2d temp = new Matrix2d(); temp.set_term(0, 0, Sx); temp.set_term(1, 1, Sy); temp.set_term(2, 2, 1.0); return new Transformation2d(temp.multiply(this)); } public Transformation2d rotate(double Theta) { Matrix2d temp = new Matrix2d(); double theSin = Math.sin(Theta); double theCos = Math.cos(Theta); temp.set_term(0, 0, theCos); temp.set_term(0, 1, -theSin); temp.set_term(1, 0,theSin); temp.set_term(1, 1, theCos); return new Transformation2d(temp.multiply(this)); } public Vector2d apply(Vector2d v) { return this.multiply(v); } }