Geometry rescaled; AffineTransformation geometryAT = new AffineTransformation( at.getScaleX(), at.getShearX(),
/** * Rotates a geometry by a given angle (in radians) about the specified * point at (x0, y0). * * @param geom Geometry * @param theta Angle * @param x0 x-coordinate of point about which to rotate * @param y0 y-coordinate of point about which to rotate * @return The geometry rotated by theta about (x0, y0) */ public static Geometry rotate(Geometry geom, double theta, double x0, double y0) { if (geom != null) { return AffineTransformation.rotationInstance(theta, x0, y0).transform(geom); } else { return null; } } }
/** * Creates a transformation for a scaling relative to the point (x,y). * * @param xScale the value to scale by in the x direction * @param yScale the value to scale by in the y direction * @param x the x-ordinate of the point to scale around * @param y the y-ordinate of the point to scale around * @return a transformation for the scaling */ public static AffineTransformation scaleInstance(double xScale, double yScale, double x, double y) { AffineTransformation trans = new AffineTransformation(); trans.translate(-x, -y); trans.scale(xScale, yScale); trans.translate(x, y); return trans; }
geometryAT = new AffineTransformation(1, 0, -sourceRegion.x, 0, 1, -sourceRegion.y); geometryAT.scale(xScale, yScale); LOGGER.fine( "Adapting overview's geometry to current image, using transformation: " + geometryAT.toString()); new AffineTransformation( at.getScaleX(), at.getShearX(),
/** * Creates a transformation for a scaling relative to the origin. * * @param xScale the value to scale by in the x direction * @param yScale the value to scale by in the y direction * @return a transformation for the scaling */ public static AffineTransformation scaleInstance(double xScale, double yScale) { AffineTransformation trans = new AffineTransformation(); trans.setToScale(xScale, yScale); return trans; }
/** * Creates a transformation for a shear. * * @param xShear the value to shear by in the x direction * @param yShear the value to shear by in the y direction * @return a transformation for the shear */ public static AffineTransformation shearInstance(double xShear, double yShear) { AffineTransformation trans = new AffineTransformation(); trans.setToShear(xShear, yShear); return trans; }
public void testTransform1() { AffineTransformation trans = new AffineTransformation(); trans.rotate(1); trans.translate(10, 10); trans.scale(2, 2); runTransform(trans, ctl0, ctl1, ctl2); }
final AffineTransformation t = new AffineTransformation(); final double xDiff = tileEnvelope.getWidth(); final double yDiff = tileEnvelope.getHeight(); t.translate(xOffset, yOffset); t.scale(1d / (xDiff / (double) mvtLayerParams.extent), -1d / (yDiff / (double) mvtLayerParams.extent)); t.translate(0d, (double) mvtLayerParams.extent); nextUserData = nextInterGeom.getUserData(); nextTransformGeom = t.transform(nextInterGeom);
/** * Creates a transformation for a translation. * * @param x the value to translate by in the x direction * @param y the value to translate by in the y direction * @return a transformation for the translation */ public static AffineTransformation translationInstance(double x, double y) { AffineTransformation trans = new AffineTransformation(); trans.setToTranslation(x, y); return trans; }
public static Geometry translateToOrigin(Geometry g) { Coordinate lowerLeft = envelopeLowerLeft(g); AffineTransformation trans = AffineTransformation.translationInstance(-lowerLeft.x, -lowerLeft.y); return trans.transform(g); } }
/** * Transforms the i'th coordinate in the input sequence * *@param seq a <code>CoordinateSequence</code> *@param i the index of the coordinate to transform */ public void filter(CoordinateSequence seq, int i) { transform(seq, i); }
public void testComposeRotation1() { AffineTransformation t0 = AffineTransformation.rotationInstance(1, 10, 10); AffineTransformation t1 = AffineTransformation.translationInstance(-10, -10); t1.rotate(1); t1.translate(10, 10); checkTransformation(t0, t1); }
setToTranslation(-x0, -y0); double sin = dy / d; double cos = dx / d; rotate(-sin, cos); scale(1, -1); rotate(sin, cos); translate(x0, y0); return this;
public static Geometry scale(Geometry g, double scale) { Coordinate centre = envelopeCentre(g); AffineTransformation trans = AffineTransformation.scaleInstance(scale, scale, centre.x, centre.y); return trans.transform(g); }
/** * Creates a transformation for a reflection about the * line (0,0) - (x,y). * * @param x the x-ordinate of a point on the reflection line * @param y the y-ordinate of a point on the reflection line * @return a transformation for the reflection */ public static AffineTransformation reflectionInstance(double x, double y) { AffineTransformation trans = new AffineTransformation(); trans.setToReflection(x, y); return trans; }
/** * Creates a transformation for a rotation * by an angle <i>theta</i>, * specified by the sine and cosine of the angle. * This allows providing exact values for sin(theta) and cos(theta) * for the common case of rotations of multiples of quarter-circles. * * @param sinTheta the sine of the rotation angle * @param cosTheta the cosine of the rotation angle * @return a transformation for the rotation */ public static AffineTransformation rotationInstance(double sinTheta, double cosTheta) { AffineTransformation trans = new AffineTransformation(); trans.setToRotation(sinTheta, cosTheta); return trans; }
public void testCompose1() { AffineTransformation t0 = AffineTransformation.translationInstance(10, 0); t0.rotate(Math.PI /2); t0.translate(0, -10); AffineTransformation t1 = AffineTransformation.translationInstance(0, 0); t1.rotate(Math.PI /2); checkTransformation(t0, t1); }
throws NoninvertibleTransformationException double det = getDeterminant(); if (det == 0) throw new NoninvertibleTransformationException("Transformation is non-invertible"); double im12 = (-m00 * m12 + m10 * m02) / det; return new AffineTransformation(im00, im01, im02, im10, im11, im12);
/** * Creates a transformation for a rotation * about the origin * by an angle <i>theta</i>. * Positive angles correspond to a rotation * in the counter-clockwise direction. * * @param theta the rotation angle, in radians * @return a transformation for the rotation */ public static AffineTransformation rotationInstance(double theta) { return rotationInstance(Math.sin(theta), Math.cos(theta)); }