From d2adf76e6197524d2528678beb6fa259db63d397 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Sun, 24 Jul 2011 14:31:52 +0000 Subject: [PATCH] Unnecessary casts git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1150381 13f79535-47bb-0310-9956-ffa450edef68 --- .../euclidean/threed/PolyhedronsSet.java | 12 +++---- .../geometry/euclidean/threed/PlaneTest.java | 2 +- .../euclidean/threed/PolyhedronsSetTest.java | 4 +-- .../geometry/euclidean/twod/LineTest.java | 16 ++++----- .../euclidean/twod/PolygonsSetTest.java | 36 +++++++++---------- .../partitioning/utilities/AVLTreeTest.java | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSet.java b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSet.java index 947280120..0c15fc662 100644 --- a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSet.java +++ b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSet.java @@ -341,11 +341,11 @@ public class PolyhedronsSet extends AbstractRegion { final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; final Vector3D p00 = oPlane.getOrigin(); - final Vector3D p10 = (Vector3D) oPlane.toSpace(new Vector2D(1.0, 0.0)); - final Vector3D p01 = (Vector3D) oPlane.toSpace(new Vector2D(0.0, 1.0)); - final Vector2D tP00 = (Vector2D) tPlane.toSubSpace(apply(p00)); - final Vector2D tP10 = (Vector2D) tPlane.toSubSpace(apply(p10)); - final Vector2D tP01 = (Vector2D) tPlane.toSubSpace(apply(p01)); + final Vector3D p10 = oPlane.toSpace(new Vector2D(1.0, 0.0)); + final Vector3D p01 = oPlane.toSpace(new Vector2D(0.0, 1.0)); + final Vector2D tP00 = tPlane.toSubSpace(apply(p00)); + final Vector2D tP10 = tPlane.toSubSpace(apply(p10)); + final Vector2D tP01 = tPlane.toSubSpace(apply(p01)); final AffineTransform at = new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(), tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(), @@ -407,7 +407,7 @@ public class PolyhedronsSet extends AbstractRegion { final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; - final Vector2D shift = (Vector2D) tPlane.toSubSpace(apply(oPlane.getOrigin())); + final Vector2D shift = tPlane.toSubSpace(apply(oPlane.getOrigin())); final AffineTransform at = AffineTransform.getTranslateInstance(shift.getX(), shift.getY()); diff --git a/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PlaneTest.java b/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PlaneTest.java index e1ff38710..7a29eb049 100644 --- a/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PlaneTest.java +++ b/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PlaneTest.java @@ -130,7 +130,7 @@ public class PlaneTest { Vector3D p2 = new Vector3D (3.4, -5.8, 1.2); Plane pA = new Plane(p1, p2, new Vector3D (-2.0, 4.3, 0.7)); Plane pB = new Plane(p1, new Vector3D (11.4, -3.8, 5.1), p2); - Line l = (Line) pA.intersection(pB); + Line l = pA.intersection(pB); Assert.assertTrue(l.contains(p1)); Assert.assertTrue(l.contains(p2)); Assert.assertNull(pA.intersection(pA)); diff --git a/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSetTest.java b/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSetTest.java index fec1b602b..81fa93802 100644 --- a/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSetTest.java +++ b/src/test/java/org/apache/commons/math/geometry/euclidean/threed/PolyhedronsSetTest.java @@ -128,7 +128,7 @@ public class PolyhedronsSetTest { 1.0, c, 1.0, r.applyTo(barycenter.subtract(c))); Assert.assertEquals(0.0, - newB.subtract((Vector3D) tree.getBarycenter()).getNorm(), + newB.subtract(tree.getBarycenter()).getNorm(), 1.0e-10); final Vector3D[] expectedV = new Vector3D[] { @@ -172,7 +172,7 @@ public class PolyhedronsSetTest { ((PolygonsSet) facet.getRemainingRegion()).getVertices(); Assert.assertEquals(1, vertices.length); for (int i = 0; i < vertices[0].length; ++i) { - Vector3D v = (Vector3D) plane.toSpace(vertices[0][i]); + Vector3D v = plane.toSpace(vertices[0][i]); double d = Double.POSITIVE_INFINITY; for (int k = 0; k < expectedV.length; ++k) { d = FastMath.min(d, v.subtract(expectedV[k]).getNorm()); diff --git a/src/test/java/org/apache/commons/math/geometry/euclidean/twod/LineTest.java b/src/test/java/org/apache/commons/math/geometry/euclidean/twod/LineTest.java index 894a2ac4b..c4e6e655b 100644 --- a/src/test/java/org/apache/commons/math/geometry/euclidean/twod/LineTest.java +++ b/src/test/java/org/apache/commons/math/geometry/euclidean/twod/LineTest.java @@ -42,16 +42,16 @@ public class LineTest { public void testAbscissa() { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); Assert.assertEquals(0.0, - ((Vector1D) l.toSubSpace(new Vector2D(-3, 4))).getX(), + (l.toSubSpace(new Vector2D(-3, 4))).getX(), 1.0e-10); Assert.assertEquals(0.0, - ((Vector1D) l.toSubSpace(new Vector2D( 3, -4))).getX(), + (l.toSubSpace(new Vector2D( 3, -4))).getX(), 1.0e-10); Assert.assertEquals(-5.0, - ((Vector1D) l.toSubSpace(new Vector2D( 7, -1))).getX(), + (l.toSubSpace(new Vector2D( 7, -1))).getX(), 1.0e-10); Assert.assertEquals( 5.0, - ((Vector1D) l.toSubSpace(new Vector2D(-1, -7))).getX(), + (l.toSubSpace(new Vector2D(-1, -7))).getX(), 1.0e-10); } @@ -67,12 +67,12 @@ public class LineTest { Line l = new Line(new Vector2D(2, 1), new Vector2D(-2, -2)); for (double a = -2.0; a < 2.0; a += 0.2) { Vector1D pA = new Vector1D(a); - Vector2D point = (Vector2D) l.toSpace(pA); - Assert.assertEquals(a, ((Vector1D) l.toSubSpace(point)).getX(), 1.0e-10); + Vector2D point = l.toSpace(pA); + Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(0.0, l.getOffset(point), 1.0e-10); for (double o = -2.0; o < 2.0; o += 0.2) { point = l.getPointAt(pA, o); - Assert.assertEquals(a, ((Vector1D) l.toSubSpace(point)).getX(), 1.0e-10); + Assert.assertEquals(a, (l.toSubSpace(point)).getX(), 1.0e-10); Assert.assertEquals(o, l.getOffset(point), 1.0e-10); } } @@ -120,7 +120,7 @@ public class LineTest { public void testIntersection() { Line l1 = new Line(new Vector2D( 0, 1), new Vector2D(1, 2)); Line l2 = new Line(new Vector2D(-1, 2), new Vector2D(2, 1)); - Vector2D p = (Vector2D) l1.intersection(l2); + Vector2D p = l1.intersection(l2); Assert.assertEquals(0.5, p.getX(), 1.0e-10); Assert.assertEquals(1.5, p.getY(), 1.0e-10); } diff --git a/src/test/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSetTest.java b/src/test/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSetTest.java index 8bae8944d..b1a922441 100644 --- a/src/test/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSetTest.java +++ b/src/test/java/org/apache/commons/math/geometry/euclidean/twod/PolygonsSetTest.java @@ -232,18 +232,18 @@ public class PolygonsSetTest { SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane()); List i1 = ((IntervalsSet) s1.getRemainingRegion()).asList(); Assert.assertEquals(2, i1.size()); - Interval v10 = (Interval) i1.get(0); - Vector2D p10Lower = (Vector2D) l1.toSpace(new Vector1D(v10.getLower())); + Interval v10 = i1.get(0); + Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getLower())); Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10); Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10); - Vector2D p10Upper = (Vector2D) l1.toSpace(new Vector1D(v10.getUpper())); + Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getUpper())); Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10); - Interval v11 = (Interval) i1.get(1); - Vector2D p11Lower = (Vector2D) l1.toSpace(new Vector1D(v11.getLower())); + Interval v11 = i1.get(1); + Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getLower())); Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10); Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10); - Vector2D p11Upper = (Vector2D) l1.toSpace(new Vector1D(v11.getUpper())); + Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getUpper())); Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10); Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10); @@ -251,11 +251,11 @@ public class PolygonsSetTest { SubLine s2 = (SubLine) set.intersection(l2.wholeHyperplane()); List i2 = ((IntervalsSet) s2.getRemainingRegion()).asList(); Assert.assertEquals(1, i2.size()); - Interval v20 = (Interval) i2.get(0); - Vector2D p20Lower = (Vector2D) l2.toSpace(new Vector1D(v20.getLower())); + Interval v20 = i2.get(0); + Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getLower())); Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10); - Vector2D p20Upper = (Vector2D) l2.toSpace(new Vector1D(v20.getUpper())); + Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getUpper())); Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10); Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10); @@ -818,8 +818,8 @@ public class PolygonsSetTest { } private double intersectionAbscissa(Line l0, Line l1) { - Vector2D p = (Vector2D) l0.intersection(l1); - return ((Vector1D) l0.toSubSpace(p)).getX(); + Vector2D p = l0.intersection(l1); + return (l0.toSubSpace(p)).getX(); } private SubHyperplane buildHalfLine(Vector2D start, Vector2D end, @@ -827,17 +827,17 @@ public class PolygonsSetTest { Line line = new Line(start, end); double lower = startIsVirtual ? Double.NEGATIVE_INFINITY - : ((Vector1D) line.toSubSpace(start)).getX(); + : (line.toSubSpace(start)).getX(); double upper = startIsVirtual - ? ((Vector1D) line.toSubSpace(end)).getX() + ? (line.toSubSpace(end)).getX() : Double.POSITIVE_INFINITY; return new SubLine(line, new IntervalsSet(lower, upper)); } private SubHyperplane buildSegment(Vector2D start, Vector2D end) { Line line = new Line(start, end); - double lower = ((Vector1D) line.toSubSpace(start)).getX(); - double upper = ((Vector1D) line.toSubSpace(end)).getX(); + double lower = (line.toSubSpace(start)).getX(); + double upper = (line.toSubSpace(end)).getX(); return new SubLine(line, new IntervalsSet(lower, upper)); } @@ -853,9 +853,9 @@ public class PolygonsSetTest { double tolerance) { Line line = new Line(p1, p2); if (line.getOffset(p) < tolerance) { - double x = ((Vector1D) line.toSubSpace(p)).getX(); - double x1 = ((Vector1D) line.toSubSpace(p1)).getX(); - double x2 = ((Vector1D) line.toSubSpace(p2)).getX(); + double x = (line.toSubSpace(p)).getX(); + double x1 = (line.toSubSpace(p1)).getX(); + double x2 = (line.toSubSpace(p2)).getX(); return (((x - x1) * (x - x2) <= 0.0) || (p1.distance(p) < tolerance) || (p2.distance(p) < tolerance)); diff --git a/src/test/java/org/apache/commons/math/geometry/partitioning/utilities/AVLTreeTest.java b/src/test/java/org/apache/commons/math/geometry/partitioning/utilities/AVLTreeTest.java index e9cc570d3..59ab5c481 100644 --- a/src/test/java/org/apache/commons/math/geometry/partitioning/utilities/AVLTreeTest.java +++ b/src/test/java/org/apache/commons/math/geometry/partitioning/utilities/AVLTreeTest.java @@ -157,7 +157,7 @@ public class AVLTreeTest { } private int value(AVLTree.Node node) { - return ((Integer) node.getElement()).intValue(); + return node.getElement().intValue(); } private void checkOrder(AVLTree tree) {