diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java index 9de30ce1e..da6ba93cc 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java @@ -16,7 +16,6 @@ */ package org.apache.commons.math4.geometry.euclidean.threed; -import java.awt.geom.AffineTransform; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -595,13 +594,15 @@ public class PolyhedronsSet extends AbstractRegion { final Vector2D tP00 = tPlane.toSubSpace((Point) apply(p00)); final Vector2D tP10 = tPlane.toSubSpace((Point) apply(p10)); final Vector2D tP01 = tPlane.toSubSpace((Point) apply(p01)); - final AffineTransform at = - new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), - tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), - tP00.getX(), tP00.getY()); cachedOriginal = (Plane) original; - cachedTransform = org.apache.commons.math4.geometry.euclidean.twod.Line.getTransform(at); + cachedTransform = + org.apache.commons.math4.geometry.euclidean.twod.Line.getTransform(tP10.getX() - tP00.getX(), + tP10.getY() - tP00.getY(), + tP01.getX() - tP00.getX(), + tP01.getY() - tP00.getY(), + tP00.getX(), + tP00.getY()); } return ((SubLine) sub).applyTransform(cachedTransform); @@ -660,12 +661,12 @@ public class PolyhedronsSet extends AbstractRegion { final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector2D shift = tPlane.toSubSpace((Point) apply(oPlane.getOrigin())); - final AffineTransform at = - AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); cachedOriginal = (Plane) original; cachedTransform = - org.apache.commons.math4.geometry.euclidean.twod.Line.getTransform(at); + org.apache.commons.math4.geometry.euclidean.twod.Line.getTransform(1, 0, 0, 1, + shift.getX(), + shift.getY()); } diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java index 3bfae8dd3..9f7d57872 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java @@ -16,8 +16,6 @@ */ package org.apache.commons.math4.geometry.euclidean.twod; -import java.awt.geom.AffineTransform; - import org.apache.commons.math4.exception.MathIllegalArgumentException; import org.apache.commons.math4.exception.util.LocalizedFormats; import org.apache.commons.math4.geometry.Point; @@ -422,20 +420,27 @@ public class Line implements Hyperplane, Embedding getTransform(final AffineTransform transform) + public static Transform getTransform(final double cXX, + final double cYX, + final double cXY, + final double cYY, + final double cX1, + final double cY1) throws MathIllegalArgumentException { - return new LineTransform(transform); + return new LineTransform(cXX, cYX, cXY, cYY, cX1, cY1); } /** Class embedding an affine transform. @@ -448,11 +453,22 @@ public class Line implements Hyperplane, Embedding { // CHECKSTYLE: stop JavadocVariable check + /** Transform factor between input abscissa and output abscissa. */ private final double cXX; - private final double cXY; - private final double cX1; + + /** Transform factor between input abscissa and output ordinate. */ private final double cYX; + + /** Transform factor between input ordinate and output abscissa. */ + private final double cXY; + + /** Transform factor between input ordinate and output ordinate. */ private final double cYY; + + /** Transform addendum for output abscissa. */ + private final double cX1; + + /** Transform addendum for output ordinate. */ private final double cY1; private final double c1Y; @@ -461,21 +477,25 @@ public class Line implements Hyperplane, Embedding t1 = - Line.getTransform(new AffineTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5)); + Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5); Assert.assertEquals(0.5 * FastMath.PI, ((Line) t1.apply(l1)).getAngle(), 1.0e-10); Line l2 = new Line(new Vector2D(0.0, 0.0), new Vector2D(1.0, 1.0), 1.0e-10); Transform t2 = - Line.getTransform(new AffineTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5)); + Line.getTransform(0.0, 0.5, -1.0, 0.0, 1.0, 1.5); Assert.assertEquals(FastMath.atan2(1.0, -2.0), ((Line) t2.apply(l2)).getAngle(), 1.0e-10);