@Override public final AffineTransform2D preConcatenate(final AffineGet affine) { assert affine.numSourceDimensions() >= 2 : "Only >=2d affine transformations can be pre-concatenated to a 2d affine transformation."; final double am00 = affine.get(0, 0); final double am01 = affine.get(0, 1); final double am02 = affine.get(0, 2); final double am10 = affine.get(1, 0); final double am11 = affine.get(1, 1); final double am12 = affine.get(1, 2); final double a00 = am00 * a.m00 + am01 * a.m10; final double a01 = am00 * a.m01 + am01 * a.m11; final double a02 = am00 * a.m02 + am01 * a.m12 + am02; final double a10 = am10 * a.m00 + am11 * a.m10; final double a11 = am10 * a.m01 + am11 * a.m11; final double a12 = am10 * a.m02 + am11 * a.m12 + am12; a.m00 = a00; a.m01 = a01; a.m02 = a02; a.m10 = a10; a.m11 = a11; a.m12 = a12; invert(); updateDs(); inverse.updateDs(); return this; }
/** * Translate * * @param t 2d translation vector */ public void translate(final double... t) { assert t.length == 2 : "2d affine transformations can be translated by 2d vector only."; a.m02 += t[0]; a.m12 += t[1]; invert(); updateDs(); inverse.updateDs(); }
protected AffineTransform2D(final AffineMatrix2D a) { this.a = a; d0 = new RealPoint(2); d1 = new RealPoint(2); ds = new RealPoint[] {d0, d1}; updateDs(); inverse = new AffineTransform2D(this); invert(); inverse.updateDs(); }
/** * Scale * * @param d scale factor */ public void scale(final double d) { a.m00 *= d; a.m01 *= d; a.m02 *= d; a.m10 *= d; a.m11 *= d; a.m12 *= d; invert(); updateDs(); inverse.updateDs(); }
@Override public void set(final double[][] values) { assert values.length >= 2 && values[0].length >= 3 && values[1].length == 3 : "Input dimensions do not match. A 2d affine matrix is a 2x3 matrix."; a.m00 = values[0][0]; a.m01 = values[0][1]; a.m02 = values[0][2]; a.m10 = values[1][0]; a.m11 = values[1][1]; a.m12 = values[1][2]; updateDs(); invert(); inverse.updateDs(); }
@Override public void set(final double... values) { assert values.length >= 6 : "Input dimensions do not match. A 2d affine matrix is a 2x3 matrix."; a.m00 = values[0]; a.m01 = values[1]; a.m02 = values[2]; a.m10 = values[3]; a.m11 = values[4]; a.m12 = values[5]; updateDs(); invert(); inverse.updateDs(); }
public final AffineTransform2D preConcatenate(final AffineTransform2D affine) { final double a00 = affine.a.m00 * a.m00 + affine.a.m01 * a.m10; final double a01 = affine.a.m00 * a.m01 + affine.a.m01 * a.m11; final double a02 = affine.a.m00 * a.m02 + affine.a.m01 * a.m12 + affine.a.m02; final double a10 = affine.a.m10 * a.m00 + affine.a.m11 * a.m10; final double a11 = affine.a.m10 * a.m01 + affine.a.m11 * a.m11; final double a12 = affine.a.m10 * a.m02 + affine.a.m11 * a.m12 + affine.a.m12; a.m00 = a00; a.m01 = a01; a.m02 = a02; a.m10 = a10; a.m11 = a11; a.m12 = a12; invert(); updateDs(); inverse.updateDs(); return this; }
public final AffineTransform2D concatenate(final AffineTransform2D model) { final double a00 = a.m00 * model.a.m00 + a.m01 * model.a.m10; final double a01 = a.m00 * model.a.m01 + a.m01 * model.a.m11; final double a02 = a.m00 * model.a.m02 + a.m01 * model.a.m12 + a.m02; final double a10 = a.m10 * model.a.m00 + a.m11 * model.a.m10; final double a11 = a.m10 * model.a.m01 + a.m11 * model.a.m11; final double a12 = a.m10 * model.a.m02 + a.m11 * model.a.m12 + a.m12; a.m00 = a00; a.m01 = a01; a.m02 = a02; a.m10 = a10; a.m11 = a11; a.m12 = a12; invert(); updateDs(); inverse.updateDs(); return this; }
@Override public void set(final double value, final int row, final int column) { assert row >= 0 && row < 2 && column >= 0 && column < 3 : "Index out of bounds, a 2d affine matrix is a 2x3 matrix."; switch (row) { case 0: switch (column) { case 0: a.m00 = value; break; case 1: a.m01 = value; break; default: a.m02 = value; } break; default: switch (column) { case 0: a.m10 = value; break; case 1: a.m11 = value; break; default: a.m12 = value; break; } } updateDs(); invert(); inverse.updateDs(); }