Add missing @Override tags, use final for private fields where possible.

This commit is contained in:
Thomas Neidhart 2015-03-10 23:05:14 +01:00
parent 7c172a091a
commit fbf5a51ea5
34 changed files with 166 additions and 19 deletions

View File

@ -58,6 +58,7 @@ public class WelzlEncloser<S extends Space, P extends Point<S>> implements Enclo
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public EnclosingBall<S, P> enclose(final Iterable<P> points) { public EnclosingBall<S, P> enclose(final Iterable<P> points) {
if (points == null || !points.iterator().hasNext()) { if (points == null || !points.iterator().hasNext()) {

View File

@ -45,6 +45,7 @@ public class Euclidean1D implements Serializable, Space {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public int getDimension() { public int getDimension() {
return 1; return 1;
} }
@ -57,6 +58,7 @@ public class Euclidean1D implements Serializable, Space {
* @return nothing * @return nothing
* @throws NoSubSpaceException in all cases * @throws NoSubSpaceException in all cases
*/ */
@Override
public Space getSubSpace() throws NoSubSpaceException { public Space getSubSpace() throws NoSubSpaceException {
throw new NoSubSpaceException(); throw new NoSubSpaceException();
} }

View File

@ -511,6 +511,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
* </p> * </p>
* @since 3.3 * @since 3.3
*/ */
@Override
public Iterator<double[]> iterator() { public Iterator<double[]> iterator() {
return new SubIntervalsIterator(); return new SubIntervalsIterator();
} }
@ -599,11 +600,13 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean hasNext() { public boolean hasNext() {
return pending != null; return pending != null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double[] next() { public double[] next() {
if (pending == null) { if (pending == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
@ -614,6 +617,7 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> imple
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.partitioning.Hyperplane;
public class OrientedPoint implements Hyperplane<Euclidean1D> { public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** Vector location. */ /** Vector location. */
private Vector1D location; private final Vector1D location;
/** Orientation. */ /** Orientation. */
private boolean direct; private boolean direct;
@ -55,6 +55,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
* the instance.</p> * the instance.</p>
* @return the instance itself * @return the instance itself
*/ */
@Override
public OrientedPoint copySelf() { public OrientedPoint copySelf() {
return this; return this;
} }
@ -68,6 +69,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getOffset(final Point<Euclidean1D> point) { public double getOffset(final Point<Euclidean1D> point) {
final double delta = ((Vector1D) point).getX() - location.getX(); final double delta = ((Vector1D) point).getX() - location.getX();
return direct ? delta : -delta; return direct ? delta : -delta;
@ -84,6 +86,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
* <em>not</em> be used otherwise.</p> * <em>not</em> be used otherwise.</p>
* @return a dummy sub hyperplane * @return a dummy sub hyperplane
*/ */
@Override
public SubOrientedPoint wholeHyperplane() { public SubOrientedPoint wholeHyperplane() {
return new SubOrientedPoint(this, null); return new SubOrientedPoint(this, null);
} }
@ -92,11 +95,13 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
* @return a region containing the instance (really an {@link * @return a region containing the instance (really an {@link
* IntervalsSet IntervalsSet} instance) * IntervalsSet IntervalsSet} instance)
*/ */
@Override
public IntervalsSet wholeSpace() { public IntervalsSet wholeSpace() {
return new IntervalsSet(tolerance); return new IntervalsSet(tolerance);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Euclidean1D> other) { public boolean sameOrientationAs(final Hyperplane<Euclidean1D> other) {
return !(direct ^ ((OrientedPoint) other).direct); return !(direct ^ ((OrientedPoint) other).direct);
} }
@ -104,6 +109,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public Point<Euclidean1D> project(Point<Euclidean1D> point) { public Point<Euclidean1D> project(Point<Euclidean1D> point) {
return location; return location;
} }
@ -111,6 +117,7 @@ public class OrientedPoint implements Hyperplane<Euclidean1D> {
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public double getTolerance() { public double getTolerance() {
return tolerance; return tolerance;
} }

View File

@ -44,11 +44,13 @@ public class Euclidean3D implements Serializable, Space {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public int getDimension() { public int getDimension() {
return 3; return 3;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Euclidean2D getSubSpace() { public Euclidean2D getSubSpace() {
return Euclidean2D.getInstance(); return Euclidean2D.getInstance();
} }

View File

@ -159,6 +159,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
/** {@inheritDoc} /** {@inheritDoc}
* @see #getAbscissa(Vector3D) * @see #getAbscissa(Vector3D)
*/ */
@Override
public Vector1D toSubSpace(final Point<Euclidean3D> point) { public Vector1D toSubSpace(final Point<Euclidean3D> point) {
return new Vector1D(getAbscissa((Vector3D) point)); return new Vector1D(getAbscissa((Vector3D) point));
} }
@ -166,6 +167,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> {
/** {@inheritDoc} /** {@inheritDoc}
* @see #pointAt(double) * @see #pointAt(double)
*/ */
@Override
public Vector3D toSpace(final Point<Euclidean1D> point) { public Vector3D toSpace(final Point<Euclidean1D> point) {
return pointAt(((Vector1D) point).getX()); return pointAt(((Vector1D) point).getX());
} }

View File

@ -38,13 +38,13 @@ import org.apache.commons.math4.util.FastMath;
public class OutlineExtractor { public class OutlineExtractor {
/** Abscissa axis of the projection plane. */ /** Abscissa axis of the projection plane. */
private Vector3D u; private final Vector3D u;
/** Ordinate axis of the projection plane. */ /** Ordinate axis of the projection plane. */
private Vector3D v; private final Vector3D v;
/** Normal of the projection plane (viewing direction). */ /** Normal of the projection plane (viewing direction). */
private Vector3D w; private final Vector3D w;
/** Build an extractor for a specific projection plane. /** Build an extractor for a specific projection plane.
* @param u abscissa axis of the projection point * @param u abscissa axis of the projection point
@ -136,11 +136,13 @@ public class OutlineExtractor {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Euclidean3D> node) { public Order visitOrder(final BSPTree<Euclidean3D> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Euclidean3D> node) { public void visitInternalNode(final BSPTree<Euclidean3D> node) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BoundaryAttribute<Euclidean3D> attribute = final BoundaryAttribute<Euclidean3D> attribute =
@ -154,6 +156,7 @@ public class OutlineExtractor {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Euclidean3D> node) { public void visitLeafNode(final BSPTree<Euclidean3D> node) {
} }

View File

@ -117,6 +117,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* shared (except for immutable objects).</p> * shared (except for immutable objects).</p>
* @return a new hyperplane, copy of the instance * @return a new hyperplane, copy of the instance
*/ */
@Override
public Plane copySelf() { public Plane copySelf() {
return new Plane(this); return new Plane(this);
} }
@ -215,6 +216,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public Point<Euclidean3D> project(Point<Euclidean3D> point) { public Point<Euclidean3D> project(Point<Euclidean3D> point) {
return toSpace(toSubSpace(point)); return toSpace(toSubSpace(point));
} }
@ -222,6 +224,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public double getTolerance() { public double getTolerance() {
return tolerance; return tolerance;
} }
@ -270,6 +273,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* org.apache.commons.math4.geometry.euclidean.twod.Vector2D Vector2D} instance) * org.apache.commons.math4.geometry.euclidean.twod.Vector2D Vector2D} instance)
* @see #toSpace * @see #toSpace
*/ */
@Override
public Vector2D toSubSpace(final Point<Euclidean3D> point) { public Vector2D toSubSpace(final Point<Euclidean3D> point) {
final Vector3D p3D = (Vector3D) point; final Vector3D p3D = (Vector3D) point;
return new Vector2D(p3D.dotProduct(u), p3D.dotProduct(v)); return new Vector2D(p3D.dotProduct(u), p3D.dotProduct(v));
@ -281,6 +285,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return 3D space point (really a {@link Vector3D Vector3D} instance) * @return 3D space point (really a {@link Vector3D Vector3D} instance)
* @see #toSubSpace * @see #toSubSpace
*/ */
@Override
public Vector3D toSpace(final Point<Euclidean2D> point) { public Vector3D toSpace(final Point<Euclidean2D> point) {
final Vector2D p2D = (Vector2D) point; final Vector2D p2D = (Vector2D) point;
return new Vector3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w); return new Vector3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w);
@ -422,6 +427,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
/** Build a region covering the whole hyperplane. /** Build a region covering the whole hyperplane.
* @return a region covering the whole hyperplane * @return a region covering the whole hyperplane
*/ */
@Override
public SubPlane wholeHyperplane() { public SubPlane wholeHyperplane() {
return new SubPlane(this, new PolygonsSet(tolerance)); return new SubPlane(this, new PolygonsSet(tolerance));
} }
@ -430,6 +436,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return a region containing the instance (really a {@link * @return a region containing the instance (really a {@link
* PolyhedronsSet PolyhedronsSet} instance) * PolyhedronsSet PolyhedronsSet} instance)
*/ */
@Override
public PolyhedronsSet wholeSpace() { public PolyhedronsSet wholeSpace() {
return new PolyhedronsSet(tolerance); return new PolyhedronsSet(tolerance);
} }
@ -472,6 +479,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @param point point to check * @param point point to check
* @return offset of the point * @return offset of the point
*/ */
@Override
public double getOffset(final Point<Euclidean3D> point) { public double getOffset(final Point<Euclidean3D> point) {
return ((Vector3D) point).dotProduct(w) + originOffset; return ((Vector3D) point).dotProduct(w) + originOffset;
} }
@ -481,6 +489,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu
* @return true if the instance and the other hyperplane have * @return true if the instance and the other hyperplane have
* the same orientation * the same orientation
*/ */
@Override
public boolean sameOrientationAs(final Hyperplane<Euclidean3D> other) { public boolean sameOrientationAs(final Hyperplane<Euclidean3D> other) {
return (((Plane) other).w).dotProduct(w) > 0.0; return (((Plane) other).w).dotProduct(w) > 0.0;
} }

View File

@ -183,11 +183,13 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Euclidean3D> node) { public Order visitOrder(final BSPTree<Euclidean3D> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Euclidean3D> node) { public void visitInternalNode(final BSPTree<Euclidean3D> node) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BoundaryAttribute<Euclidean3D> attribute = final BoundaryAttribute<Euclidean3D> attribute =
@ -201,6 +203,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Euclidean3D> node) { public void visitLeafNode(final BSPTree<Euclidean3D> node) {
} }
@ -345,10 +348,10 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
private static class RotationTransform implements Transform<Euclidean3D, Euclidean2D> { private static class RotationTransform implements Transform<Euclidean3D, Euclidean2D> {
/** Center point of the rotation. */ /** Center point of the rotation. */
private Vector3D center; private final Vector3D center;
/** Vectorial rotation. */ /** Vectorial rotation. */
private Rotation rotation; private final Rotation rotation;
/** Cached original hyperplane. */ /** Cached original hyperplane. */
private Plane cachedOriginal; private Plane cachedOriginal;
@ -366,17 +369,20 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector3D apply(final Point<Euclidean3D> point) { public Vector3D apply(final Point<Euclidean3D> point) {
final Vector3D delta = ((Vector3D) point).subtract(center); final Vector3D delta = ((Vector3D) point).subtract(center);
return new Vector3D(1.0, center, 1.0, rotation.applyTo(delta)); return new Vector3D(1.0, center, 1.0, rotation.applyTo(delta));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Plane apply(final Hyperplane<Euclidean3D> hyperplane) { public Plane apply(final Hyperplane<Euclidean3D> hyperplane) {
return ((Plane) hyperplane).rotate(center, rotation); return ((Plane) hyperplane).rotate(center, rotation);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub,
final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> original,
final Hyperplane<Euclidean3D> transformed) { final Hyperplane<Euclidean3D> transformed) {
@ -418,7 +424,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
private static class TranslationTransform implements Transform<Euclidean3D, Euclidean2D> { private static class TranslationTransform implements Transform<Euclidean3D, Euclidean2D> {
/** Translation vector. */ /** Translation vector. */
private Vector3D translation; private final Vector3D translation;
/** Cached original hyperplane. */ /** Cached original hyperplane. */
private Plane cachedOriginal; private Plane cachedOriginal;
@ -434,16 +440,19 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector3D apply(final Point<Euclidean3D> point) { public Vector3D apply(final Point<Euclidean3D> point) {
return new Vector3D(1.0, (Vector3D) point, 1.0, translation); return new Vector3D(1.0, (Vector3D) point, 1.0, translation);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Plane apply(final Hyperplane<Euclidean3D> hyperplane) { public Plane apply(final Hyperplane<Euclidean3D> hyperplane) {
return ((Plane) hyperplane).translate(translation); return ((Plane) hyperplane).translate(translation);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub, public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub,
final Hyperplane<Euclidean3D> original, final Hyperplane<Euclidean3D> original,
final Hyperplane<Euclidean3D> transformed) { final Hyperplane<Euclidean3D> transformed) {

View File

@ -33,6 +33,7 @@ import org.apache.commons.math4.util.FastMath;
public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector3D> { public class SphereGenerator implements SupportBallGenerator<Euclidean3D, Vector3D> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public EnclosingBall<Euclidean3D, Vector3D> ballOnSupport(final List<Vector3D> support) { public EnclosingBall<Euclidean3D, Vector3D> ballOnSupport(final List<Vector3D> support) {
if (support.size() < 1) { if (support.size() < 1) {

View File

@ -29,6 +29,7 @@ import org.apache.commons.math4.util.FastMath;
public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D> { public class DiskGenerator implements SupportBallGenerator<Euclidean2D, Vector2D> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public EnclosingBall<Euclidean2D, Vector2D> ballOnSupport(final List<Vector2D> support) { public EnclosingBall<Euclidean2D, Vector2D> ballOnSupport(final List<Vector2D> support) {
if (support.size() < 1) { if (support.size() < 1) {

View File

@ -44,11 +44,13 @@ public class Euclidean2D implements Serializable, Space {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public int getDimension() { public int getDimension() {
return 2; return 2;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Euclidean1D getSubSpace() { public Euclidean1D getSubSpace() {
return Euclidean1D.getInstance(); return Euclidean1D.getInstance();
} }

View File

@ -136,6 +136,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Line copySelf() { public Line copySelf() {
return new Line(this); return new Line(this);
} }
@ -241,12 +242,14 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector1D toSubSpace(final Point<Euclidean2D> point) { public Vector1D toSubSpace(final Point<Euclidean2D> point) {
Vector2D p2 = (Vector2D) point; Vector2D p2 = (Vector2D) point;
return new Vector1D(MathArrays.linearCombination(cos, p2.getX(), sin, p2.getY())); return new Vector1D(MathArrays.linearCombination(cos, p2.getX(), sin, p2.getY()));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector2D toSpace(final Point<Euclidean1D> point) { public Vector2D toSpace(final Point<Euclidean1D> point) {
final double abscissa = ((Vector1D) point).getX(); final double abscissa = ((Vector1D) point).getX();
return new Vector2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin), return new Vector2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin),
@ -270,6 +273,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public Point<Euclidean2D> project(Point<Euclidean2D> point) { public Point<Euclidean2D> project(Point<Euclidean2D> point) {
return toSpace(toSubSpace(point)); return toSpace(toSubSpace(point));
} }
@ -277,11 +281,13 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public double getTolerance() { public double getTolerance() {
return tolerance; return tolerance;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubLine wholeHyperplane() { public SubLine wholeHyperplane() {
return new SubLine(this, new IntervalsSet(tolerance)); return new SubLine(this, new IntervalsSet(tolerance));
} }
@ -290,6 +296,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return a region containing the instance (really a {@link * @return a region containing the instance (really a {@link
* PolygonsSet PolygonsSet} instance) * PolygonsSet PolygonsSet} instance)
*/ */
@Override
public PolygonsSet wholeSpace() { public PolygonsSet wholeSpace() {
return new PolygonsSet(tolerance); return new PolygonsSet(tolerance);
} }
@ -318,12 +325,14 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getOffset(final Point<Euclidean2D> point) { public double getOffset(final Point<Euclidean2D> point) {
Vector2D p2 = (Vector2D) point; Vector2D p2 = (Vector2D) point;
return MathArrays.linearCombination(sin, p2.getX(), -cos, p2.getY(), 1.0, originOffset); return MathArrays.linearCombination(sin, p2.getX(), -cos, p2.getY(), 1.0, originOffset);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Euclidean2D> other) { public boolean sameOrientationAs(final Hyperplane<Euclidean2D> other) {
final Line otherL = (Line) other; final Line otherL = (Line) other;
return MathArrays.linearCombination(sin, otherL.sin, cos, otherL.cos) >= 0.0; return MathArrays.linearCombination(sin, otherL.sin, cos, otherL.cos) >= 0.0;
@ -439,16 +448,16 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
private static class LineTransform implements Transform<Euclidean2D, Euclidean1D> { private static class LineTransform implements Transform<Euclidean2D, Euclidean1D> {
// CHECKSTYLE: stop JavadocVariable check // CHECKSTYLE: stop JavadocVariable check
private double cXX; private final double cXX;
private double cXY; private final double cXY;
private double cX1; private final double cX1;
private double cYX; private final double cYX;
private double cYY; private final double cYY;
private double cY1; private final double cY1;
private double c1Y; private final double c1Y;
private double c1X; private final double c1X;
private double c11; private final double c11;
// CHECKSTYLE: resume JavadocVariable check // CHECKSTYLE: resume JavadocVariable check
/** Build an affine line transform from a n {@code AffineTransform}. /** Build an affine line transform from a n {@code AffineTransform}.
@ -479,6 +488,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector2D apply(final Point<Euclidean2D> point) { public Vector2D apply(final Point<Euclidean2D> point) {
final Vector2D p2D = (Vector2D) point; final Vector2D p2D = (Vector2D) point;
final double x = p2D.getX(); final double x = p2D.getX();
@ -488,6 +498,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Line apply(final Hyperplane<Euclidean2D> hyperplane) { public Line apply(final Hyperplane<Euclidean2D> hyperplane) {
final Line line = (Line) hyperplane; final Line line = (Line) hyperplane;
final double rOffset = MathArrays.linearCombination(c1X, line.cos, c1Y, line.sin, c11, line.originOffset); final double rOffset = MathArrays.linearCombination(c1X, line.cos, c1Y, line.sin, c11, line.originOffset);
@ -500,6 +511,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubHyperplane<Euclidean1D> apply(final SubHyperplane<Euclidean1D> sub, public SubHyperplane<Euclidean1D> apply(final SubHyperplane<Euclidean1D> sub,
final Hyperplane<Euclidean2D> original, final Hyperplane<Euclidean2D> original,
final Hyperplane<Euclidean2D> transformed) { final Hyperplane<Euclidean2D> transformed) {

View File

@ -1002,11 +1002,13 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Euclidean2D> node) { public Order visitOrder(final BSPTree<Euclidean2D> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Euclidean2D> node) { public void visitInternalNode(final BSPTree<Euclidean2D> node) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BoundaryAttribute<Euclidean2D> attribute = (BoundaryAttribute<Euclidean2D>) node.getAttribute(); final BoundaryAttribute<Euclidean2D> attribute = (BoundaryAttribute<Euclidean2D>) node.getAttribute();
@ -1020,6 +1022,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Euclidean2D> node) { public void visitLeafNode(final BSPTree<Euclidean2D> node) {
} }

View File

@ -85,6 +85,7 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public ConvexHull2D generate(final Collection<Vector2D> points) public ConvexHull2D generate(final Collection<Vector2D> points)
throws NullArgumentException, ConvergenceException { throws NullArgumentException, ConvergenceException {
// check for null points // check for null points

View File

@ -106,6 +106,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Vector2D>, Serializ
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Vector2D[] getVertices() { public Vector2D[] getVertices() {
return vertices.clone(); return vertices.clone();
} }
@ -157,6 +158,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Vector2D>, Serializ
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Region<Euclidean2D> createRegion() throws InsufficientDataException { public Region<Euclidean2D> createRegion() throws InsufficientDataException {
if (vertices.length < 3) { if (vertices.length < 3) {
throw new InsufficientDataException(); throw new InsufficientDataException();

View File

@ -32,6 +32,7 @@ import org.apache.commons.math4.geometry.hull.ConvexHullGenerator;
public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Vector2D> { public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Vector2D> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
ConvexHull2D generate(Collection<Vector2D> points) throws NullArgumentException, ConvergenceException; ConvexHull2D generate(Collection<Vector2D> points) throws NullArgumentException, ConvergenceException;
} }

View File

@ -80,6 +80,7 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
// sort the points in increasing order on the x-axis // sort the points in increasing order on the x-axis
Collections.sort(pointsSortedByXAxis, new Comparator<Vector2D>() { Collections.sort(pointsSortedByXAxis, new Comparator<Vector2D>() {
@Override
public int compare(final Vector2D o1, final Vector2D o2) { public int compare(final Vector2D o1, final Vector2D o2) {
final double tolerance = getTolerance(); final double tolerance = getTolerance();
// need to take the tolerance value into account, otherwise collinear points // need to take the tolerance value into account, otherwise collinear points

View File

@ -110,6 +110,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
// (we don't want equal size elements to be removed, so // (we don't want equal size elements to be removed, so
// we use a trick to fool the TreeSet) // 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<SubHyperplane<S>>(new Comparator<SubHyperplane<S>>() {
@Override
public int compare(final SubHyperplane<S> o1, final SubHyperplane<S> o2) { public int compare(final SubHyperplane<S> o1, final SubHyperplane<S> o2) {
final double size1 = o1.getSize(); final double size1 = o1.getSize();
final double size2 = o2.getSize(); final double size2 = o2.getSize();
@ -126,15 +127,18 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
tree.visit(new BSPTreeVisitor<S>() { tree.visit(new BSPTreeVisitor<S>() {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<S> node) { public Order visitOrder(final BSPTree<S> node) {
return Order.PLUS_SUB_MINUS; return Order.PLUS_SUB_MINUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<S> node) { public void visitInternalNode(final BSPTree<S> node) {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<S> node) { public void visitLeafNode(final BSPTree<S> node) {
if (node.getParent() == null || node == node.getParent().getMinus()) { if (node.getParent() == null || node == node.getParent().getMinus()) {
node.setAttribute(Boolean.TRUE); node.setAttribute(Boolean.TRUE);
@ -179,6 +183,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public abstract AbstractRegion<S, T> buildNew(BSPTree<S> newTree); public abstract AbstractRegion<S, T> buildNew(BSPTree<S> newTree);
/** Get the tolerance below which points are considered to belong to hyperplanes. /** Get the tolerance below which points are considered to belong to hyperplanes.
@ -240,16 +245,19 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public AbstractRegion<S, T> copySelf() { public AbstractRegion<S, T> copySelf() {
return buildNew(tree.copySelf()); return buildNew(tree.copySelf());
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isEmpty() { public boolean isEmpty() {
return isEmpty(tree); return isEmpty(tree);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isEmpty(final BSPTree<S> node) { public boolean isEmpty(final BSPTree<S> node) {
// we use a recursive function rather than the BSPTreeVisitor // we use a recursive function rather than the BSPTreeVisitor
@ -267,11 +275,13 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isFull() { public boolean isFull() {
return isFull(tree); return isFull(tree);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isFull(final BSPTree<S> node) { public boolean isFull(final BSPTree<S> node) {
// we use a recursive function rather than the BSPTreeVisitor // we use a recursive function rather than the BSPTreeVisitor
@ -289,6 +299,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean contains(final Region<S> region) { public boolean contains(final Region<S> region) {
return new RegionFactory<S>().difference(region, this).isEmpty(); return new RegionFactory<S>().difference(region, this).isEmpty();
} }
@ -296,6 +307,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
/** {@inheritDoc} /** {@inheritDoc}
* @since 3.3 * @since 3.3
*/ */
@Override
public BoundaryProjection<S> projectToBoundary(final Point<S> point) { 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<S, T>(point);
getTree(true).visit(projector); getTree(true).visit(projector);
@ -313,6 +325,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Location checkPoint(final Point<S> point) { public Location checkPoint(final Point<S> point) {
return checkPoint(tree, point); return checkPoint(tree, point);
} }
@ -350,6 +363,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> getTree(final boolean includeBoundaryAttributes) { public BSPTree<S> getTree(final boolean includeBoundaryAttributes) {
if (includeBoundaryAttributes && (tree.getCut() != null) && (tree.getAttribute() == null)) { if (includeBoundaryAttributes && (tree.getCut() != null) && (tree.getAttribute() == null)) {
// compute the boundary attributes // compute the boundary attributes
@ -359,6 +373,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getBoundarySize() { public double getBoundarySize() {
final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<S>(); final BoundarySizeVisitor<S> visitor = new BoundarySizeVisitor<S>();
getTree(true).visit(visitor); getTree(true).visit(visitor);
@ -366,6 +381,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getSize() { public double getSize() {
if (barycenter == null) { if (barycenter == null) {
computeGeometricalProperties(); computeGeometricalProperties();
@ -381,6 +397,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Point<S> getBarycenter() { public Point<S> getBarycenter() {
if (barycenter == null) { if (barycenter == null) {
computeGeometricalProperties(); computeGeometricalProperties();
@ -408,6 +425,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
protected abstract void computeGeometricalProperties(); protected abstract void computeGeometricalProperties();
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Side side(final Hyperplane<S> hyperplane) { public Side side(final Hyperplane<S> hyperplane) {
final InsideFinder<S> finder = new InsideFinder<S>(this); final InsideFinder<S> finder = new InsideFinder<S>(this);
finder.recurseSides(tree, hyperplane.wholeHyperplane()); finder.recurseSides(tree, hyperplane.wholeHyperplane());
@ -417,6 +435,7 @@ public abstract class AbstractRegion<S extends Space, T extends Space> implement
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubHyperplane<S> intersection(final SubHyperplane<S> sub) { public SubHyperplane<S> intersection(final SubHyperplane<S> sub) {
return recurseIntersection(tree, sub); return recurseIntersection(tree, sub);
} }

View File

@ -63,6 +63,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
final Region<T> remaining); final Region<T> remaining);
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public AbstractSubHyperplane<S, T> copySelf() { public AbstractSubHyperplane<S, T> copySelf() {
return buildNew(hyperplane.copySelf(), remainingRegion); return buildNew(hyperplane.copySelf(), remainingRegion);
} }
@ -70,6 +71,7 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
/** Get the underlying hyperplane. /** Get the underlying hyperplane.
* @return underlying hyperplane * @return underlying hyperplane
*/ */
@Override
public Hyperplane<S> getHyperplane() { public Hyperplane<S> getHyperplane() {
return hyperplane; return hyperplane;
} }
@ -86,11 +88,13 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getSize() { public double getSize() {
return remainingRegion.getSize(); return remainingRegion.getSize();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public AbstractSubHyperplane<S, T> reunite(final SubHyperplane<S> other) { public AbstractSubHyperplane<S, T> reunite(final SubHyperplane<S> other) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
AbstractSubHyperplane<S, T> o = (AbstractSubHyperplane<S, T>) other; AbstractSubHyperplane<S, T> o = (AbstractSubHyperplane<S, T>) other;
@ -175,12 +179,15 @@ public abstract class AbstractSubHyperplane<S extends Space, T extends Space>
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public abstract Side side(Hyperplane<S> hyper); public abstract Side side(Hyperplane<S> hyper);
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public abstract SplitSubHyperplane<S> split(Hyperplane<S> hyper); public abstract SplitSubHyperplane<S> split(Hyperplane<S> hyper);
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isEmpty() { public boolean isEmpty() {
return remainingRegion.isEmpty(); return remainingRegion.isEmpty();
} }

View File

@ -29,11 +29,13 @@ import org.apache.commons.math4.geometry.Space;
class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> { class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(BSPTree<S> node) { public Order visitOrder(BSPTree<S> node) {
return Order.PLUS_MINUS_SUB; return Order.PLUS_MINUS_SUB;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(BSPTree<S> node) { public void visitInternalNode(BSPTree<S> node) {
SubHyperplane<S> plusOutside = null; SubHyperplane<S> plusOutside = null;
@ -89,6 +91,7 @@ class BoundaryBuilder<S extends Space> implements BSPTreeVisitor<S> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(BSPTree<S> node) { public void visitLeafNode(BSPTree<S> node) {
} }

View File

@ -54,6 +54,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<S> node) { public Order visitOrder(final BSPTree<S> node) {
// we want to visit the tree so that the first encountered // we want to visit the tree so that the first encountered
// leaf is the one closest to the test point // leaf is the one closest to the test point
@ -65,6 +66,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<S> node) { public void visitInternalNode(final BSPTree<S> node) {
// project the point on the cut sub-hyperplane // project the point on the cut sub-hyperplane
@ -111,6 +113,7 @@ class BoundaryProjector<S extends Space, T extends Space> implements BSPTreeVisi
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<S> node) { public void visitLeafNode(final BSPTree<S> node) {
if (leaf == null) { if (leaf == null) {
// this is the first leaf we visit, // this is the first leaf we visit,

View File

@ -34,11 +34,13 @@ class BoundarySizeVisitor<S extends Space> implements BSPTreeVisitor<S> {
} }
/** {@inheritDoc}*/ /** {@inheritDoc}*/
@Override
public Order visitOrder(final BSPTree<S> node) { public Order visitOrder(final BSPTree<S> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc}*/ /** {@inheritDoc}*/
@Override
public void visitInternalNode(final BSPTree<S> node) { public void visitInternalNode(final BSPTree<S> node) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
final BoundaryAttribute<S> attribute = final BoundaryAttribute<S> attribute =
@ -52,6 +54,7 @@ class BoundarySizeVisitor<S extends Space> implements BSPTreeVisitor<S> {
} }
/** {@inheritDoc}*/ /** {@inheritDoc}*/
@Override
public void visitLeafNode(final BSPTree<S> node) { public void visitLeafNode(final BSPTree<S> node) {
} }

View File

@ -30,7 +30,7 @@ import org.apache.commons.math4.geometry.Space;
public class NodesSet<S extends Space> implements Iterable<BSPTree<S>> { public class NodesSet<S extends Space> implements Iterable<BSPTree<S>> {
/** List of sub-hyperplanes. */ /** List of sub-hyperplanes. */
private List<BSPTree<S>> list; private final List<BSPTree<S>> list;
/** Simple constructor. /** Simple constructor.
*/ */
@ -65,6 +65,7 @@ public class NodesSet<S extends Space> implements Iterable<BSPTree<S>> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Iterator<BSPTree<S>> iterator() { public Iterator<BSPTree<S>> iterator() {
return list.iterator(); return list.iterator();
} }

View File

@ -206,6 +206,7 @@ public class RegionFactory<S extends Space> {
/** BSP tree leaf merger computing union of two regions. */ /** BSP tree leaf merger computing union of two regions. */
private class UnionMerger implements BSPTree.LeafMerger<S> { private class UnionMerger implements BSPTree.LeafMerger<S> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree,
final BSPTree<S> parentTree, final BSPTree<S> parentTree,
final boolean isPlusChild, final boolean leafFromInstance) { final boolean isPlusChild, final boolean leafFromInstance) {
@ -223,6 +224,7 @@ public class RegionFactory<S extends Space> {
/** BSP tree leaf merger computing intersection of two regions. */ /** BSP tree leaf merger computing intersection of two regions. */
private class IntersectionMerger implements BSPTree.LeafMerger<S> { private class IntersectionMerger implements BSPTree.LeafMerger<S> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree,
final BSPTree<S> parentTree, final BSPTree<S> parentTree,
final boolean isPlusChild, final boolean leafFromInstance) { final boolean isPlusChild, final boolean leafFromInstance) {
@ -240,6 +242,7 @@ public class RegionFactory<S extends Space> {
/** BSP tree leaf merger computing symmetric difference (exclusive or) of two regions. */ /** BSP tree leaf merger computing symmetric difference (exclusive or) of two regions. */
private class XorMerger implements BSPTree.LeafMerger<S> { private class XorMerger implements BSPTree.LeafMerger<S> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree,
final BSPTree<S> parentTree, final boolean isPlusChild, final BSPTree<S> parentTree, final boolean isPlusChild,
final boolean leafFromInstance) { final boolean leafFromInstance) {
@ -272,6 +275,7 @@ public class RegionFactory<S extends Space> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree, public BSPTree<S> merge(final BSPTree<S> leaf, final BSPTree<S> tree,
final BSPTree<S> parentTree, final boolean isPlusChild, final BSPTree<S> parentTree, final boolean isPlusChild,
final boolean leafFromInstance) { final boolean leafFromInstance) {
@ -290,6 +294,7 @@ public class RegionFactory<S extends Space> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> fixNode(final BSPTree<S> node) { public BSPTree<S> fixNode(final BSPTree<S> node) {
// get a representative point in the degenerate cell // get a representative point in the degenerate cell
final BSPTree<S> cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null); final BSPTree<S> cell = node.pruneAroundConvexCell(Boolean.TRUE, Boolean.FALSE, null);
@ -305,16 +310,19 @@ public class RegionFactory<S extends Space> {
private class NodesCleaner implements BSPTreeVisitor<S> { private class NodesCleaner implements BSPTreeVisitor<S> {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<S> node) { public Order visitOrder(final BSPTree<S> node) {
return Order.PLUS_SUB_MINUS; return Order.PLUS_SUB_MINUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<S> node) { public void visitInternalNode(final BSPTree<S> node) {
node.setAttribute(null); node.setAttribute(null);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<S> node) { public void visitLeafNode(final BSPTree<S> node) {
} }
@ -334,6 +342,7 @@ public class RegionFactory<S extends Space> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public BSPTree<S> fixNode(final BSPTree<S> node) { public BSPTree<S> fixNode(final BSPTree<S> node) {
if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) { if (node.getPlus().getAttribute().equals(node.getMinus().getAttribute())) {
// no ambiguity // no ambiguity

View File

@ -580,6 +580,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
* The iterator does <em>not</em> support the optional {@code remove} operation. * The iterator does <em>not</em> support the optional {@code remove} operation.
* </p> * </p>
*/ */
@Override
public Iterator<double[]> iterator() { public Iterator<double[]> iterator() {
return new SubArcsIterator(); return new SubArcsIterator();
} }
@ -676,11 +677,13 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean hasNext() { public boolean hasNext() {
return pending != null; return pending != null;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double[] next() { public double[] next() {
if (pending == null) { if (pending == null) {
throw new NoSuchElementException(); throw new NoSuchElementException();
@ -691,6 +694,7 @@ public class ArcsSet extends AbstractRegion<Sphere1D, Sphere1D> implements Itera
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void remove() { public void remove() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -27,10 +27,10 @@ import org.apache.commons.math4.geometry.partitioning.Hyperplane;
public class LimitAngle implements Hyperplane<Sphere1D> { public class LimitAngle implements Hyperplane<Sphere1D> {
/** Angle location. */ /** Angle location. */
private S1Point location; private final S1Point location;
/** Orientation. */ /** Orientation. */
private boolean direct; private final boolean direct;
/** Tolerance below which angles are considered identical. */ /** Tolerance below which angles are considered identical. */
private final double tolerance; private final double tolerance;
@ -52,11 +52,13 @@ public class LimitAngle implements Hyperplane<Sphere1D> {
* the instance.</p> * the instance.</p>
* @return the instance itself * @return the instance itself
*/ */
@Override
public LimitAngle copySelf() { public LimitAngle copySelf() {
return this; return this;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getOffset(final Point<Sphere1D> point) { public double getOffset(final Point<Sphere1D> point) {
final double delta = ((S1Point) point).getAlpha() - location.getAlpha(); final double delta = ((S1Point) point).getAlpha() - location.getAlpha();
return direct ? delta : -delta; return direct ? delta : -delta;
@ -90,6 +92,7 @@ public class LimitAngle implements Hyperplane<Sphere1D> {
* <em>not</em> be used otherwise.</p> * <em>not</em> be used otherwise.</p>
* @return a dummy sub hyperplane * @return a dummy sub hyperplane
*/ */
@Override
public SubLimitAngle wholeHyperplane() { public SubLimitAngle wholeHyperplane() {
return new SubLimitAngle(this, null); return new SubLimitAngle(this, null);
} }
@ -98,11 +101,13 @@ public class LimitAngle implements Hyperplane<Sphere1D> {
* @return a region containing the instance (really an {@link * @return a region containing the instance (really an {@link
* ArcsSet IntervalsSet} instance) * ArcsSet IntervalsSet} instance)
*/ */
@Override
public ArcsSet wholeSpace() { public ArcsSet wholeSpace() {
return new ArcsSet(tolerance); return new ArcsSet(tolerance);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Sphere1D> other) { public boolean sameOrientationAs(final Hyperplane<Sphere1D> other) {
return !(direct ^ ((LimitAngle) other).direct); return !(direct ^ ((LimitAngle) other).direct);
} }
@ -115,11 +120,13 @@ public class LimitAngle implements Hyperplane<Sphere1D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Point<Sphere1D> project(Point<Sphere1D> point) { public Point<Sphere1D> project(Point<Sphere1D> point) {
return location; return location;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getTolerance() { public double getTolerance() {
return tolerance; return tolerance;
} }

View File

@ -77,16 +77,19 @@ public class S1Point implements Point<Sphere1D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Space getSpace() { public Space getSpace() {
return Sphere1D.getInstance(); return Sphere1D.getInstance();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isNaN() { public boolean isNaN() {
return Double.isNaN(alpha); return Double.isNaN(alpha);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double distance(final Point<Sphere1D> point) { public double distance(final Point<Sphere1D> point) {
return distance(this, (S1Point) point); return distance(this, (S1Point) point);
} }

View File

@ -51,6 +51,7 @@ public class Sphere1D implements Serializable, Space {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public int getDimension() { public int getDimension() {
return 1; return 1;
} }
@ -63,6 +64,7 @@ public class Sphere1D implements Serializable, Space {
* @return nothing * @return nothing
* @throws NoSubSpaceException in all cases * @throws NoSubSpaceException in all cases
*/ */
@Override
public Space getSubSpace() throws NoSubSpaceException { public Space getSubSpace() throws NoSubSpaceException {
throw new NoSubSpaceException(); throw new NoSubSpaceException();
} }

View File

@ -102,6 +102,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Circle copySelf() { public Circle copySelf() {
return new Circle(this); return new Circle(this);
} }
@ -134,11 +135,13 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Point<Sphere2D> project(Point<Sphere2D> point) { public Point<Sphere2D> project(Point<Sphere2D> point) {
return toSpace(toSubSpace(point)); return toSpace(toSubSpace(point));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double getTolerance() { public double getTolerance() {
return tolerance; return tolerance;
} }
@ -146,6 +149,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
/** {@inheritDoc} /** {@inheritDoc}
* @see #getPhase(Vector3D) * @see #getPhase(Vector3D)
*/ */
@Override
public S1Point toSubSpace(final Point<Sphere2D> point) { public S1Point toSubSpace(final Point<Sphere2D> point) {
return new S1Point(getPhase(((S2Point) point).getVector())); return new S1Point(getPhase(((S2Point) point).getVector()));
} }
@ -167,6 +171,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
/** {@inheritDoc} /** {@inheritDoc}
* @see #getPointAt(double) * @see #getPointAt(double)
*/ */
@Override
public S2Point toSpace(final Point<Sphere1D> point) { public S2Point toSpace(final Point<Sphere1D> point) {
return new S2Point(getPointAt(((S1Point) point).getAlpha())); return new S2Point(getPointAt(((S1Point) point).getAlpha()));
} }
@ -236,6 +241,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubCircle wholeHyperplane() { public SubCircle wholeHyperplane() {
return new SubCircle(this, new ArcsSet(tolerance)); return new SubCircle(this, new ArcsSet(tolerance));
} }
@ -244,6 +250,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @return a region containing the instance (really a {@link * @return a region containing the instance (really a {@link
* SphericalPolygonsSet SphericalPolygonsSet} instance) * SphericalPolygonsSet SphericalPolygonsSet} instance)
*/ */
@Override
public SphericalPolygonsSet wholeSpace() { public SphericalPolygonsSet wholeSpace() {
return new SphericalPolygonsSet(tolerance); return new SphericalPolygonsSet(tolerance);
} }
@ -251,6 +258,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
/** {@inheritDoc} /** {@inheritDoc}
* @see #getOffset(Vector3D) * @see #getOffset(Vector3D)
*/ */
@Override
public double getOffset(final Point<Sphere2D> point) { public double getOffset(final Point<Sphere2D> point) {
return getOffset(((S2Point) point).getVector()); return getOffset(((S2Point) point).getVector());
} }
@ -269,6 +277,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Sphere2D> other) { public boolean sameOrientationAs(final Hyperplane<Sphere2D> other) {
final Circle otherC = (Circle) other; final Circle otherC = (Circle) other;
return Vector3D.dotProduct(pole, otherC.pole) >= 0.0; return Vector3D.dotProduct(pole, otherC.pole) >= 0.0;
@ -300,11 +309,13 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public S2Point apply(final Point<Sphere2D> point) { public S2Point apply(final Point<Sphere2D> point) {
return new S2Point(rotation.applyTo(((S2Point) point).getVector())); return new S2Point(rotation.applyTo(((S2Point) point).getVector()));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Circle apply(final Hyperplane<Sphere2D> hyperplane) { public Circle apply(final Hyperplane<Sphere2D> hyperplane) {
final Circle circle = (Circle) hyperplane; final Circle circle = (Circle) hyperplane;
return new Circle(rotation.applyTo(circle.pole), return new Circle(rotation.applyTo(circle.pole),
@ -314,6 +325,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public SubHyperplane<Sphere1D> apply(final SubHyperplane<Sphere1D> sub, public SubHyperplane<Sphere1D> apply(final SubHyperplane<Sphere1D> sub,
final Hyperplane<Sphere2D> original, final Hyperplane<Sphere2D> original,
final Hyperplane<Sphere2D> transformed) { final Hyperplane<Sphere2D> transformed) {

View File

@ -60,11 +60,13 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Sphere2D> node) { public Order visitOrder(final BSPTree<Sphere2D> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Sphere2D> node) { public void visitInternalNode(final BSPTree<Sphere2D> node) {
nodeToEdgesList.put(node, new ArrayList<Edge>()); nodeToEdgesList.put(node, new ArrayList<Edge>());
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -78,6 +80,7 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Sphere2D> node) { public void visitLeafNode(final BSPTree<Sphere2D> node) {
} }

View File

@ -54,16 +54,19 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Order visitOrder(final BSPTree<Sphere2D> node) { public Order visitOrder(final BSPTree<Sphere2D> node) {
return Order.MINUS_SUB_PLUS; return Order.MINUS_SUB_PLUS;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitInternalNode(final BSPTree<Sphere2D> node) { public void visitInternalNode(final BSPTree<Sphere2D> node) {
// nothing to do here // nothing to do here
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public void visitLeafNode(final BSPTree<Sphere2D> node) { public void visitLeafNode(final BSPTree<Sphere2D> node) {
if ((Boolean) node.getAttribute()) { if ((Boolean) node.getAttribute()) {

View File

@ -152,11 +152,13 @@ public class S2Point implements Point<Sphere2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Space getSpace() { public Space getSpace() {
return Sphere2D.getInstance(); return Sphere2D.getInstance();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public boolean isNaN() { public boolean isNaN() {
return Double.isNaN(theta) || Double.isNaN(phi); return Double.isNaN(theta) || Double.isNaN(phi);
} }
@ -169,6 +171,7 @@ public class S2Point implements Point<Sphere2D> {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public double distance(final Point<Sphere2D> point) { public double distance(final Point<Sphere2D> point) {
return distance(this, (S2Point) point); return distance(this, (S2Point) point);
} }

View File

@ -50,11 +50,13 @@ public class Sphere2D implements Serializable, Space {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public int getDimension() { public int getDimension() {
return 2; return 2;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public Sphere1D getSubSpace() { public Sphere1D getSubSpace() {
return Sphere1D.getInstance(); return Sphere1D.getInstance();
} }