This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push: new 1b0067787b Remove the `horizontal` boolean argument in `ShapeUtilities.parabolicControlPoint(…)`. It was never used. 1b0067787b is described below commit 1b0067787b1767eb856d6fcc2612cbaa7f223dcc Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Dec 22 11:19:55 2024 +0100 Remove the `horizontal` boolean argument in `ShapeUtilities.parabolicControlPoint(…)`. It was never used. --- .../transform/AbstractMathTransform2D.java | 31 +++--- .../transform/ConcatenatedTransform2D.java | 2 +- .../transform/ConcatenatedTransformDirect2D.java | 2 +- .../InterpolatedGeocentricTransform2D.java | 4 +- .../transform/InterpolatedTransform2D.java | 4 +- .../operation/transform/MolodenskyTransform2D.java | 2 +- .../transform/PassThroughTransform2D.java | 2 +- .../operation/transform/ProjectiveTransform2D.java | 2 +- .../transform/SpecializableTransform2D.java | 4 +- .../sis/referencing/privy/ShapeUtilities.java | 105 +++++++-------------- .../sis/referencing/privy/ShapeUtilitiesTest.java | 23 ++--- .../referencing/privy/ShapeUtilitiesViewer.java | 10 +- 12 files changed, 67 insertions(+), 124 deletions(-) diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java index c7958b6eb1..91ba0930dd 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java @@ -143,11 +143,11 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return isIdentity() ? shape : createTransformedShape(this, shape, null, null, false); + return isIdentity() ? shape : createTransformedShape(this, shape, null, null); } /** - * Transforms a geometric shape. This method always copy transformed coordinates in a new object. + * Transforms a geometric shape. This method always copies the transformed coordinates in a new object. * The new object is often a {@link Path2D}, but may also be a {@link Line2D} or a {@link QuadCurve2D} * if such simplification is possible. * @@ -157,15 +157,13 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl * transformation using {@code this}, or {@code null} if none. * @param postTransform an optional affine transform to apply <em>after</em> the transformation * using {@code this}, or {@code null} if none. - * @param horizontal {@code true} for forcing parabolic equation. * @return the transformed geometric shape. * @throws TransformException if a transformation failed. */ static Shape createTransformedShape(final MathTransform2D mt, final Shape shape, final AffineTransform preTransform, - final AffineTransform postTransform, - final boolean horizontal) + final AffineTransform postTransform) throws TransformException { final PathIterator it = shape.getPathIterator(preTransform); @@ -180,8 +178,8 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl } case PathIterator.SEG_CLOSE: { /* - * Close the geometric shape and continues the loop. We use the 'continue' instruction - * here instead of 'break' because we do not want to execute the code after the switch + * Close the geometric shape and continues the loop. We use the `continue` instruction + * here instead of `break` because we do not want to execute the code after the switch * (addition of transformed points into the path - there is no such point in a SEG_CLOSE). */ path.closePath(); @@ -189,8 +187,8 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl } case PathIterator.SEG_MOVETO: { /* - * Transform the single point and adds it to the path. We use the 'continue' instruction - * here instead of 'break' because we do not want to execute the code after the switch + * Transform the single point and adds it to the path. We use the `continue` instruction + * here instead of `break` because we do not want to execute the code after the switch * (addition of a line or a curve - there is no such curve to add here; we are just moving * the cursor). */ @@ -208,14 +206,14 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl } case PathIterator.SEG_LINETO: { /* - * Insert a new control point at 'buffer[0,1]'. This control point will + * Insert a new control point at `buffer[0,1]`. This control point will * be initialised with coordinates in the middle of the straight line: * * x = 0.5 * (x1+x2) * y = 0.5 * (y1+y2) * - * This point will be transformed after the 'switch', which is why we use - * the 'break' statement here instead of 'continue' as in previous case. + * This point will be transformed after the `switch`, which is why we use + * the `break` statement here instead of `continue` as in previous case. */ buffer[0] = 0.5 * (ax + (ax = buffer[0])); buffer[1] = 0.5 * (ay + (ay = buffer[1])); @@ -225,7 +223,7 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl } case PathIterator.SEG_QUADTO: { /* - * Replace the control point in 'buffer[0,1]' by a new control point lying on the quadratic curve. + * Replace the control point in `buffer[0,1]` by a new control point lying on the quadratic curve. * Coordinates for a point in the middle of the curve can be computed with: * * x = 0.5 * (ctrlx + 0.5 * (x1+x2)) @@ -239,7 +237,7 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl } case PathIterator.SEG_CUBICTO: { /* - * Replace the control point in 'buffer[0,1]' by a new control point lying on the cubic curve. + * Replace the control point in `buffer[0,1]` by a new control point lying on the cubic curve. * Coordinates for a point in the middle of the curve can be computed with: * * x = 0.25 * (1.5 * (ctrlx1 + ctrlx2) + 0.5 * (x1 + x2)); @@ -267,8 +265,7 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl mt.transform(buffer, 0, buffer, 0, DIMENSION); final Point2D ctrlPoint = ShapeUtilities.parabolicControlPoint(px, py, buffer[0], buffer[1], - buffer[2], buffer[3], - horizontal); + buffer[2], buffer[3]); px = buffer[2]; py = buffer[3]; if (Double.isFinite(px) && Double.isFinite(py)) { @@ -399,7 +396,7 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return isIdentity() ? shape : AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return isIdentity() ? shape : AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransform2D.java index 1cb8e68f0b..fb35671bc1 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransform2D.java @@ -82,7 +82,7 @@ final class ConcatenatedTransform2D extends ConcatenatedTransform implements Mat */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java index 781c26f90b..d9f8d0e282 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ConcatenatedTransformDirect2D.java @@ -76,7 +76,7 @@ final class ConcatenatedTransformDirect2D extends ConcatenatedTransformDirect im */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java index b35fd28b3d..ac4f52a918 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedGeocentricTransform2D.java @@ -66,7 +66,7 @@ final class InterpolatedGeocentricTransform2D extends InterpolatedGeocentricTran */ @Override public Shape createTransformedShape(Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** @@ -120,7 +120,7 @@ final class InterpolatedGeocentricTransform2D extends InterpolatedGeocentricTran */ @Override public Shape createTransformedShape(Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java index 8d095bd76c..94afb87c62 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/InterpolatedTransform2D.java @@ -65,7 +65,7 @@ final class InterpolatedTransform2D extends InterpolatedTransform implements Mat */ @Override public Shape createTransformedShape(Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** @@ -123,7 +123,7 @@ final class InterpolatedTransform2D extends InterpolatedTransform implements Mat */ @Override public Shape createTransformedShape(Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MolodenskyTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MolodenskyTransform2D.java index 3a6322d5a2..a88f8ddef2 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MolodenskyTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/MolodenskyTransform2D.java @@ -78,7 +78,7 @@ class MolodenskyTransform2D extends MolodenskyTransform implements MathTransform */ @Override public Shape createTransformedShape(Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform2D.java index 0b694fdf52..a5af4f995a 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/PassThroughTransform2D.java @@ -74,7 +74,7 @@ final class PassThroughTransform2D extends PassThroughTransform implements MathT */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java index bbdf5995ff..1421a323f2 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/ProjectiveTransform2D.java @@ -68,7 +68,7 @@ final class ProjectiveTransform2D extends ProjectiveTransform implements LinearT */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform2D.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform2D.java index beeeadf8e3..7ecab52371 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform2D.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/transform/SpecializableTransform2D.java @@ -58,7 +58,7 @@ final class SpecializableTransform2D extends SpecializableTransform implements M */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** @@ -114,7 +114,7 @@ final class SpecializableTransform2D extends SpecializableTransform implements M */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { - return AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false); + return AbstractMathTransform2D.createTransformedShape(this, shape, null, null); } /** diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ShapeUtilities.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ShapeUtilities.java index 3c801615ba..dba1a7a16d 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ShapeUtilities.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/privy/ShapeUtilities.java @@ -82,8 +82,8 @@ public final class ShapeUtilities extends Static { (by2 / bx2) * (x - bx1) + by1 : (ay2 / ax2) * (x - ax1) + ay1; /* - * The '!=0' expressions below are important for avoiding rounding errors with - * horizontal or vertical lines. The '!' are important for handling NaN values. + * The `!=0` expressions below are important for avoiding rounding errors with + * horizontal or vertical lines. The `!` are important for handling NaN values. */ if (ax2 != 0 && !(ax2 < 0 ? (x <= ax1 && x >= ax1 + ax2) : (x >= ax1 && x <= ax1 + ax2))) return null; if (bx2 != 0 && !(bx2 < 0 ? (x <= bx1 && x >= bx1 + bx2) : (x >= bx1 && x <= bx1 + bx2))) return null; @@ -238,17 +238,8 @@ public final class ShapeUtilities extends Static { /** * Returns a quadratic curve passing by the 3 given points. There is an infinity of quadratic curves passing by * 3 points. We can express the curve we are looking for as a parabolic equation of the form {@code y=ax²+bx+c} - * but where the <var>x</var> axis is not necessarily horizontal. The orientation of the <var>x</var> axis in - * the above equation is determined by the {@code horizontal} parameter: - * - * <ul> - * <li>A value of {@code true} means that the <var>x</var> axis must be horizontal. The quadratic curve - * will then looks like an ordinary parabolic curve as we see in mathematic school book.</li> - * <li>A value of {@code false} means that the <var>x</var> axis must be parallel to the - * line segment joining the {@code P0} and {@code P2} ending points.</li> - * </ul> - * - * Note that if {@code P0.y == P2.y}, then both {@code horizontal} values produce the same result. + * except that the <var>x</var> axis is not necessarily horizontal. The <var>x</var> axis in above equation is + * parallel to the line segment joining the {@code P0} and {@code P2} ending points. * * @param x1 <var>x</var> value of the starting point. * @param y1 <var>y</var> value of the starting point. @@ -256,9 +247,6 @@ public final class ShapeUtilities extends Static { * @param py <var>y</var> value of a passing point. * @param x2 <var>x</var> value of the ending point. * @param y2 <var>y</var> value of the ending point. - * @param horizontal if {@code true}, the <var>x</var> axis is considered horizontal while computing the - * {@code y=ax²+bx+c} equation terms. If {@code false}, it is considered parallel to the line - * joining the {@code P0} and {@code P2} points. * @return a quadratic curve passing by the given points. The curve starts at {@code P0} and ends at {@code P2}. * If two points are too close or if the three points are colinear, then this method returns {@code null}. * @@ -268,28 +256,17 @@ public final class ShapeUtilities extends Static { */ public static QuadCurve2D.Double fitParabol(final double x1, final double y1, final double px, final double py, - final double x2, final double y2, - final boolean horizontal) + final double x2, final double y2) { - final Point2D.Double p = parabolicControlPoint(x1, y1, px, py, x2, y2, horizontal); + final Point2D.Double p = parabolicControlPoint(x1, y1, px, py, x2, y2); return (p != null) ? new QuadCurve2D.Double(x1, y1, p.x, p.y, x2, y2) : null; } /** * Returns the control point of a quadratic curve passing by the 3 given points. There is an infinity of quadratic * curves passing by 3 points. We can express the curve we are looking for as a parabolic equation of the form - * {@code y = ax²+bx+c}, but the <var>x</var> axis is not necessarily horizontal. The <var>x</var> axis orientation - * in the above equation is determined by the {@code horizontal} parameter: - * - * <ul> - * <li>A value of {@code true} means that the <var>x</var> axis must be horizontal. - * The quadratic curve will then look like an ordinary parabolic curve as we see - * in mathematic school book.</li> - * <li>A value of {@code false} means that the <var>x</var> axis must be parallel to the - * line segment joining the {@code P0} and {@code P2} ending points.</li> - * </ul> - * - * Note that if {@code P0.y == P2.y}, then both {@code horizontal} values produce the same result. + * {@code y = ax²+bx+c}, except that the <var>x</var> axis is not necessarily horizontal. The <var>x</var> axis + * in above equation is parallel to the line segment joining the {@code P0} and {@code P2} ending points. * * @param x1 <var>x</var> value of the starting point. * @param y1 <var>y</var> value of the starting point. @@ -297,15 +274,12 @@ public final class ShapeUtilities extends Static { * @param py <var>y</var> value of a passing point. * @param x2 <var>x</var> value of the ending point. * @param y2 <var>y</var> value of the ending point. - * @param horizontal if {@code true}, the <var>x</var> axis is considered horizontal while computing the - * {@code y = ax²+bx+c} equation terms. If {@code false}, it is considered parallel to the line - * joining the {@code P0} and {@code P2} points. * @return the control point of a quadratic curve passing by the given points. The curve starts at {@code (x0,y0)} * and ends at {@code (x2,y2)}. If two points are too close or if the three points are colinear, then this * method returns {@code null}. */ public static Point2D.Double parabolicControlPoint(final double x1, final double y1, - double px, double py, double x2, double y2, final boolean horizontal) + double px, double py, double x2, double y2) { /* * Apply a translation in such a way that (x0,y0) become the coordinate system origin. @@ -315,42 +289,31 @@ public final class ShapeUtilities extends Static { py -= y1; x2 -= x1; y2 -= y1; - if (horizontal) { - final double a = (y2 - py*x2/px) / (x2-px); // Actually "a*x2" - final double check = abs(a); - if (!(check <= 1/EPS)) return null; // Two points have the same coordinates. - if (!(check >= EPS)) return null; // The three points are co-linear. - final double b = y2/x2 - a; - px = (1 + b/(2*a))*x2 - y2/(2*a); - py = y1 + b*px; - px += x1; - } else { - /* - * Apply a rotation in such a way that (x2,y2) - * lies on the x axis, i.e. y2 = 0. - */ - final double rx2 = x2; - final double ry2 = y2; - x2 = hypot(x2,y2); - y2 = (px*rx2 + py*ry2) / x2; // use 'y2' as a temporary variable for 'x1' - py = (py*rx2 - px*ry2) / x2; - px = y2; -// y2 = 0; // Could be set to that value, but not used. - /* - * Now compute the control point coordinates in our new coordinate system axis. - */ - final double x = 0.5; // Actually "x/x2" - final double y = (py*x*x2) / (px*(x2-px)); // Actually "y/y2" - final double check = abs(y); - if (!(check <= 1/EPS)) return null; // Two points have the same coordinates. - if (!(check >= EPS)) return null; // The three points are co-linear. - /* - * Applies the inverse rotation then a translation to bring - * us back to the original coordinate system. - */ - px = (x*rx2 - y*ry2) + x1; - py = (y*rx2 + x*ry2) + y1; - } + /* + * Apply a rotation in such a way that (x2,y2) + * lies on the x axis, i.e. y2 = 0. + */ + final double rx2 = x2; + final double ry2 = y2; + x2 = hypot(x2, y2); + y2 = (px*rx2 + py*ry2) / x2; // use `y2` as a temporary variable for `x1` + py = (py*rx2 - px*ry2) / x2; + px = y2; +// y2 = 0; // Could be set to that value, but not used. + /* + * Now compute the control point coordinates in our new coordinate system axis. + */ + final double x = 0.5; // Actually "x/x2" + final double y = (py*x*x2) / (px*(x2-px)); // Actually "y/y2" + final double check = abs(y); + if (!(check <= 1/EPS)) return null; // Two points have the same coordinates. + if (!(check >= EPS)) return null; // The three points are co-linear. + /* + * Applies the inverse rotation then a translation to bring + * us back to the original coordinate system. + */ + px = (x*rx2 - y*ry2) + x1; + py = (y*rx2 + x*ry2) + y1; return new Point2D.Double(px,py); } diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesTest.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesTest.java index b8e9e6d39b..e76a3203f9 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesTest.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesTest.java @@ -98,16 +98,15 @@ public final class ShapeUtilitiesTest extends TestCase { } /** - * Invokes {@code ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2, horizontal)}, + * Invokes {@code ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2)}, * then verifies that the control point of the returned curve is equal to {@code (cx, cy)}. */ private static void assertParabolEquals(final double cx, final double cy, final double x1, final double y1, final double px, final double py, - final double x2, final double y2, - final boolean horizontal) + final double x2, final double y2) { - final QuadCurve2D p = ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2, horizontal); + final QuadCurve2D p = ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2); assertPointEquals(x1, y1, p.getP1()); assertPointEquals(x2, y2, p.getP2()); assertPointEquals(cx, cy, p.getCtrlPt()); @@ -120,19 +119,9 @@ public final class ShapeUtilitiesTest extends TestCase { */ @Test public void testFitParabol() { - assertParabolEquals(203.09937404322247, 298.52149034018106, 188, 25, 367, 282, 477, 294, false); - assertParabolEquals(440.2165208525737, 147.92614458270768, 342, 193, 503, 182, 537, 196, false); - assertParabolEquals(688.8232271997849, 117.2311838864974, 488, 241, 578, 134, 455, 86, false); - } - - /** - * Tests {@link ShapeUtilities#fitParabol(double, double, double, double, double, double, boolean)} - * with a {@code true} boolean argument. - * This is an anti-regression test with values computed by {@link ShapeUtilitiesViewer}. - */ - @Test - public void testFitParabolHorizontal() { - assertParabolEquals(327.0, 272.41465201465195, 538, 197, 473, 213, 116, 43, true); + assertParabolEquals(203.09937404322247, 298.52149034018106, 188, 25, 367, 282, 477, 294); + assertParabolEquals(440.2165208525737, 147.92614458270768, 342, 193, 503, 182, 537, 196); + assertParabolEquals(688.8232271997849, 117.2311838864974, 488, 241, 578, 134, 455, 86); } /** diff --git a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesViewer.java b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesViewer.java index 3b1aac7115..141b1153de 100644 --- a/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesViewer.java +++ b/endorsed/src/org.apache.sis.referencing/test/org/apache/sis/referencing/privy/ShapeUtilitiesViewer.java @@ -51,7 +51,6 @@ public final class ShapeUtilitiesViewer extends JPanel { NEAREAST_COLINEAR_POINT, DISTANCED_COLINEAR_POINT, FIT_PARABOL, - FIT_PARABOL_HORIZONTAL, BEZIER, CIRCLE_CENTRE }; @@ -124,7 +123,6 @@ public final class ShapeUtilitiesViewer extends JPanel { output.reset(); fillInput = true; fillOutput = true; - boolean horizontal = false; final int x = getX(); final int y = getY(); final int width = getWidth(); @@ -164,16 +162,12 @@ public final class ShapeUtilitiesViewer extends JPanel { out.printf(Locale.ENGLISH, "colinearPoint(%d, %d, %d, %d, %d, %d, %g)%n", x1, y1, x2, y2, x3, y3, distance); break; } - case FIT_PARABOL_HORIZONTAL: { - horizontal = true; - // Fall through - } case FIT_PARABOL: { addPoint(input, x1, y1); addPoint(input, x2, y2); addPoint(input, x3, y3); - output.append(ShapeUtilities.fitParabol(x1, y1, x2, y2, x3, y3, horizontal), false); - out.printf(Locale.ENGLISH, "fitParabol(%d, %d, %d, %d, %d, %d, %b)%n", x1, y1, x2, y2, x3, y3, horizontal); + output.append(ShapeUtilities.fitParabol(x1, y1, x2, y2, x3, y3), false); + out.printf(Locale.ENGLISH, "fitParabol(%d, %d, %d, %d, %d, %d)%n", x1, y1, x2, y2, x3, y3); fillOutput = false; break; }