http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java index 2dc6933..be89ef4 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldRotation.java @@ -374,9 +374,9 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl public FieldRotation(final RotationOrder order, final RotationConvention convention, final T alpha1, final T alpha2, final T alpha3) { final T one = alpha1.getField().getOne(); - final FieldRotation<T> r1 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA1()), alpha1, convention); - final FieldRotation<T> r2 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA2()), alpha2, convention); - final FieldRotation<T> r3 = new FieldRotation<T>(new FieldVector3D<T>(one, order.getA3()), alpha3, convention); + final FieldRotation<T> r1 = new FieldRotation<>(new FieldVector3D<>(one, order.getA1()), alpha1, convention); + final FieldRotation<T> r2 = new FieldRotation<>(new FieldVector3D<>(one, order.getA2()), alpha2, convention); + final FieldRotation<T> r3 = new FieldRotation<>(new FieldVector3D<>(one, order.getA3()), alpha3, convention); final FieldRotation<T> composed = r1.compose(r2.compose(r3, convention), convention); q0 = composed.q0; q1 = composed.q1; @@ -453,7 +453,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * of the instance */ public FieldRotation<T> revert() { - return new FieldRotation<T>(q0.negate(), q1, q2, q3, false); + return new FieldRotation<>(q0.negate(), q1, q2, q3, false); } /** Get the scalar coordinate of the quaternion. @@ -509,17 +509,17 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T squaredSine = q1.multiply(q1).add(q2.multiply(q2)).add(q3.multiply(q3)); if (squaredSine.getReal() == 0) { final Field<T> field = squaredSine.getField(); - return new FieldVector3D<T>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), + return new FieldVector3D<>(convention == RotationConvention.VECTOR_OPERATOR ? field.getOne(): field.getOne().negate(), field.getZero(), field.getZero()); } else { final double sgn = convention == RotationConvention.VECTOR_OPERATOR ? +1 : -1; if (q0.getReal() < 0) { T inverse = squaredSine.sqrt().reciprocal().multiply(sgn); - return new FieldVector3D<T>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } final T inverse = squaredSine.sqrt().reciprocal().negate().multiply(sgn); - return new FieldVector3D<T>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); + return new FieldVector3D<>(q1.multiply(inverse), q2.multiply(inverse), q3.multiply(inverse)); } } @@ -1032,7 +1032,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl */ private FieldVector3D<T> vector(final double x, final double y, final double z) { final T zero = q0.getField().getZero(); - return new FieldVector3D<T>(zero.add(x), zero.add(y), zero.add(z)); + return new FieldVector3D<>(zero.add(x), zero.add(y), zero.add(z)); } /** Get the 3X3 matrix corresponding to the instance @@ -1090,7 +1090,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D<T>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(q0.multiply(x.multiply(q0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(y.multiply(q0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(z.multiply(q0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1108,7 +1108,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); - return new FieldVector3D<T>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(q0.multiply(q0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), q0.multiply(q0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), q0.multiply(q0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1165,7 +1165,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); - return new FieldVector3D<T>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D<>(x.multiply(r.getQ0()).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(r.getQ0()).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(r.getQ0()).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(r.getQ0()).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(r.getQ0()).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(r.getQ0()).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1184,7 +1184,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D<T>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(m0.multiply(x.multiply(m0).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(y.multiply(m0).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(z.multiply(m0).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1203,7 +1203,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = q1.multiply(x).add(q2.multiply(y)).add(q3.multiply(z)); final T m0 = q0.negate(); - return new FieldVector3D<T>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), + return new FieldVector3D<>(m0.multiply(m0.multiply(x).subtract(q2.multiply(z).subtract(q3.multiply(y)))).add(s.multiply(q1)).multiply(2).subtract(x), m0.multiply(m0.multiply(y).subtract(q3.multiply(x).subtract(q1.multiply(z)))).add(s.multiply(q2)).multiply(2).subtract(y), m0.multiply(m0.multiply(z).subtract(q1.multiply(y).subtract(q2.multiply(x)))).add(s.multiply(q3)).multiply(2).subtract(z)); @@ -1263,7 +1263,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl final T s = x.multiply(r.getQ1()).add(y.multiply(r.getQ2())).add(z.multiply(r.getQ3())); final double m0 = -r.getQ0(); - return new FieldVector3D<T>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), + return new FieldVector3D<>(x.multiply(m0).subtract(z.multiply(r.getQ2()).subtract(y.multiply(r.getQ3()))).multiply(m0).add(s.multiply(r.getQ1())).multiply(2).subtract(x), y.multiply(m0).subtract(x.multiply(r.getQ3()).subtract(z.multiply(r.getQ1()))).multiply(m0).add(s.multiply(r.getQ2())).multiply(2).subtract(y), z.multiply(m0).subtract(y.multiply(r.getQ1()).subtract(x.multiply(r.getQ2()))).multiply(m0).add(s.multiply(r.getQ3())).multiply(2).subtract(z)); @@ -1317,7 +1317,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * using vector operator convention */ private FieldRotation<T> composeInternal(final FieldRotation<T> r) { - return new FieldRotation<T>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), + return new FieldRotation<>(r.q0.multiply(q0).subtract(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))), r.q1.multiply(q0).add(r.q0.multiply(q1)).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))), r.q2.multiply(q0).add(r.q0.multiply(q2)).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))), r.q3.multiply(q0).add(r.q0.multiply(q3)).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))), @@ -1372,7 +1372,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * using vector operator convention */ private FieldRotation<T> composeInternal(final Rotation r) { - return new FieldRotation<T>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), + return new FieldRotation<>(q0.multiply(r.getQ0()).subtract(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))), q0.multiply(r.getQ1()).add(q1.multiply(r.getQ0())).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))), q0.multiply(r.getQ2()).add(q2.multiply(r.getQ0())).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))), q0.multiply(r.getQ3()).add(q3.multiply(r.getQ0())).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))), @@ -1391,7 +1391,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * @return a new rotation which is the composition of r by the instance */ public static <T extends RealFieldElement<T>> FieldRotation<T> applyTo(final Rotation r1, final FieldRotation<T> rInner) { - return new FieldRotation<T>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), + return new FieldRotation<>(rInner.q0.multiply(r1.getQ0()).subtract(rInner.q1.multiply(r1.getQ1()).add(rInner.q2.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ3()))), rInner.q1.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ1())).add(rInner.q2.multiply(r1.getQ3()).subtract(rInner.q3.multiply(r1.getQ2()))), rInner.q2.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ2())).add(rInner.q3.multiply(r1.getQ1()).subtract(rInner.q1.multiply(r1.getQ3()))), rInner.q3.multiply(r1.getQ0()).add(rInner.q0.multiply(r1.getQ3())).add(rInner.q1.multiply(r1.getQ2()).subtract(rInner.q2.multiply(r1.getQ1()))), @@ -1450,7 +1450,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * of the instance using vector operator convention */ private FieldRotation<T> composeInverseInternal(FieldRotation<T> r) { - return new FieldRotation<T>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), + return new FieldRotation<>(r.q0.multiply(q0).add(r.q1.multiply(q1).add(r.q2.multiply(q2)).add(r.q3.multiply(q3))).negate(), r.q0.multiply(q1).add(r.q2.multiply(q3).subtract(r.q3.multiply(q2))).subtract(r.q1.multiply(q0)), r.q0.multiply(q2).add(r.q3.multiply(q1).subtract(r.q1.multiply(q3))).subtract(r.q2.multiply(q0)), r.q0.multiply(q3).add(r.q1.multiply(q2).subtract(r.q2.multiply(q1))).subtract(r.q3.multiply(q0)), @@ -1509,7 +1509,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * of the instance using vector operator convention */ private FieldRotation<T> composeInverseInternal(Rotation r) { - return new FieldRotation<T>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), + return new FieldRotation<>(q0.multiply(r.getQ0()).add(q1.multiply(r.getQ1()).add(q2.multiply(r.getQ2())).add(q3.multiply(r.getQ3()))).negate(), q1.multiply(r.getQ0()).add(q3.multiply(r.getQ2()).subtract(q2.multiply(r.getQ3()))).subtract(q0.multiply(r.getQ1())), q2.multiply(r.getQ0()).add(q1.multiply(r.getQ3()).subtract(q3.multiply(r.getQ1()))).subtract(q0.multiply(r.getQ2())), q3.multiply(r.getQ0()).add(q2.multiply(r.getQ1()).subtract(q1.multiply(r.getQ2()))).subtract(q0.multiply(r.getQ3())), @@ -1530,7 +1530,7 @@ public class FieldRotation<T extends RealFieldElement<T>> implements Serializabl * of the instance */ public static <T extends RealFieldElement<T>> FieldRotation<T> applyInverseTo(final Rotation rOuter, final FieldRotation<T> rInner) { - return new FieldRotation<T>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), + return new FieldRotation<>(rInner.q0.multiply(rOuter.getQ0()).add(rInner.q1.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ2())).add(rInner.q3.multiply(rOuter.getQ3()))).negate(), rInner.q0.multiply(rOuter.getQ1()).add(rInner.q2.multiply(rOuter.getQ3()).subtract(rInner.q3.multiply(rOuter.getQ2()))).subtract(rInner.q1.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ2()).add(rInner.q3.multiply(rOuter.getQ1()).subtract(rInner.q1.multiply(rOuter.getQ3()))).subtract(rInner.q2.multiply(rOuter.getQ0())), rInner.q0.multiply(rOuter.getQ3()).add(rInner.q1.multiply(rOuter.getQ2()).subtract(rInner.q2.multiply(rOuter.getQ1()))).subtract(rInner.q3.multiply(rOuter.getQ0())),
http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java index f03a1ec..bec2d74 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/FieldVector3D.java @@ -408,7 +408,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final FieldVector3D<T> v) { - return new FieldVector3D<T>(x.add(v.x), y.add(v.y), z.add(v.z)); + return new FieldVector3D<>(x.add(v.x), y.add(v.y), z.add(v.z)); } /** Add a vector to the instance. @@ -416,7 +416,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final Vector3D v) { - return new FieldVector3D<T>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); + return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); } /** Add a scaled vector to the instance. @@ -425,7 +425,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final T factor, final FieldVector3D<T> v) { - return new FieldVector3D<T>(x.getField().getOne(), this, factor, v); + return new FieldVector3D<>(x.getField().getOne(), this, factor, v); } /** Add a scaled vector to the instance. @@ -434,7 +434,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final T factor, final Vector3D v) { - return new FieldVector3D<T>(x.add(factor.multiply(v.getX())), + return new FieldVector3D<>(x.add(factor.multiply(v.getX())), y.add(factor.multiply(v.getY())), z.add(factor.multiply(v.getZ()))); } @@ -445,7 +445,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final double factor, final FieldVector3D<T> v) { - return new FieldVector3D<T>(1.0, this, factor, v); + return new FieldVector3D<>(1.0, this, factor, v); } /** Add a scaled vector to the instance. @@ -454,7 +454,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> add(final double factor, final Vector3D v) { - return new FieldVector3D<T>(x.add(factor * v.getX()), + return new FieldVector3D<>(x.add(factor * v.getX()), y.add(factor * v.getY()), z.add(factor * v.getZ())); } @@ -464,7 +464,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final FieldVector3D<T> v) { - return new FieldVector3D<T>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); + return new FieldVector3D<>(x.subtract(v.x), y.subtract(v.y), z.subtract(v.z)); } /** Subtract a vector from the instance. @@ -472,7 +472,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final Vector3D v) { - return new FieldVector3D<T>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); + return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); } /** Subtract a scaled vector from the instance. @@ -481,7 +481,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final T factor, final FieldVector3D<T> v) { - return new FieldVector3D<T>(x.getField().getOne(), this, factor.negate(), v); + return new FieldVector3D<>(x.getField().getOne(), this, factor.negate(), v); } /** Subtract a scaled vector from the instance. @@ -490,7 +490,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final T factor, final Vector3D v) { - return new FieldVector3D<T>(x.subtract(factor.multiply(v.getX())), + return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())), y.subtract(factor.multiply(v.getY())), z.subtract(factor.multiply(v.getZ()))); } @@ -501,7 +501,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final double factor, final FieldVector3D<T> v) { - return new FieldVector3D<T>(1.0, this, -factor, v); + return new FieldVector3D<>(1.0, this, -factor, v); } /** Subtract a scaled vector from the instance. @@ -510,7 +510,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> subtract(final double factor, final Vector3D v) { - return new FieldVector3D<T>(x.subtract(factor * v.getX()), + return new FieldVector3D<>(x.subtract(factor * v.getX()), y.subtract(factor * v.getY()), z.subtract(factor * v.getZ())); } @@ -551,13 +551,13 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl if (FastMath.abs(x.getReal()) <= threshold) { final T inverse = y.multiply(y).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D<T>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); + return new FieldVector3D<>(inverse.getField().getZero(), inverse.multiply(z), inverse.multiply(y).negate()); } else if (FastMath.abs(y.getReal()) <= threshold) { final T inverse = x.multiply(x).add(z.multiply(z)).sqrt().reciprocal(); - return new FieldVector3D<T>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); + return new FieldVector3D<>(inverse.multiply(z).negate(), inverse.getField().getZero(), inverse.multiply(x)); } else { final T inverse = x.multiply(x).add(y.multiply(y)).sqrt().reciprocal(); - return new FieldVector3D<T>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); + return new FieldVector3D<>(inverse.multiply(y), inverse.multiply(x).negate(), inverse.getField().getZero()); } } @@ -655,7 +655,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector which is opposite to the instance */ public FieldVector3D<T> negate() { - return new FieldVector3D<T>(x.negate(), y.negate(), z.negate()); + return new FieldVector3D<>(x.negate(), y.negate(), z.negate()); } /** Multiply the instance by a scalar. @@ -663,7 +663,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> scalarMultiply(final T a) { - return new FieldVector3D<T>(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); } /** Multiply the instance by a scalar. @@ -671,7 +671,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return a new vector */ public FieldVector3D<T> scalarMultiply(final double a) { - return new FieldVector3D<T>(x.multiply(a), y.multiply(a), z.multiply(a)); + return new FieldVector3D<>(x.multiply(a), y.multiply(a), z.multiply(a)); } /** @@ -779,7 +779,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D<T> crossProduct(final FieldVector3D<T> v) { - return new FieldVector3D<T>(x.linearCombination(y, v.z, z.negate(), v.y), + return new FieldVector3D<>(x.linearCombination(y, v.z, z.negate(), v.y), y.linearCombination(z, v.x, x.negate(), v.z), z.linearCombination(x, v.y, y.negate(), v.x)); } @@ -789,7 +789,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the cross product this ^ v as a new Vector3D */ public FieldVector3D<T> crossProduct(final Vector3D v) { - return new FieldVector3D<T>(x.linearCombination(v.getZ(), y, -v.getY(), z), + return new FieldVector3D<>(x.linearCombination(v.getZ(), y, -v.getY(), z), y.linearCombination(v.getX(), z, -v.getZ(), x), z.linearCombination(v.getY(), x, -v.getX(), y)); } @@ -993,7 +993,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl */ public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1, final FieldVector3D<T> v2) { - return new FieldVector3D<T>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), + return new FieldVector3D<>(v2.x.linearCombination(v1.getY(), v2.z, -v1.getZ(), v2.y), v2.y.linearCombination(v1.getZ(), v2.x, -v1.getX(), v2.z), v2.z.linearCombination(v1.getX(), v2.y, -v1.getY(), v2.x)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java index a501813..67abdd1 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/OutlineExtractor.java @@ -203,7 +203,7 @@ public class OutlineExtractor { } // compute the projection of the facet in the outline plane - final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<SubHyperplane<Euclidean2D>>(); + final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>(); for (Vector2D[] loop : vertices) { final boolean closed = loop[0] != null; int previous = closed ? (loop.length - 1) : 1; http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/PolyhedronsSet.java ---------------------------------------------------------------------- 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 095d6d5..b99c9c2 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 @@ -162,7 +162,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { final double tolerance) { if ((xMin >= xMax - tolerance) || (yMin >= yMax - tolerance) || (zMin >= zMax - tolerance)) { // too thin box, build an empty polygons set - return new BSPTree<Euclidean3D>(Boolean.FALSE); + return new BSPTree<>(Boolean.FALSE); } final Plane pxMin = new Plane(new Vector3D(xMin, 0, 0), Vector3D.MINUS_I, tolerance); final Plane pxMax = new Plane(new Vector3D(xMax, 0, 0), Vector3D.PLUS_I, tolerance); @@ -226,7 +226,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { } } - final List<SubHyperplane<Euclidean3D>> boundary = new ArrayList<SubHyperplane<Euclidean3D>>(); + final List<SubHyperplane<Euclidean3D>> boundary = new ArrayList<>(); for (final int[] facet : facets) { http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java index f28a762..deef1e9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SphereGenerator.java @@ -37,15 +37,15 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector public EnclosingBall<Euclidean3D, Vector3D> ballOnSupport(final List<Vector3D> support) { if (support.size() < 1) { - return new EnclosingBall<Euclidean3D, Vector3D>(Vector3D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall<>(Vector3D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector3D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall<Euclidean3D, Vector3D>(vA, 0, vA); + return new EnclosingBall<>(vA, 0, vA); } else { final Vector3D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall<Euclidean3D, Vector3D>(new Vector3D(0.5, vA, 0.5, vB), + return new EnclosingBall<>(new Vector3D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -61,7 +61,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector p.toSubSpace(vC))); // convert back to 3D - return new EnclosingBall<Euclidean3D, Vector3D>(p.toSpace(disk.getCenter()), + return new EnclosingBall<>(p.toSpace(disk.getCenter()), disk.getRadius(), vA, vB, vC); } else { @@ -118,7 +118,7 @@ public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector final BigFraction dy = c3[0].subtract(centerY); final BigFraction dz = c4[0].subtract(centerZ); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)).add(dz.multiply(dz)); - return new EnclosingBall<Euclidean3D, Vector3D>(new Vector3D(centerX.doubleValue(), + return new EnclosingBall<>(new Vector3D(centerX.doubleValue(), centerY.doubleValue(), centerZ.doubleValue()), FastMath.sqrt(r2.doubleValue()), http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java index ae3dc4a..61499d9 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubLine.java @@ -85,7 +85,7 @@ public class SubLine { public List<Segment> getSegments() { final List<Interval> list = remainingRegion.asList(); - final List<Segment> segments = new ArrayList<Segment>(list.size()); + final List<Segment> segments = new ArrayList<>(list.size()); for (final Interval interval : list) { final Vector3D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java index 89885d4..0c89584 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/SubPlane.java @@ -67,11 +67,11 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> { // the hyperplanes are parallel final double global = otherPlane.getOffset(thisPlane); if (global < -tolerance) { - return new SplitSubHyperplane<Euclidean3D>(null, this); + return new SplitSubHyperplane<>(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane<Euclidean3D>(this, null); + return new SplitSubHyperplane<>(this, null); } else { - return new SplitSubHyperplane<Euclidean3D>(null, null); + return new SplitSubHyperplane<>(null, null); } } @@ -92,15 +92,15 @@ public class SubPlane extends AbstractSubHyperplane<Euclidean3D, Euclidean2D> { final BSPTree<Euclidean2D> splitTree = getRemainingRegion().getTree(false).split(l2DMinus); final BSPTree<Euclidean2D> plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree<Euclidean2D>(Boolean.FALSE) : - new BSPTree<Euclidean2D>(l2DPlus, new BSPTree<Euclidean2D>(Boolean.FALSE), + new BSPTree<>(l2DPlus, new BSPTree<Euclidean2D>(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree<Euclidean2D> minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree<Euclidean2D>(Boolean.FALSE) : - new BSPTree<Euclidean2D>(l2DMinus, new BSPTree<Euclidean2D>(Boolean.FALSE), + new BSPTree<>(l2DMinus, new BSPTree<Euclidean2D>(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane<Euclidean3D>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), + return new SplitSubHyperplane<>(new SubPlane(thisPlane.copySelf(), new PolygonsSet(plusTree, tolerance)), new SubPlane(thisPlane.copySelf(), new PolygonsSet(minusTree, tolerance))); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java index 4cc3546..a19a876 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/DiskGenerator.java @@ -33,15 +33,15 @@ public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D public EnclosingBall<Euclidean2D, Vector2D> ballOnSupport(final List<Vector2D> support) { if (support.size() < 1) { - return new EnclosingBall<Euclidean2D, Vector2D>(Vector2D.ZERO, Double.NEGATIVE_INFINITY); + return new EnclosingBall<>(Vector2D.ZERO, Double.NEGATIVE_INFINITY); } else { final Vector2D vA = support.get(0); if (support.size() < 2) { - return new EnclosingBall<Euclidean2D, Vector2D>(vA, 0, vA); + return new EnclosingBall<>(vA, 0, vA); } else { final Vector2D vB = support.get(1); if (support.size() < 3) { - return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(0.5, vA, 0.5, vB), + return new EnclosingBall<>(new Vector2D(0.5, vA, 0.5, vB), 0.5 * vA.distance(vB), vA, vB); } else { @@ -86,7 +86,7 @@ public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D final BigFraction dx = c2[0].subtract(centerX); final BigFraction dy = c3[0].subtract(centerY); final BigFraction r2 = dx.multiply(dx).add(dy.multiply(dy)); - return new EnclosingBall<Euclidean2D, Vector2D>(new Vector2D(centerX.doubleValue(), + return new EnclosingBall<>(new Vector2D(centerX.doubleValue(), centerY.doubleValue()), FastMath.sqrt(r2.doubleValue()), vA, vB, vC); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java index cb3a2be..a967fb6 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java @@ -71,7 +71,7 @@ class NestedLoops { * @since 3.3 */ NestedLoops(final double tolerance) { - this.surrounded = new ArrayList<NestedLoops>(); + this.surrounded = new ArrayList<>(); this.tolerance = tolerance; } @@ -90,11 +90,11 @@ class NestedLoops { } this.loop = loop; - this.surrounded = new ArrayList<NestedLoops>(); + this.surrounded = new ArrayList<>(); this.tolerance = tolerance; // build the polygon defined by the loop - final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<SubHyperplane<Euclidean2D>>(); + final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>(); Vector2D current = loop[loop.length - 1]; for (int i = 0; i < loop.length; ++i) { final Vector2D previous = current; @@ -152,7 +152,7 @@ class NestedLoops { } // we should be separate from the remaining children - RegionFactory<Euclidean2D> factory = new RegionFactory<Euclidean2D>(); + RegionFactory<Euclidean2D> factory = new RegionFactory<>(); for (final NestedLoops child : surrounded) { if (!factory.intersection(node.polygon, child.polygon).isEmpty()) { throw new MathIllegalArgumentException(LocalizedFormats.CROSSING_BOUNDARY_LOOPS); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java index 6dcf2cd..38b94f4 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java @@ -199,7 +199,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { final int n = vertices.length; if (n == 0) { // the tree represents the whole space - return new BSPTree<Euclidean2D>(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } // build the vertices @@ -209,7 +209,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { } // build the edges - List<Edge> edges = new ArrayList<Edge>(n); + List<Edge> edges = new ArrayList<>(n); for (int i = 0; i < n; ++i) { // get the endpoints of the edge @@ -238,7 +238,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { } // build the tree top-down - final BSPTree<Euclidean2D> tree = new BSPTree<Euclidean2D>(); + final BSPTree<Euclidean2D> tree = new BSPTree<>(); insertEdges(hyperplaneThickness, tree, edges); return tree; @@ -287,8 +287,8 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { // we have split the node by inserting an edge as a cut sub-hyperplane // distribute the remaining edges in the two sub-trees - final List<Edge> plusList = new ArrayList<Edge>(); - final List<Edge> minusList = new ArrayList<Edge>(); + final List<Edge> plusList = new ArrayList<>(); + final List<Edge> minusList = new ArrayList<>(); for (final Edge edge : edges) { if (edge != inserted) { final double startOffset = inserted.getLine().getOffset((Point<Euclidean2D>) edge.getStart().getLocation()); @@ -365,7 +365,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { this.location = location; this.incoming = null; this.outgoing = null; - this.lines = new ArrayList<Line>(); + this.lines = new ArrayList<>(); } /** Get Vertex location. @@ -640,7 +640,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { } // create the segment loops - final ArrayList<List<Segment>> loops = new ArrayList<List<Segment>>(); + final ArrayList<List<Segment>> loops = new ArrayList<>(); for (ConnectableSegment s = getUnprocessed(segments); s != null; s = getUnprocessed(segments)) { final List<Segment> loop = followLoop(s); if (loop != null) { @@ -824,7 +824,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { */ private List<Segment> followLoop(final ConnectableSegment defining) { - final List<Segment> loop = new ArrayList<Segment>(); + final List<Segment> loop = new ArrayList<>(); loop.add(defining); defining.setProcessed(true); @@ -998,7 +998,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> { */ SegmentsBuilder(final double tolerance) { this.tolerance = tolerance; - this.segments = new ArrayList<ConnectableSegment>(); + this.segments = new ArrayList<>(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java index 4f53e6c..eb24760 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java @@ -83,7 +83,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> { final Line line = (Line) getHyperplane(); final List<Interval> list = ((IntervalsSet) getRemainingRegion()).asList(); - final List<Segment> segments = new ArrayList<Segment>(list.size()); + final List<Segment> segments = new ArrayList<>(list.size()); for (final Interval interval : list) { final Vector2D start = line.toSpace((Point<Euclidean1D>) new Vector1D(interval.getInf())); @@ -168,11 +168,11 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> { // the lines are parallel final double global = otherLine.getOffset(thisLine); if (global < -tolerance) { - return new SplitSubHyperplane<Euclidean2D>(null, this); + return new SplitSubHyperplane<>(null, this); } else if (global > tolerance) { - return new SplitSubHyperplane<Euclidean2D>(this, null); + return new SplitSubHyperplane<>(this, null); } else { - return new SplitSubHyperplane<Euclidean2D>(null, null); + return new SplitSubHyperplane<>(null, null); } } @@ -187,13 +187,13 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> { final BSPTree<Euclidean1D> splitTree = getRemainingRegion().getTree(false).split(subMinus); final BSPTree<Euclidean1D> plusTree = getRemainingRegion().isEmpty(splitTree.getPlus()) ? new BSPTree<Euclidean1D>(Boolean.FALSE) : - new BSPTree<Euclidean1D>(subPlus, new BSPTree<Euclidean1D>(Boolean.FALSE), + new BSPTree<>(subPlus, new BSPTree<Euclidean1D>(Boolean.FALSE), splitTree.getPlus(), null); final BSPTree<Euclidean1D> minusTree = getRemainingRegion().isEmpty(splitTree.getMinus()) ? new BSPTree<Euclidean1D>(Boolean.FALSE) : - new BSPTree<Euclidean1D>(subMinus, new BSPTree<Euclidean1D>(Boolean.FALSE), + new BSPTree<>(subMinus, new BSPTree<Euclidean1D>(Boolean.FALSE), splitTree.getMinus(), null); - return new SplitSubHyperplane<Euclidean2D>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), + return new SplitSubHyperplane<>(new SubLine(thisLine.copySelf(), new IntervalsSet(plusTree, tolerance)), new SubLine(thisLine.copySelf(), new IntervalsSet(minusTree, tolerance))); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java index 2388db0..84be4ac 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java @@ -84,7 +84,7 @@ public final class AklToussaintHeuristic { return points; } - final List<Vector2D> reducedPoints = new ArrayList<Vector2D>(quadrilateral); + final List<Vector2D> reducedPoints = new ArrayList<>(quadrilateral); for (final Vector2D p : points) { // check all points if they are within the quadrilateral // in which case they can not be part of the convex hull @@ -103,7 +103,7 @@ public final class AklToussaintHeuristic { * @return the quadrilateral */ private static List<Vector2D> buildQuadrilateral(final Vector2D... points) { - List<Vector2D> quadrilateral = new ArrayList<Vector2D>(); + List<Vector2D> quadrilateral = new ArrayList<>(); for (Vector2D p : points) { if (!quadrilateral.contains(p)) { quadrilateral.add(p); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java index b973e13..7356da1 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java @@ -163,7 +163,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Vector2D>, Serializ if (vertices.length < 3) { throw new InsufficientDataException(); } - final RegionFactory<Euclidean2D> factory = new RegionFactory<Euclidean2D>(); + final RegionFactory<Euclidean2D> factory = new RegionFactory<>(); final Segment[] segments = retrieveLineSegments(); final Line[] lineArray = new Line[segments.length]; for (int i = 0; i < segments.length; i++) { http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java index 39caa99..5746c7f 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java @@ -77,7 +77,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D { @Override public Collection<Vector2D> findHullVertices(final Collection<Vector2D> points) { - final List<Vector2D> pointsSortedByXAxis = new ArrayList<Vector2D>(points); + final List<Vector2D> pointsSortedByXAxis = new ArrayList<>(points); // sort the points in increasing order on the x-axis Collections.sort(pointsSortedByXAxis, new Comparator<Vector2D>() { @@ -97,13 +97,13 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D { }); // build lower hull - final List<Vector2D> lowerHull = new ArrayList<Vector2D>(); + final List<Vector2D> lowerHull = new ArrayList<>(); for (Vector2D p : pointsSortedByXAxis) { updateHull(p, lowerHull); } // build upper hull - final List<Vector2D> upperHull = new ArrayList<Vector2D>(); + final List<Vector2D> upperHull = new ArrayList<>(); for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) { final Vector2D p = pointsSortedByXAxis.get(idx); updateHull(p, upperHull); @@ -111,7 +111,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D { // concatenate the lower and upper hulls // the last point of each list is omitted as it is repeated at the beginning of the other list - final List<Vector2D> hullVertices = new ArrayList<Vector2D>(lowerHull.size() + upperHull.size() - 2); + final List<Vector2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2); for (int idx = 0; idx < lowerHull.size() - 1; idx++) { hullVertices.add(lowerHull.get(idx)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java index 57d2c64..9463bb8 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractRegion.java @@ -53,7 +53,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement * @param tolerance tolerance below which points are considered identical. */ protected AbstractRegion(final double tolerance) { - this.tree = new BSPTree<S>(Boolean.TRUE); + this.tree = new BSPTree<>(Boolean.TRUE); this.tolerance = tolerance; } @@ -102,14 +102,14 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement if (boundary.size() == 0) { // the tree represents the whole space - tree = new BSPTree<S>(Boolean.TRUE); + tree = new BSPTree<>(Boolean.TRUE); } else { // sort the boundary elements in decreasing size order // (we don't want equal size elements to be removed, so // we use a trick to fool the TreeSet) - final TreeSet<SubHyperplane<S>> ordered = new TreeSet<SubHyperplane<S>>(new Comparator<SubHyperplane<S>>() { + final TreeSet<SubHyperplane<S>> ordered = new TreeSet<>(new Comparator<SubHyperplane<S>>() { /** {@inheritDoc} */ @Override public int compare(final SubHyperplane<S> o1, final SubHyperplane<S> o2) { @@ -121,7 +121,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement ordered.addAll(boundary); // build the tree top-down - tree = new BSPTree<S>(); + tree = new BSPTree<>(); insertCuts(tree, ordered); // set up the inside/outside flags @@ -161,7 +161,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement public AbstractRegion(final Hyperplane<S>[] hyperplanes, final double tolerance) { this.tolerance = tolerance; if ((hyperplanes == null) || (hyperplanes.length == 0)) { - tree = new BSPTree<S>(Boolean.FALSE); + tree = new BSPTree<>(Boolean.FALSE); } else { // use the first hyperplane to build the right class @@ -218,8 +218,8 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement } // distribute the remaining edges in the two sub-trees - final ArrayList<SubHyperplane<S>> plusList = new ArrayList<SubHyperplane<S>>(); - final ArrayList<SubHyperplane<S>> minusList = new ArrayList<SubHyperplane<S>>(); + final ArrayList<SubHyperplane<S>> plusList = new ArrayList<>(); + final ArrayList<SubHyperplane<S>> minusList = new ArrayList<>(); while (iterator.hasNext()) { final SubHyperplane<S> other = iterator.next(); final SubHyperplane.SplitSubHyperplane<S> split = other.split(inserted); @@ -310,7 +310,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement */ @Override public BoundaryProjection<S> projectToBoundary(final Point<S> point) { - final BoundaryProjector<S, T> projector = new BoundaryProjector<S, T>(point); + final BoundaryProjector<S, T> projector = new BoundaryProjector<>(point); getTree(true).visit(projector); return projector.getProjection(); } @@ -376,7 +376,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement /** {@inheritDoc} */ @Override public double getBoundarySize() { - final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<S>(); + final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<>(); getTree(true).visit(visitor); return visitor.getSize(); } @@ -485,7 +485,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement public AbstractRegion<S, T> applyTransform(final Transform<S, T> transform) { // transform the tree, except for boundary attribute splitters - final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<BSPTree<S>, BSPTree<S>>(); + final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<>(); final BSPTree<S> transformedTree = recurseTransform(getTree(false), transform, map); // set up the boundary attributes splitters @@ -519,7 +519,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement final BSPTree<S> transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<S>(node.getAttribute()); + transformedNode = new BSPTree<>(node.getAttribute()); } else { final SubHyperplane<S> sub = node.getCut(); @@ -531,10 +531,10 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement final SubHyperplane<S> tPI = (attribute.getPlusInside() == null) ? null : ((AbstractSubHyperplane<S, T>) attribute.getPlusInside()).applyTransform(transform); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<S>(tPO, tPI, new NodesSet<S>()); + attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet<S>()); } - transformedNode = new BSPTree<S>(tSub, + transformedNode = new BSPTree<>(tSub, recurseTransform(node.getPlus(), transform, map), recurseTransform(node.getMinus(), transform, map), attribute); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java index 76c925c..275269e 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/AbstractSubHyperplane.java @@ -116,7 +116,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space> final Hyperplane<S> tHyperplane = transform.apply(hyperplane); // transform the tree, except for boundary attribute splitters - final Map<BSPTree<T>, BSPTree<T>> map = new HashMap<BSPTree<T>, BSPTree<T>>(); + final Map<BSPTree<T>, BSPTree<T>> map = new HashMap<>(); final BSPTree<T> tTree = recurseTransform(remainingRegion.getTree(false), tHyperplane, transform, map); @@ -153,7 +153,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space> final BSPTree<T> transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<T>(node.getAttribute()); + transformedNode = new BSPTree<>(node.getAttribute()); } else { @SuppressWarnings("unchecked") @@ -164,10 +164,10 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space> final SubHyperplane<T> tPI = (attribute.getPlusInside() == null) ? null : transform.apply(attribute.getPlusInside(), hyperplane, transformed); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<T>(tPO, tPI, new NodesSet<T>()); + attribute = new BoundaryAttribute<>(tPO, tPI, new NodesSet<T>()); } - transformedNode = new BSPTree<T>(transform.apply(node.getCut(), hyperplane, transformed), + transformedNode = new BSPTree<>(transform.apply(node.getCut(), hyperplane, transformed), recurseTransform(node.getPlus(), transformed, transform, map), recurseTransform(node.getMinus(), transformed, transform, map), attribute); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java index 16548dd..0599d89 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BSPTree.java @@ -163,9 +163,9 @@ public class BSPTree<S extends Space> { } cut = chopped; - plus = new BSPTree<S>(); + plus = new BSPTree<>(); plus.parent = this; - minus = new BSPTree<S>(); + minus = new BSPTree<>(); minus.parent = this; return true; @@ -181,10 +181,10 @@ public class BSPTree<S extends Space> { public BSPTree<S> copySelf() { if (cut == null) { - return new BSPTree<S>(attribute); + return new BSPTree<>(attribute); } - return new BSPTree<S>(cut.copySelf(), plus.copySelf(), minus.copySelf(), + return new BSPTree<>(cut.copySelf(), plus.copySelf(), minus.copySelf(), attribute); } @@ -340,7 +340,7 @@ public class BSPTree<S extends Space> { * than maxOffset from the point) */ public List<BSPTree<S>> getCloseCuts(final Point<S> point, final double maxOffset) { - final List<BSPTree<S>> close = new ArrayList<BSPTree<S>>(); + final List<BSPTree<S>> close = new ArrayList<>(); recurseCloseCuts(point, maxOffset, close); return close; } @@ -554,7 +554,7 @@ public class BSPTree<S extends Space> { public BSPTree<S> split(final SubHyperplane<S> sub) { if (cut == null) { - return new BSPTree<S>(sub, copySelf(), new BSPTree<S>(attribute), null); + return new BSPTree<>(sub, copySelf(), new BSPTree<S>(attribute), null); } final Hyperplane<S> cHyperplane = cut.getHyperplane(); @@ -566,12 +566,12 @@ public class BSPTree<S extends Space> { final BSPTree<S> split = plus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree<S>(cut.copySelf(), split.plus, minus.copySelf(), attribute); + new BSPTree<>(cut.copySelf(), split.plus, minus.copySelf(), attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree<S>(cut.copySelf(), split.minus, minus.copySelf(), attribute); + new BSPTree<>(cut.copySelf(), split.minus, minus.copySelf(), attribute); split.minus.condense(); split.minus.parent = split; } @@ -582,12 +582,12 @@ public class BSPTree<S extends Space> { final BSPTree<S> split = minus.split(sub); if (cut.split(sHyperplane).getSide() == Side.PLUS) { split.plus = - new BSPTree<S>(cut.copySelf(), plus.copySelf(), split.plus, attribute); + new BSPTree<>(cut.copySelf(), plus.copySelf(), split.plus, attribute); split.plus.condense(); split.plus.parent = split; } else { split.minus = - new BSPTree<S>(cut.copySelf(), plus.copySelf(), split.minus, attribute); + new BSPTree<>(cut.copySelf(), plus.copySelf(), split.minus, attribute); split.minus.condense(); split.minus.parent = split; } @@ -597,7 +597,7 @@ public class BSPTree<S extends Space> { { final SubHyperplane.SplitSubHyperplane<S> cutParts = cut.split(sHyperplane); final BSPTree<S> split = - new BSPTree<S>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), + new BSPTree<>(sub, plus.split(subParts.getPlus()), minus.split(subParts.getMinus()), null); split.plus.cut = cutParts.getPlus(); split.minus.cut = cutParts.getMinus(); @@ -612,8 +612,8 @@ public class BSPTree<S extends Space> { } default : return cHyperplane.sameOrientationAs(sHyperplane) ? - new BSPTree<S>(sub, plus.copySelf(), minus.copySelf(), attribute) : - new BSPTree<S>(sub, minus.copySelf(), plus.copySelf(), attribute); + new BSPTree<>(sub, plus.copySelf(), minus.copySelf(), attribute) : + new BSPTree<>(sub, minus.copySelf(), plus.copySelf(), attribute); } } @@ -710,16 +710,16 @@ public class BSPTree<S extends Space> { final Object internalAttributes) { // build the current cell leaf - BSPTree<S> tree = new BSPTree<S>(cellAttribute); + BSPTree<S> tree = new BSPTree<>(cellAttribute); // build the pruned tree bottom-up for (BSPTree<S> current = this; current.parent != null; current = current.parent) { final SubHyperplane<S> parentCut = current.parent.cut.copySelf(); - final BSPTree<S> sibling = new BSPTree<S>(otherLeafsAttributes); + final BSPTree<S> sibling = new BSPTree<>(otherLeafsAttributes); if (current == current.parent.plus) { - tree = new BSPTree<S>(parentCut, tree, sibling, internalAttributes); + tree = new BSPTree<>(parentCut, tree, sibling, internalAttributes); } else { - tree = new BSPTree<S>(parentCut, sibling, tree, internalAttributes); + tree = new BSPTree<>(parentCut, sibling, tree, internalAttributes); } } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java index 2b35eb9..a286235 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryBuilder.java @@ -44,18 +44,18 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> { // characterize the cut sub-hyperplane, // first with respect to the plus sub-tree - final Characterization<S> plusChar = new Characterization<S>(node.getPlus(), node.getCut().copySelf()); + final Characterization<S> plusChar = new Characterization<>(node.getPlus(), node.getCut().copySelf()); if (plusChar.touchOutside()) { // plusChar.outsideTouching() corresponds to a subset of the cut sub-hyperplane // known to have outside cells on its plus side, we want to check if parts // of this subset do have inside cells on their minus side - final Characterization<S> minusChar = new Characterization<S>(node.getMinus(), plusChar.outsideTouching()); + final Characterization<S> minusChar = new Characterization<>(node.getMinus(), plusChar.outsideTouching()); if (minusChar.touchInside()) { // this part belongs to the boundary, // it has the outside on its plus side and the inside on its minus side plusOutside = minusChar.insideTouching(); - splitters = new NodesSet<S>(); + splitters = new NodesSet<>(); splitters.addAll(minusChar.getInsideSplitters()); splitters.addAll(plusChar.getOutsideSplitters()); } @@ -65,13 +65,13 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> { // plusChar.insideTouching() corresponds to a subset of the cut sub-hyperplane // known to have inside cells on its plus side, we want to check if parts // of this subset do have outside cells on their minus side - final Characterization<S> minusChar = new Characterization<S>(node.getMinus(), plusChar.insideTouching()); + final Characterization<S> minusChar = new Characterization<>(node.getMinus(), plusChar.insideTouching()); if (minusChar.touchOutside()) { // this part belongs to the boundary, // it has the inside on its plus side and the outside on its minus side plusInside = minusChar.outsideTouching(); if (splitters == null) { - splitters = new NodesSet<S>(); + splitters = new NodesSet<>(); } splitters.addAll(minusChar.getOutsideSplitters()); splitters.addAll(plusChar.getInsideSplitters()); @@ -86,7 +86,7 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> { } // set the boundary attribute at non-leaf nodes - node.setAttribute(new BoundaryAttribute<S>(plusOutside, plusInside, splitters)); + node.setAttribute(new BoundaryAttribute<>(plusOutside, plusInside, splitters)); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java index afb8884..212f624 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/BoundaryProjector.java @@ -130,7 +130,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi // fix offset sign offset = FastMath.copySign(offset, (Boolean) leaf.getAttribute() ? -1 : +1); - return new BoundaryProjection<S>(original, projected, offset); + return new BoundaryProjection<>(original, projected, offset); } @@ -140,7 +140,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi */ private List<Region<T>> boundaryRegions(final BSPTree<S> node) { - final List<Region<T>> regions = new ArrayList<Region<T>>(2); + final List<Region<T>> regions = new ArrayList<>(2); @SuppressWarnings("unchecked") final BoundaryAttribute<S> ba = (BoundaryAttribute<S>) node.getAttribute(); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java index 69df9ad..9eae358 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/Characterization.java @@ -56,8 +56,8 @@ class Characterization<S extends Space> { Characterization(final BSPTree<S> node, final SubHyperplane<S> sub) { outsideTouching = null; insideTouching = null; - outsideSplitters = new NodesSet<S>(); - insideSplitters = new NodesSet<S>(); + outsideSplitters = new NodesSet<>(); + insideSplitters = new NodesSet<>(); characterize(node, sub, new ArrayList<BSPTree<S>>()); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java index e7588e0..1d55c5b 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/NodesSet.java @@ -35,7 +35,7 @@ public class NodesSet<S extends Space> implements Iterable<BSPTree<S>> { /** Simple constructor. */ public NodesSet() { - list = new ArrayList<BSPTree<S>>(); + list = new ArrayList<>(); } /** Add a node if not already known. http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java index 6d49939..3b0e795 100644 --- a/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java +++ b/src/main/java/org/apache/commons/math4/geometry/partitioning/RegionFactory.java @@ -176,7 +176,7 @@ public class RegionFactory<S extends Space> { private BSPTree<S> recurseComplement(final BSPTree<S> node) { // transform the tree, except for boundary attribute splitters - final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<BSPTree<S>, BSPTree<S>>(); + final Map<BSPTree<S>, BSPTree<S>> map = new HashMap<>(); final BSPTree<S> transformedTree = recurseComplement(node, map); // set up the boundary attributes splitters @@ -208,7 +208,7 @@ public class RegionFactory<S extends Space> { final BSPTree<S> transformedNode; if (node.getCut() == null) { - transformedNode = new BSPTree<S>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); + transformedNode = new BSPTree<>(((Boolean) node.getAttribute()) ? Boolean.FALSE : Boolean.TRUE); } else { @SuppressWarnings("unchecked") @@ -219,10 +219,10 @@ public class RegionFactory<S extends Space> { final SubHyperplane<S> plusInside = (attribute.getPlusOutside() == null) ? null : attribute.getPlusOutside().copySelf(); // we start with an empty list of splitters, it will be filled in out of recursion - attribute = new BoundaryAttribute<S>(plusOutside, plusInside, new NodesSet<S>()); + attribute = new BoundaryAttribute<>(plusOutside, plusInside, new NodesSet<S>()); } - transformedNode = new BSPTree<S>(node.getCut().copySelf(), + transformedNode = new BSPTree<>(node.getCut().copySelf(), recurseComplement(node.getPlus(), map), recurseComplement(node.getMinus(), map), attribute); @@ -330,7 +330,7 @@ public class RegionFactory<S extends Space> { final BSPTree<S> cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null); final Region<S> r = region1.buildNew(cell); final Point<S> p = r.getBarycenter(); - return new BSPTree<S>(region1.checkPoint(p) == Location.INSIDE && + return new BSPTree<>(region1.checkPoint(p) == Location.INSIDE && region2.checkPoint(p) == Location.OUTSIDE); } @@ -376,10 +376,10 @@ public class RegionFactory<S extends Space> { public BSPTree<S> fixNode(final BSPTree<S> node) { if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) { // no ambiguity - return new BSPTree<S>(node.getPlus().getAttribute()); + return new BSPTree<>(node.getPlus().getAttribute()); } else { // ambiguous node - return new BSPTree<S>(inside); + return new BSPTree<>(inside); } } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java index 1436ce2..bc1e390 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/ArcsSet.java @@ -132,7 +132,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera if (Precision.equals(lower, upper, 0) || (upper - lower) >= MathUtils.TWO_PI) { // the tree must cover the whole circle - return new BSPTree<Sphere1D>(Boolean.TRUE); + return new BSPTree<>(Boolean.TRUE); } else if (lower > upper) { throw new NumberIsTooLargeException(LocalizedFormats.ENDPOINTS_NOT_AN_INTERVAL, lower, upper, true); @@ -148,9 +148,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera // simple arc starting after 0 and ending before 2 \pi final SubHyperplane<Sphere1D> upperCut = new LimitAngle(new S1Point(normalizedUpper), true, tolerance).wholeHyperplane(); - return new BSPTree<Sphere1D>(lowerCut, + return new BSPTree<>(lowerCut, new BSPTree<Sphere1D>(Boolean.FALSE), - new BSPTree<Sphere1D>(upperCut, + new BSPTree<>(upperCut, new BSPTree<Sphere1D>(Boolean.FALSE), new BSPTree<Sphere1D>(Boolean.TRUE), null), @@ -159,8 +159,8 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera // arc wrapping around 2 \pi final SubHyperplane<Sphere1D> upperCut = new LimitAngle(new S1Point(normalizedUpper - MathUtils.TWO_PI), true, tolerance).wholeHyperplane(); - return new BSPTree<Sphere1D>(lowerCut, - new BSPTree<Sphere1D>(upperCut, + return new BSPTree<>(lowerCut, + new BSPTree<>(upperCut, new BSPTree<Sphere1D>(Boolean.FALSE), new BSPTree<Sphere1D>(Boolean.TRUE), null), @@ -504,9 +504,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera final double previousOffset = alpha - previous; final double currentOffset = a[0] - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<Sphere1D>(point, new S1Point(a[0]), currentOffset); + return new BoundaryProjection<>(point, new S1Point(a[0]), currentOffset); } } } else if (alpha <= a[1]) { @@ -515,9 +515,9 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera final double offset0 = a[0] - alpha; final double offset1 = alpha - a[1]; if (offset0 < offset1) { - return new BoundaryProjection<Sphere1D>(point, new S1Point(a[1]), offset1); + return new BoundaryProjection<>(point, new S1Point(a[1]), offset1); } else { - return new BoundaryProjection<Sphere1D>(point, new S1Point(a[0]), offset0); + return new BoundaryProjection<>(point, new S1Point(a[0]), offset0); } } } @@ -527,7 +527,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera if (Double.isNaN(previous)) { // there are no points at all in the arcs set - return new BoundaryProjection<Sphere1D>(point, null, MathUtils.TWO_PI); + return new BoundaryProjection<>(point, null, MathUtils.TWO_PI); } else { @@ -538,18 +538,18 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera final double previousOffset = alpha - (previous - MathUtils.TWO_PI); final double currentOffset = first - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<Sphere1D>(point, new S1Point(first), currentOffset); + return new BoundaryProjection<>(point, new S1Point(first), currentOffset); } } else { // the test point is between last and 2\pi final double previousOffset = alpha - previous; final double currentOffset = first + MathUtils.TWO_PI - alpha; if (previousOffset < currentOffset) { - return new BoundaryProjection<Sphere1D>(point, new S1Point(previous), previousOffset); + return new BoundaryProjection<>(point, new S1Point(previous), previousOffset); } else { - return new BoundaryProjection<Sphere1D>(point, new S1Point(first), currentOffset); + return new BoundaryProjection<>(point, new S1Point(first), currentOffset); } } @@ -565,7 +565,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera * @return a new ordered list containing {@link Arc Arc} elements */ public List<Arc> asList() { - final List<Arc> list = new ArrayList<Arc>(); + final List<Arc> list = new ArrayList<>(); for (final double[] a : this) { list.add(new Arc(a[0], a[1], getTolerance())); } @@ -724,8 +724,8 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera */ public Split split(final Arc arc) { - final List<Double> minus = new ArrayList<Double>(); - final List<Double> plus = new ArrayList<Double>(); + final List<Double> minus = new ArrayList<>(); + final List<Double> plus = new ArrayList<>(); final double reference = FastMath.PI + arc.getInf(); final double arcLength = arc.getSup() - arc.getInf(); @@ -861,7 +861,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera } // build the tree by adding all angular sectors - BSPTree<Sphere1D> tree = new BSPTree<Sphere1D>(Boolean.FALSE); + BSPTree<Sphere1D> tree = new BSPTree<>(Boolean.FALSE); for (int i = 0; i < limits.size() - 1; i += 2) { addArcLimit(tree, limits.get(i), true); addArcLimit(tree, limits.get(i + 1), false); http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java index 31f79fd..37a6de8 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/SubLimitAngle.java @@ -59,8 +59,8 @@ public class SubLimitAngle extends AbstractSubHyperplane<Sphere1D, Sphere1D> { public SplitSubHyperplane<Sphere1D> split(final Hyperplane<Sphere1D> hyperplane) { final double global = hyperplane.getOffset(((LimitAngle) getHyperplane()).getLocation()); return (global < -1.0e-10) ? - new SplitSubHyperplane<Sphere1D>(null, this) : - new SplitSubHyperplane<Sphere1D>(this, null); + new SplitSubHyperplane<>(null, this) : + new SplitSubHyperplane<>(this, null); } } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java index 002d42c..86f12c6 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java @@ -55,8 +55,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> { EdgesBuilder(final BSPTree<Sphere2D> root, final double tolerance) { this.root = root; this.tolerance = tolerance; - this.edgeToNode = new IdentityHashMap<Edge, BSPTree<Sphere2D>>(); - this.nodeToEdgesList = new IdentityHashMap<BSPTree<Sphere2D>, List<Edge>>(); + this.edgeToNode = new IdentityHashMap<>(); + this.nodeToEdgesList = new IdentityHashMap<>(); } /** {@inheritDoc} */ @@ -165,7 +165,7 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> { previous.setNextEdge(getFollowingEdge(previous)); } - return new ArrayList<Edge>(edgeToNode.keySet()); + return new ArrayList<>(edgeToNode.keySet()); } http://git-wip-us.apache.org/repos/asf/commons-math/blob/8b5f4535/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java index eadc223..b7bcbf0 100644 --- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java +++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java @@ -50,7 +50,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> { this.tolerance = tolerance; this.summedArea = 0; this.summedBarycenter = Vector3D.ZERO; - this.convexCellsInsidePoints = new ArrayList<Vector3D>(); + this.convexCellsInsidePoints = new ArrayList<>(); } /** {@inheritDoc} */