Search in sources :

Example 1 with NoninvertibleTransformationException

use of com.revolsys.geometry.model.util.NoninvertibleTransformationException 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) {
    }
}
Also used : NoninvertibleTransformationException(com.revolsys.geometry.model.util.NoninvertibleTransformationException) AffineTransformation(com.revolsys.geometry.model.util.AffineTransformation) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

Point (com.revolsys.geometry.model.Point)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 AffineTransformation (com.revolsys.geometry.model.util.AffineTransformation)1 NoninvertibleTransformationException (com.revolsys.geometry.model.util.NoninvertibleTransformationException)1