use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.
the class AffineTransformationTest method testCompose2.
public void testCompose2() {
final AffineTransformation t0 = AffineTransformation.reflectionInstance(0, 0, 1, 0);
t0.reflect(0, 0, 0, -1);
final AffineTransformation t1 = AffineTransformation.rotationInstance(Math.PI);
checkTransformation(t0, t1);
}
use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.
the class AffineTransformationTest method testCompose3.
public void testCompose3() {
final AffineTransformation t0 = AffineTransformation.reflectionInstance(0, 10, 10, 0);
t0.translate(-10, -10);
final AffineTransformation t1 = AffineTransformation.reflectionInstance(0, 0, -1, 1);
checkTransformation(t0, t1);
}
use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.
the class AffineTransformationTest method checkTransformation.
/**
* Checks that a transformation produces the expected result
* @param x the input pt x
* @param y the input pt y
* @param trans the transformation
* @param xp the expected output x
* @param yp the expected output y
*/
void checkTransformation(final double x, final double y, final AffineTransformation trans, final double xp, final double yp) {
final Point p = new PointDoubleXY(x, y);
final Point p2 = trans.transform(p);
assertEquals(xp, p2.getX(), .00005);
assertEquals(yp, p2.getY(), .00005);
// if the transformation is invertible, test the inverse
try {
final AffineTransformation invTrans = trans.getInverse();
final Point pInv = invTrans.transform(p2);
assertEquals(x, pInv.getX(), .00005);
assertEquals(y, pInv.getY(), .00005);
final double det = trans.getDeterminant();
final double detInv = invTrans.getDeterminant();
assertEquals(det, 1.0 / detInv, .00005);
} catch (final NoninvertibleTransformationException ex) {
}
}
use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.
the class AffineTransformationTest method testReflectXYXY1.
public void testReflectXYXY1() throws IOException, ParseException {
final AffineTransformation t = AffineTransformation.reflectionInstance(0, 5, 5, 0);
checkTransformation(5, 0, t, 5, 0);
checkTransformation(0, 0, t, 5, 5);
checkTransformation(-10, -10, t, 15, 15);
}
use of com.revolsys.geometry.model.util.AffineTransformation in project com.revolsys.open by revolsys.
the class AffineTransformationTest method checkTransformation.
void checkTransformation(final String geomStr) throws IOException, ParseException, NoninvertibleTransformationException {
final Geometry geom = geometryFactory.geometry(geomStr);
final AffineTransformation trans = AffineTransformation.rotationInstance(Math.PI / 2);
final AffineTransformation inv = trans.getInverse();
final Geometry transGeom = trans.transform(geom);
final Geometry invGeom = inv.transform(transGeom);
// check if transformed geometry is equal to original
final boolean isEqual = geom.equalsExact(invGeom, 0.0005);
assertTrue(isEqual);
}
Aggregations