Search in sources :

Example 16 with AffineTransformation

use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.

the class AffineTransformationFunctions method transformByBaseline.

public static Geometry transformByBaseline(final Geometry g, final Geometry destBaseline) {
    final BoundingBox env = g.getBoundingBox();
    final Point src0 = new PointDoubleXY(env.getMinX(), env.getMinY());
    final Point src1 = new PointDoubleXY(env.getMaxX(), env.getMinY());
    final Point[] destPts = CoordinatesListUtil.getPointArray(destBaseline);
    final Point dest0 = destPts[0];
    final Point dest1 = destPts[1];
    final AffineTransformation trans = AffineTransformationFactory.newFromBaseLines(src0, src1, dest0, dest1);
    return trans.transform(g);
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 17 with AffineTransformation

use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.

the class AffineTransformationFunctions method scale.

public static Geometry scale(final Geometry g, final double scale) {
    final Point centre = envelopeCentre(g);
    final AffineTransformation trans = AffineTransformation.scaleInstance(scale, scale, centre.getX(), centre.getY());
    return trans.transform(g);
}
Also used : AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point)

Example 18 with AffineTransformation

use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.

the class AffineTransformationFunctions method translateCentreToOrigin.

public static Geometry translateCentreToOrigin(final Geometry g) {
    final Point centre = envelopeCentre(g);
    final AffineTransformation trans = AffineTransformation.translationInstance(-centre.getX(), -centre.getY());
    return trans.transform(g);
}
Also used : AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point)

Example 19 with AffineTransformation

use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.

the class AffineTransformationFunctions method rotateByPiMultiple.

public static Geometry rotateByPiMultiple(final Geometry g, final double multipleOfPi) {
    final Point centre = envelopeCentre(g);
    final AffineTransformation trans = AffineTransformation.rotationInstance(multipleOfPi * Math.PI, centre.getX(), centre.getY());
    return trans.transform(g);
}
Also used : AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point)

Example 20 with AffineTransformation

use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.

the class AffineTransformationFunctions method transformByVectors.

public static Geometry transformByVectors(final Geometry g, final Geometry control) {
    final int nControl = control.getGeometryCount();
    final Point[] src = new Point[nControl];
    final Point[] dest = new Point[nControl];
    for (int i = 0; i < nControl; i++) {
        final Geometry contComp = control.getGeometry(i);
        final Point[] pts = CoordinatesListUtil.getPointArray(contComp);
        src[i] = pts[0];
        dest[i] = pts[1];
    }
    final AffineTransformation trans = AffineTransformationFactory.newFromControlVectors(src, dest);
    System.out.println(trans);
    return trans.transform(g);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point) Point(com.revolsys.geometry.model.Point)

Aggregations

AffineTransformation (com.revolsys.geometry.model.util.AffineTransformation)29 Point (com.revolsys.geometry.model.Point)13 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)4 AffineTransformationBuilder (com.revolsys.geometry.model.util.AffineTransformationBuilder)3 Geometry (com.revolsys.geometry.model.Geometry)2 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 NoninvertibleTransformationException (com.revolsys.geometry.model.util.NoninvertibleTransformationException)1