Unnecessary casts

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1150381 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley 2011-07-24 14:31:52 +00:00
parent 69b7b985da
commit d2adf76e61
6 changed files with 36 additions and 36 deletions

View File

@ -341,11 +341,11 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
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<Euclidean3D, Euclidean2D> {
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());

View File

@ -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));

View File

@ -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());

View File

@ -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);
}

View File

@ -232,18 +232,18 @@ public class PolygonsSetTest {
SubLine s1 = (SubLine) set.intersection(l1.wholeHyperplane());
List<Interval> 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<Interval> 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<Euclidean2D> 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<Euclidean2D> 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));

View File

@ -157,7 +157,7 @@ public class AVLTreeTest {
}
private int value(AVLTree<Integer>.Node node) {
return ((Integer) node.getElement()).intValue();
return node.getElement().intValue();
}
private void checkOrder(AVLTree<Integer> tree) {