geometryAT = new AffineTransformation(1, 0, -sourceRegion.x, 0, 1, -sourceRegion.y); new AffineTransformation( at.getScaleX(), at.getShearX(),
AffineTransformation at = new AffineTransformation(); AffineTransformation at = new AffineTransformation();
Geometry rescaled; AffineTransformation geometryAT = new AffineTransformation( at.getScaleX(), at.getShearX(),
AffineTransformation at = new AffineTransformation();
/** * 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 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 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; }
/** * 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; }
/** * Computes the {@link AffineTransformation} * determined by the control point mappings, * or <code>null</code> if the control vectors do not determine a well-defined transformation. * * @return an affine transformation, or null if the control vectors do not determine a well-defined transformation */ public AffineTransformation getTransformation() { // compute full 3-point transformation boolean isSolvable = compute(); if (isSolvable) return new AffineTransformation(m00, m01, m02, m10, m11, m12); return null; }
/** * Creates a transformation for a reflection about the * line (x0,y0) - (x1,y1). * * @param x0 the x-ordinate of a point on the reflection line * @param y0 the y-ordinate of a point on the reflection line * @param x1 the x-ordinate of a another point on the reflection line * @param y1 the y-ordinate of a another point on the reflection line * @return a transformation for the reflection */ public static AffineTransformation reflectionInstance(double x0, double y0, double x1, double y1) { AffineTransformation trans = new AffineTransformation(); trans.setToReflection(x0, y0, x1, y1); 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; }
/** * Creates a transformation for a rotation * about the point (x,y) 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 * @param x the x-ordinate of the rotation point * @param y the y-ordinate of the rotation point * @return a transformation for the rotation */ public static AffineTransformation rotationInstance(double sinTheta, double cosTheta, double x, double y) { AffineTransformation trans = new AffineTransformation(); trans.setToRotation(sinTheta, cosTheta, x, y); return trans; }
final ListFeatureCollection featureCollection = new ListFeatureCollection(schema); final AffineTransformation jtsTransformation = new AffineTransformation( mt2D.getScaleX(), mt2D.getShearX(),
final ListFeatureCollection featureCollection = new ListFeatureCollection(featureType); final AffineTransformation jtsTransformation = new AffineTransformation( mt2D.getScaleX(), mt2D.getShearX(),
/** * 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; }
public void testTransform1() { AffineTransformation trans = new AffineTransformation(); trans.rotate(1); trans.translate(10, 10); trans.scale(2, 2); runTransform(trans, ctl0, ctl1, ctl2); }
public void testTransform2() { AffineTransformation trans = new AffineTransformation(); trans.rotate(3); trans.translate(10, 10); trans.scale(2, 10); trans.shear(5, 2); trans.reflect(5, 8, 10, 2); runTransform(trans, ctl0, ctl1, ctl2); }
@Test public void testUnionTransformedFractional() throws Exception { if (isOSX) { System.out.println("skipping testUnionTransformedFractional on OSX"); } else { final String geom1 = "POLYGON ((256.0156254550953 384.00000013906043, 384.00000082678343 384.00000013906043, 384.00000082678343 256.00000005685433, 256.0000004550675 256.00000005685433, 256.0000004550675 384.00000013906043, 256.0156254550953 384.00000013906043))"; final String geom2 = "POLYGON ((384.0156256825708 128.00000008217478, 512.0000010543083 128.00000008217478, 512.0000010543083 -0.0000000000291038, 384.00000068254303 -0.0000000000291038, 384.00000068254303 128.00000008217478, 384.0156256825708 128.00000008217478))"; final WKTReader wktReader = new WKTReader(); final Geometry geometry1 = wktReader.read(geom1); final Geometry geometry2 = wktReader.read(geom2); geometry1.apply(new AffineTransformation(1.1, 1.1, 0, 0, 1.1, 0)); geometry2.apply(new AffineTransformation(0, 1.1, 0, 1.1, 0, 0)); final ROIGeometry roiGeom1 = new ROIGeometry(geometry1); final ROIGeometry roiGeom2 = new ROIGeometry(geometry2); final ROI roiGeometryUnion = roiGeom1.add(roiGeom2); final ROIShape roiShape1 = getEquivalentROIShape(roiGeom1); final ROIShape roiShape2 = getEquivalentROIShape(roiGeom2); final ROI roiShapeUnion = roiShape1.add(roiShape2); assertROIEquivalent(roiGeometryUnion, roiShapeUnion, "Union"); } }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * * @return the new ROI */ @Override public ROI transform(AffineTransform at) { Geometry cloned = theGeom.getGeometry().copy(); cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY())); if (useFixedPrecision){ Geometry fixed = PRECISE_FACTORY.createGeometry(cloned); Coordinate[] coords = fixed.getCoordinates(); for (Coordinate coord : coords) { Coordinate precise = coord; PRECISION.makePrecise(precise); } cloned = fixed; } return buildROIGeometry(cloned); }
/** * Returns a new ROI created by applying the given transform to * this ROI. * * @param at the transform * * @return the new ROI */ @Override public ROI transform(AffineTransform at) { Geometry cloned = (Geometry) theGeom.getGeometry().clone(); cloned.apply(new AffineTransformation(at.getScaleX(), at.getShearX(), at.getTranslateX(), at.getShearY(), at.getScaleY(), at.getTranslateY())); if (useFixedPrecision){ Geometry fixed = PRECISE_FACTORY.createGeometry(cloned); Coordinate[] coords = fixed.getCoordinates(); for (Coordinate coord : coords) { Coordinate precise = coord; PRECISION.makePrecise(precise); } cloned = fixed; } return buildROIGeometry(cloned); }