http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 bec2d74..dc538a5 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 @@ -28,7 +28,7 @@ import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.MathArrays; /** - * This class is a re-implementation of {@link Vector3D} using {@link RealFieldElement}. + * This class is a re-implementation of {@link Coordinates3D} using {@link RealFieldElement}. * <p>Instance of this class are guaranteed to be immutable.</p> * @param <T> the type of the field elements * @since 3.2 @@ -110,7 +110,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param a scale factor * @param u base (unscaled) vector */ - public FieldVector3D(final T a, final Vector3D u) { + public FieldVector3D(final T a, final Coordinates3D u) { this.x = a.multiply(u.getX()); this.y = a.multiply(u.getY()); this.z = a.multiply(u.getZ()); @@ -152,8 +152,8 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param a2 second scale factor * @param u2 second base (unscaled) vector */ - public FieldVector3D(final T a1, final Vector3D u1, - final T a2, final Vector3D u2) { + public FieldVector3D(final T a1, final Coordinates3D u1, + final T a2, final Coordinates3D u2) { final T prototype = a1; this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2); this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2); @@ -205,9 +205,9 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param a3 third scale factor * @param u3 third base (unscaled) vector */ - public FieldVector3D(final T a1, final Vector3D u1, - final T a2, final Vector3D u2, - final T a3, final Vector3D u3) { + public FieldVector3D(final T a1, final Coordinates3D u1, + final T a2, final Coordinates3D u2, + final T a3, final Coordinates3D u3) { final T prototype = a1; this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2, u3.getX(), a3); this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2, u3.getY(), a3); @@ -267,10 +267,10 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param a4 fourth scale factor * @param u4 fourth base (unscaled) vector */ - public FieldVector3D(final T a1, final Vector3D u1, - final T a2, final Vector3D u2, - final T a3, final Vector3D u3, - final T a4, final Vector3D u4) { + public FieldVector3D(final T a1, final Coordinates3D u1, + final T a2, final Coordinates3D u2, + final T a3, final Coordinates3D u3, + final T a4, final Coordinates3D u4) { final T prototype = a1; this.x = prototype.linearCombination(u1.getX(), a1, u2.getX(), a2, u3.getX(), a3, u4.getX(), a4); this.y = prototype.linearCombination(u1.getY(), a1, u2.getY(), a2, u3.getY(), a3, u4.getY(), a4); @@ -338,8 +338,8 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl /** Convert to a constant vector without derivatives. * @return a constant vector */ - public Vector3D toVector3D() { - return new Vector3D(x.getReal(), y.getReal(), z.getReal()); + public Coordinates3D toVector3D() { + return new Coordinates3D(x.getReal(), y.getReal(), z.getReal()); } /** Get the L<sub>1</sub> norm for the vector. @@ -415,7 +415,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to add * @return a new vector */ - public FieldVector3D<T> add(final Vector3D v) { + public FieldVector3D<T> add(final Coordinates3D v) { return new FieldVector3D<>(x.add(v.getX()), y.add(v.getY()), z.add(v.getZ())); } @@ -433,7 +433,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to add * @return a new vector */ - public FieldVector3D<T> add(final T factor, final Vector3D v) { + public FieldVector3D<T> add(final T factor, final Coordinates3D v) { return new FieldVector3D<>(x.add(factor.multiply(v.getX())), y.add(factor.multiply(v.getY())), z.add(factor.multiply(v.getZ()))); @@ -453,7 +453,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to add * @return a new vector */ - public FieldVector3D<T> add(final double factor, final Vector3D v) { + public FieldVector3D<T> add(final double factor, final Coordinates3D v) { return new FieldVector3D<>(x.add(factor * v.getX()), y.add(factor * v.getY()), z.add(factor * v.getZ())); @@ -471,7 +471,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to subtract * @return a new vector */ - public FieldVector3D<T> subtract(final Vector3D v) { + public FieldVector3D<T> subtract(final Coordinates3D v) { return new FieldVector3D<>(x.subtract(v.getX()), y.subtract(v.getY()), z.subtract(v.getZ())); } @@ -489,7 +489,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to subtract * @return a new vector */ - public FieldVector3D<T> subtract(final T factor, final Vector3D v) { + public FieldVector3D<T> subtract(final T factor, final Coordinates3D v) { return new FieldVector3D<>(x.subtract(factor.multiply(v.getX())), y.subtract(factor.multiply(v.getY())), z.subtract(factor.multiply(v.getZ()))); @@ -509,7 +509,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v vector to subtract * @return a new vector */ - public FieldVector3D<T> subtract(final double factor, final Vector3D v) { + public FieldVector3D<T> subtract(final double factor, final Coordinates3D v) { return new FieldVector3D<>(x.subtract(factor * v.getX()), y.subtract(factor * v.getY()), z.subtract(factor * v.getZ())); @@ -610,7 +610,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return angular separation between v1 and v2 * @exception MathArithmeticException if either vector has a null norm */ - public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final Vector3D v2) + public static <T extends RealFieldElement<T>> T angle(final FieldVector3D<T> v1, final Coordinates3D v2) throws MathArithmeticException { final T normProduct = v1.getNorm().multiply(v2.getNorm()); @@ -646,7 +646,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return angular separation between v1 and v2 * @exception MathArithmeticException if either vector has a null norm */ - public static <T extends RealFieldElement<T>> T angle(final Vector3D v1, final FieldVector3D<T> v2) + public static <T extends RealFieldElement<T>> T angle(final Coordinates3D v1, final FieldVector3D<T> v2) throws MathArithmeticException { return angle(v2, v1); } @@ -770,7 +770,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v second vector * @return the dot product this.v */ - public T dotProduct(final Vector3D v) { + public T dotProduct(final Coordinates3D v) { return x.linearCombination(v.getX(), x, v.getY(), y, v.getZ(), z); } @@ -788,7 +788,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v other vector * @return the cross product this ^ v as a new Vector3D */ - public FieldVector3D<T> crossProduct(final Vector3D v) { + public FieldVector3D<T> crossProduct(final Coordinates3D v) { 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)); @@ -815,7 +815,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v second vector * @return the distance between the instance and p according to the L<sub>1</sub> norm */ - public T distance1(final Vector3D v) { + public T distance1(final Coordinates3D v) { final T dx = x.subtract(v.getX()).abs(); final T dy = y.subtract(v.getY()).abs(); final T dz = z.subtract(v.getZ()).abs(); @@ -843,7 +843,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v second vector * @return the distance between the instance and p according to the L<sub>2</sub> norm */ - public T distance(final Vector3D v) { + public T distance(final Coordinates3D v) { final T dx = x.subtract(v.getX()); final T dy = y.subtract(v.getY()); final T dz = z.subtract(v.getZ()); @@ -883,7 +883,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v second vector * @return the distance between the instance and p according to the L<sub>∞</sub> norm */ - public T distanceInf(final Vector3D v) { + public T distanceInf(final Coordinates3D v) { final T dx = x.subtract(v.getX()).abs(); final T dy = y.subtract(v.getY()).abs(); final T dz = z.subtract(v.getZ()).abs(); @@ -923,7 +923,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param v second vector * @return the square of the distance between the instance and p */ - public T distanceSq(final Vector3D v) { + public T distanceSq(final Coordinates3D v) { final T dx = x.subtract(v.getX()); final T dy = y.subtract(v.getY()); final T dz = z.subtract(v.getZ()); @@ -948,7 +948,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the dot product v1.v2 */ public static <T extends RealFieldElement<T>> T dotProduct(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.dotProduct(v2); } @@ -958,7 +958,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the dot product v1.v2 */ - public static <T extends RealFieldElement<T>> T dotProduct(final Vector3D v1, + public static <T extends RealFieldElement<T>> T dotProduct(final Coordinates3D v1, final FieldVector3D<T> v2) { return v2.dotProduct(v1); } @@ -981,7 +981,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the cross product v1 ^ v2 as a new Vector */ public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.crossProduct(v2); } @@ -991,7 +991,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the cross product v1 ^ v2 as a new Vector */ - public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Vector3D v1, + public static <T extends RealFieldElement<T>> FieldVector3D<T> crossProduct(final Coordinates3D v1, final FieldVector3D<T> v2) { 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), @@ -1022,7 +1022,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the distance between v1 and v2 according to the L<sub>1</sub> norm */ public static <T extends RealFieldElement<T>> T distance1(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.distance1(v2); } @@ -1035,7 +1035,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the distance between v1 and v2 according to the L<sub>1</sub> norm */ - public static <T extends RealFieldElement<T>> T distance1(final Vector3D v1, + public static <T extends RealFieldElement<T>> T distance1(final Coordinates3D v1, final FieldVector3D<T> v2) { return v2.distance1(v1); } @@ -1064,7 +1064,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the distance between v1 and v2 according to the L<sub>2</sub> norm */ public static <T extends RealFieldElement<T>> T distance(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.distance(v2); } @@ -1077,7 +1077,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the distance between v1 and v2 according to the L<sub>2</sub> norm */ - public static <T extends RealFieldElement<T>> T distance(final Vector3D v1, + public static <T extends RealFieldElement<T>> T distance(final Coordinates3D v1, final FieldVector3D<T> v2) { return v2.distance(v1); } @@ -1106,7 +1106,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the distance between v1 and v2 according to the L<sub>∞</sub> norm */ public static <T extends RealFieldElement<T>> T distanceInf(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.distanceInf(v2); } @@ -1119,7 +1119,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the distance between v1 and v2 according to the L<sub>∞</sub> norm */ - public static <T extends RealFieldElement<T>> T distanceInf(final Vector3D v1, + public static <T extends RealFieldElement<T>> T distanceInf(final Coordinates3D v1, final FieldVector3D<T> v2) { return v2.distanceInf(v1); } @@ -1148,7 +1148,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @return the square of the distance between v1 and v2 */ public static <T extends RealFieldElement<T>> T distanceSq(final FieldVector3D<T> v1, - final Vector3D v2) { + final Coordinates3D v2) { return v1.distanceSq(v2); } @@ -1161,7 +1161,7 @@ public class FieldVector3D<T extends RealFieldElement<T>> implements Serializabl * @param <T> the type of the field elements * @return the square of the distance between v1 and v2 */ - public static <T extends RealFieldElement<T>> T distanceSq(final Vector3D v1, + public static <T extends RealFieldElement<T>> T distanceSq(final Coordinates3D v1, final FieldVector3D<T> v2) { return v2.distanceSq(v1); }
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java index 3173ac2..d68bb94 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Line.java @@ -22,7 +22,7 @@ import org.apache.commons.math4.geometry.Point; import org.apache.commons.math4.geometry.Vector; import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D; import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet; -import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; +import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D; import org.apache.commons.math4.geometry.partitioning.Embedding; import org.apache.commons.math4.util.FastMath; import org.apache.commons.math4.util.Precision; @@ -41,10 +41,10 @@ import org.apache.commons.math4.util.Precision; public class Line implements Embedding<Euclidean3D, Euclidean1D> { /** Line direction. */ - private Vector3D direction; + private Coordinates3D direction; /** Line point closest to the origin. */ - private Vector3D zero; + private Coordinates3D zero; /** Tolerance below which points are considered identical. */ private final double tolerance; @@ -56,7 +56,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @exception MathIllegalArgumentException if the points are equal * @since 3.3 */ - public Line(final Vector3D p1, final Vector3D p2, final double tolerance) + public Line(final Coordinates3D p1, final Coordinates3D p2, final double tolerance) throws MathIllegalArgumentException { reset(p1, p2); this.tolerance = tolerance; @@ -78,14 +78,14 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param p2 second point belonging to the line (this can be any point, different from p1) * @exception MathIllegalArgumentException if the points are equal */ - public void reset(final Vector3D p1, final Vector3D p2) throws MathIllegalArgumentException { - final Vector3D delta = p2.subtract(p1); + public void reset(final Coordinates3D p1, final Coordinates3D p2) throws MathIllegalArgumentException { + final Coordinates3D delta = p2.subtract(p1); final double norm2 = delta.getNormSq(); if (norm2 == 0.0) { throw new MathIllegalArgumentException(LocalizedFormats.ZERO_NORM); } - this.direction = new Vector3D(1.0 / FastMath.sqrt(norm2), delta); - zero = new Vector3D(1.0, p1, -p1.dotProduct(delta) / norm2, delta); + this.direction = new Coordinates3D(1.0 / FastMath.sqrt(norm2), delta); + zero = new Coordinates3D(1.0, p1, -p1.dotProduct(delta) / norm2, delta); } /** Get the tolerance below which points are considered identical. @@ -108,14 +108,14 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { /** Get the normalized direction vector. * @return normalized direction vector */ - public Vector3D getDirection() { + public Coordinates3D getDirection() { return direction; } /** Get the line point closest to the origin. * @return line point closest to the origin */ - public Vector3D getOrigin() { + public Coordinates3D getOrigin() { return zero; } @@ -126,7 +126,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param point point to check * @return abscissa of the point */ - public double getAbscissa(final Vector3D point) { + public double getAbscissa(final Coordinates3D point) { return point.subtract(zero).dotProduct(direction); } @@ -134,8 +134,8 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param abscissa desired abscissa for the point * @return one point belonging to the line, at specified abscissa */ - public Vector3D pointAt(final double abscissa) { - return new Vector3D(1.0, zero, abscissa, direction); + public Coordinates3D pointAt(final double abscissa) { + return new Coordinates3D(1.0, zero, abscissa, direction); } /** Transform a space point into a sub-space point. @@ -143,7 +143,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @return (n-1)-dimension point of the sub-space corresponding to * the specified space point */ - public Vector1D toSubSpace(Vector<Euclidean3D> vector) { + public Coordinates1D toSubSpace(Vector<Euclidean3D> vector) { return toSubSpace((Point<Euclidean3D>) vector); } @@ -152,7 +152,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @return n-dimension point of the space corresponding to the * specified sub-space point */ - public Vector3D toSpace(Vector<Euclidean1D> vector) { + public Coordinates3D toSpace(Vector<Euclidean1D> vector) { return toSpace((Point<Euclidean1D>) vector); } @@ -160,16 +160,16 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @see #getAbscissa(Vector3D) */ @Override - public Vector1D toSubSpace(final Point<Euclidean3D> point) { - return new Vector1D(getAbscissa((Vector3D) point)); + public Coordinates1D toSubSpace(final Point<Euclidean3D> point) { + return new Coordinates1D(getAbscissa((Coordinates3D) point)); } /** {@inheritDoc} * @see #pointAt(double) */ @Override - public Vector3D toSpace(final Point<Euclidean1D> point) { - return pointAt(((Vector1D) point).getX()); + public Coordinates3D toSpace(final Point<Euclidean1D> point) { + return pointAt(((Coordinates1D) point).getX()); } /** Check if the instance is similar to another line. @@ -180,7 +180,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @return true if the lines are similar */ public boolean isSimilarTo(final Line line) { - final double angle = Vector3D.angle(direction, line.direction); + final double angle = Coordinates3D.angle(direction, line.direction); return ((angle < tolerance) || (angle > (FastMath.PI - tolerance))) && contains(line.zero); } @@ -188,7 +188,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param p point to check * @return true if p belongs to the line */ - public boolean contains(final Vector3D p) { + public boolean contains(final Coordinates3D p) { return distance(p) < tolerance; } @@ -196,9 +196,9 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param p to check * @return distance between the instance and the point */ - public double distance(final Vector3D p) { - final Vector3D d = p.subtract(zero); - final Vector3D n = new Vector3D(1.0, d, -d.dotProduct(direction), direction); + public double distance(final Coordinates3D p) { + final Coordinates3D d = p.subtract(zero); + final Coordinates3D n = new Coordinates3D(1.0, d, -d.dotProduct(direction), direction); return n.getNorm(); } @@ -208,7 +208,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { */ public double distance(final Line line) { - final Vector3D normal = Vector3D.crossProduct(direction, line.direction); + final Coordinates3D normal = Coordinates3D.crossProduct(direction, line.direction); final double n = normal.getNorm(); if (n < Precision.SAFE_MIN) { // lines are parallel @@ -226,7 +226,7 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @param line line to check against the instance * @return point of the instance closest to another line */ - public Vector3D closestPoint(final Line line) { + public Coordinates3D closestPoint(final Line line) { final double cos = direction.dotProduct(line.direction); final double n = 1 - cos * cos; @@ -235,11 +235,11 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { return zero; } - final Vector3D delta0 = line.zero.subtract(zero); + final Coordinates3D delta0 = line.zero.subtract(zero); final double a = delta0.dotProduct(direction); final double b = delta0.dotProduct(line.direction); - return new Vector3D(1, zero, (a - b * cos) / n, direction); + return new Coordinates3D(1, zero, (a - b * cos) / n, direction); } @@ -248,8 +248,8 @@ public class Line implements Embedding<Euclidean3D, Euclidean1D> { * @return intersection point of the instance and the other line * or null if there are no intersection points */ - public Vector3D intersection(final Line line) { - final Vector3D closest = closestPoint(line); + public Coordinates3D intersection(final Line line) { + final Coordinates3D closest = closestPoint(line); return line.contains(closest) ? closest : null; } http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 67abdd1..90eeef7 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 @@ -21,7 +21,7 @@ import java.util.ArrayList; import org.apache.commons.math4.geometry.Point; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane; import org.apache.commons.math4.geometry.partitioning.BSPTree; import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor; @@ -38,29 +38,29 @@ import org.apache.commons.math4.util.FastMath; public class OutlineExtractor { /** Abscissa axis of the projection plane. */ - private final Vector3D u; + private final Coordinates3D u; /** Ordinate axis of the projection plane. */ - private final Vector3D v; + private final Coordinates3D v; /** Normal of the projection plane (viewing direction). */ - private final Vector3D w; + private final Coordinates3D w; /** Build an extractor for a specific projection plane. * @param u abscissa axis of the projection point * @param v ordinate axis of the projection point */ - public OutlineExtractor(final Vector3D u, final Vector3D v) { + public OutlineExtractor(final Coordinates3D u, final Coordinates3D v) { this.u = u; this.v = v; - w = Vector3D.crossProduct(u, v); + w = Coordinates3D.crossProduct(u, v); } /** Extract the outline of a polyhedrons set. * @param polyhedronsSet polyhedrons set whose outline must be extracted * @return an outline, as an array of loops. */ - public Vector2D[][] getOutline(final PolyhedronsSet polyhedronsSet) { + public Coordinates2D[][] getOutline(final PolyhedronsSet polyhedronsSet) { // project all boundary facets into one polygons set final BoundaryProjector projector = new BoundaryProjector(polyhedronsSet.getTolerance()); @@ -68,9 +68,9 @@ public class OutlineExtractor { final PolygonsSet projected = projector.getProjected(); // Remove the spurious intermediate vertices from the outline - final Vector2D[][] outline = projected.getVertices(); + final Coordinates2D[][] outline = projected.getVertices(); for (int i = 0; i < outline.length; ++i) { - final Vector2D[] rawLoop = outline[i]; + final Coordinates2D[] rawLoop = outline[i]; int end = rawLoop.length; int j = 0; while (j < end) { @@ -87,7 +87,7 @@ public class OutlineExtractor { } if (end != rawLoop.length) { // resize the array - outline[i] = new Vector2D[end]; + outline[i] = new Coordinates2D[end]; System.arraycopy(rawLoop, 0, outline[i], 0, end); } } @@ -104,10 +104,10 @@ public class OutlineExtractor { * @param i index of the point to check (must be between 0 and n-1) * @return true if the point is exactly between its neighbors */ - private boolean pointIsBetween(final Vector2D[] loop, final int n, final int i) { - final Vector2D previous = loop[(i + n - 1) % n]; - final Vector2D current = loop[i]; - final Vector2D next = loop[(i + 1) % n]; + private boolean pointIsBetween(final Coordinates2D[] loop, final int n, final int i) { + final Coordinates2D previous = loop[(i + n - 1) % n]; + final Coordinates2D current = loop[i]; + final Coordinates2D next = loop[(i + 1) % n]; final double dx1 = current.getX() - previous.getX(); final double dy1 = current.getY() - previous.getY(); final double dx2 = next.getX() - current.getX(); @@ -174,16 +174,16 @@ public class OutlineExtractor { final double scal = plane.getNormal().dotProduct(w); if (FastMath.abs(scal) > 1.0e-3) { - Vector2D[][] vertices = + Coordinates2D[][] vertices = ((PolygonsSet) absFacet.getRemainingRegion()).getVertices(); if ((scal < 0) ^ reversed) { // the facet is seen from the inside, // we need to invert its boundary orientation - final Vector2D[][] newVertices = new Vector2D[vertices.length][]; + final Coordinates2D[][] newVertices = new Coordinates2D[vertices.length][]; for (int i = 0; i < vertices.length; ++i) { - final Vector2D[] loop = vertices[i]; - final Vector2D[] newLoop = new Vector2D[loop.length]; + final Coordinates2D[] loop = vertices[i]; + final Coordinates2D[] newLoop = new Coordinates2D[loop.length]; if (loop[0] == null) { newLoop[0] = null; for (int j = 1; j < loop.length; ++j) { @@ -204,17 +204,17 @@ public class OutlineExtractor { // compute the projection of the facet in the outline plane final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>(); - for (Vector2D[] loop : vertices) { + for (Coordinates2D[] loop : vertices) { final boolean closed = loop[0] != null; int previous = closed ? (loop.length - 1) : 1; - Vector3D previous3D = plane.toSpace((Point<Euclidean2D>) loop[previous]); + Coordinates3D previous3D = plane.toSpace((Point<Euclidean2D>) loop[previous]); int current = (previous + 1) % loop.length; - Vector2D pPoint = new Vector2D(previous3D.dotProduct(u), + Coordinates2D pPoint = new Coordinates2D(previous3D.dotProduct(u), previous3D.dotProduct(v)); while (current < loop.length) { - final Vector3D current3D = plane.toSpace((Point<Euclidean2D>) loop[current]); - final Vector2D cPoint = new Vector2D(current3D.dotProduct(u), + final Coordinates3D current3D = plane.toSpace((Point<Euclidean2D>) loop[current]); + final Coordinates2D cPoint = new Coordinates2D(current3D.dotProduct(u), current3D.dotProduct(v)); final org.apache.commons.math4.geometry.euclidean.twod.Line line = new org.apache.commons.math4.geometry.euclidean.twod.Line(pPoint, cPoint, tolerance); http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java index 039f5f2..0038194 100644 --- a/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java +++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/threed/Plane.java @@ -19,12 +19,11 @@ package org.apache.commons.math4.geometry.euclidean.threed; import org.apache.commons.math4.exception.MathArithmeticException; import org.apache.commons.math4.exception.util.LocalizedFormats; import org.apache.commons.math4.geometry.Point; -import org.apache.commons.math4.geometry.Vector; import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D; -import org.apache.commons.math4.geometry.euclidean.oned.Vector1D; +import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.partitioning.Embedding; import org.apache.commons.math4.geometry.partitioning.Hyperplane; import org.apache.commons.math4.util.FastMath; @@ -38,16 +37,16 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu private double originOffset; /** Origin of the plane frame. */ - private Vector3D origin; + private Coordinates3D origin; /** First vector of the plane frame (in plane). */ - private Vector3D u; + private Coordinates3D u; /** Second vector of the plane frame (in plane). */ - private Vector3D v; + private Coordinates3D v; /** Third vector of the plane frame (plane normal). */ - private Vector3D w; + private Coordinates3D w; /** Tolerance below which points are considered identical. */ private final double tolerance; @@ -58,7 +57,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @exception MathArithmeticException if the normal norm is too small * @since 3.3 */ - public Plane(final Vector3D normal, final double tolerance) + public Plane(final Coordinates3D normal, final double tolerance) throws MathArithmeticException { setNormal(normal); this.tolerance = tolerance; @@ -73,7 +72,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @exception MathArithmeticException if the normal norm is too small * @since 3.3 */ - public Plane(final Vector3D p, final Vector3D normal, final double tolerance) + public Plane(final Coordinates3D p, final Coordinates3D normal, final double tolerance) throws MathArithmeticException { setNormal(normal); this.tolerance = tolerance; @@ -91,7 +90,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @exception MathArithmeticException if the points do not constitute a plane * @since 3.3 */ - public Plane(final Vector3D p1, final Vector3D p2, final Vector3D p3, final double tolerance) + public Plane(final Coordinates3D p1, final Coordinates3D p2, final Coordinates3D p3, final double tolerance) throws MathArithmeticException { this(p1, p2.subtract(p1).crossProduct(p3.subtract(p1)), tolerance); } @@ -127,7 +126,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param normal normal direction to the plane * @exception MathArithmeticException if the normal norm is too small */ - public void reset(final Vector3D p, final Vector3D normal) throws MathArithmeticException { + public void reset(final Coordinates3D p, final Coordinates3D normal) throws MathArithmeticException { setNormal(normal); originOffset = -p.dotProduct(w); setFrame(); @@ -151,20 +150,20 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param normal normal direction to the plane (will be copied) * @exception MathArithmeticException if the normal norm is too small */ - private void setNormal(final Vector3D normal) throws MathArithmeticException { + private void setNormal(final Coordinates3D normal) throws MathArithmeticException { final double norm = normal.getNorm(); if (norm < 1.0e-10) { throw new MathArithmeticException(LocalizedFormats.ZERO_NORM); } - w = new Vector3D(1.0 / norm, normal); + w = new Coordinates3D(1.0 / norm, normal); } /** Reset the plane frame. */ private void setFrame() { - origin = new Vector3D(-originOffset, w); + origin = new Coordinates3D(-originOffset, w); u = w.orthogonal(); - v = Vector3D.crossProduct(w, u); + v = Coordinates3D.crossProduct(w, u); } /** Get the origin point of the plane frame. @@ -173,7 +172,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @return the origin point of the plane frame (point closest to the * 3D-space origin) */ - public Vector3D getOrigin() { + public Coordinates3D getOrigin() { return origin; } @@ -185,7 +184,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @see #getU * @see #getV */ - public Vector3D getNormal() { + public Coordinates3D getNormal() { return w; } @@ -197,7 +196,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @see #getV * @see #getNormal */ - public Vector3D getU() { + public Coordinates3D getU() { return u; } @@ -209,7 +208,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @see #getU * @see #getNormal */ - public Vector3D getV() { + public Coordinates3D getV() { return v; } @@ -241,7 +240,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * reversed.</p> */ public void revertSelf() { - final Vector3D tmp = u; + final Coordinates3D tmp = u; u = v; v = tmp; w = w.negate(); @@ -253,42 +252,42 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @return (n-1)-dimension point of the sub-space corresponding to * the specified space point */ - public Vector2D toSubSpace(Vector<Euclidean3D> vector) { - return toSubSpace((Point<Euclidean3D>) vector); - } +// public Coordinates2D toSubSpace(Vector<Euclidean3D> vector) { +// return toSubSpace((Point<Euclidean3D>) vector); +// } /** Transform a sub-space point into a space point. * @param vector (n-1)-dimension point of the sub-space * @return n-dimension point of the space corresponding to the * specified sub-space point */ - public Vector3D toSpace(Vector<Euclidean2D> vector) { - return toSpace((Point<Euclidean2D>) vector); - } +// public Coordinates3D toSpace(Vector<Euclidean2D> vector) { +// return toSpace((Point<Euclidean2D>) vector); +// } /** Transform a 3D space point into an in-plane point. - * @param point point of the space (must be a {@link Vector3D + * @param point point of the space (must be a {@link Coordinates3D * Vector3D} instance) * @return in-plane point (really a {@link - * org.apache.commons.math4.geometry.euclidean.twod.Vector2D Vector2D} instance) + * org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D Vector2D} instance) * @see #toSpace */ @Override - public Vector2D toSubSpace(final Point<Euclidean3D> point) { - final Vector3D p3D = (Vector3D) point; - return new Vector2D(p3D.dotProduct(u), p3D.dotProduct(v)); + public Coordinates2D toSubSpace(final Point<Euclidean3D> point) { + final Coordinates3D p3D = (Coordinates3D) point; + return new Coordinates2D(p3D.dotProduct(u), p3D.dotProduct(v)); } /** Transform an in-plane point into a 3D space point. * @param point in-plane point (must be a {@link - * org.apache.commons.math4.geometry.euclidean.twod.Vector2D Vector2D} instance) - * @return 3D space point (really a {@link Vector3D Vector3D} instance) + * org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D Vector2D} instance) + * @return 3D space point (really a {@link Coordinates3D Vector3D} instance) * @see #toSubSpace */ @Override - public Vector3D toSpace(final Point<Euclidean2D> point) { - final Vector2D p2D = (Vector2D) point; - return new Vector3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w); + public Coordinates3D toSpace(final Point<Euclidean2D> point) { + final Coordinates2D p2D = (Coordinates2D) point; + return new Coordinates3D(p2D.getX(), u, p2D.getY(), v, -originOffset, w); } /** Get one point from the 3D-space. @@ -298,8 +297,8 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @return one point in the 3D-space, with given coordinates and offset * relative to the plane */ - public Vector3D getPointAt(final Vector2D inPlane, final double offset) { - return new Vector3D(inPlane.getX(), u, inPlane.getY(), v, offset - originOffset, w); + public Coordinates3D getPointAt(final Coordinates2D inPlane, final double offset) { + return new Coordinates3D(inPlane.getX(), u, inPlane.getY(), v, offset - originOffset, w); } /** Check if the instance is similar to another plane. @@ -310,7 +309,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @return true if the planes are similar */ public boolean isSimilarTo(final Plane plane) { - final double angle = Vector3D.angle(w, plane.w); + final double angle = Coordinates3D.angle(w, plane.w); return ((angle < 1.0e-10) && (FastMath.abs(originOffset - plane.originOffset) < tolerance)) || ((angle > (FastMath.PI - 1.0e-10)) && (FastMath.abs(originOffset + plane.originOffset) < tolerance)); } @@ -321,9 +320,9 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param rotation vectorial rotation operator * @return a new plane */ - public Plane rotate(final Vector3D center, final Rotation rotation) { + public Plane rotate(final Coordinates3D center, final Rotation rotation) { - final Vector3D delta = origin.subtract(center); + final Coordinates3D delta = origin.subtract(center); final Plane plane = new Plane(center.add(rotation.applyTo(delta)), rotation.applyTo(w), tolerance); @@ -340,7 +339,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param translation translation to apply * @return a new plane */ - public Plane translate(final Vector3D translation) { + public Plane translate(final Coordinates3D translation) { final Plane plane = new Plane(origin.add(translation), w, tolerance); @@ -357,15 +356,15 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @return intersection point between between the line and the * instance (null if the line is parallel to the instance) */ - public Vector3D intersection(final Line line) { - final Vector3D direction = line.getDirection(); + public Coordinates3D intersection(final Line line) { + final Coordinates3D direction = line.getDirection(); final double dot = w.dotProduct(direction); if (FastMath.abs(dot) < 1.0e-10) { return null; } - final Vector3D point = line.toSpace((Point<Euclidean1D>) Vector1D.ZERO); + final Coordinates3D point = line.toSpace((Point<Euclidean1D>) Coordinates1D.ZERO); final double k = -(originOffset + w.dotProduct(point)) / dot; - return new Vector3D(1.0, point, k, direction); + return new Coordinates3D(1.0, point, k, direction); } /** Build the line shared by the instance and another plane. @@ -374,11 +373,11 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * other plane (really a {@link Line Line} instance) */ public Line intersection(final Plane other) { - final Vector3D direction = Vector3D.crossProduct(w, other.w); + final Coordinates3D direction = Coordinates3D.crossProduct(w, other.w); if (direction.getNorm() < tolerance) { return null; } - final Vector3D point = intersection(this, other, new Plane(direction, tolerance)); + final Coordinates3D point = intersection(this, other, new Plane(direction, tolerance)); return new Line(point, point.add(direction), tolerance); } @@ -388,7 +387,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param plane3 third plane2 * @return intersection point of three planes, null if some planes are parallel */ - public static Vector3D intersection(final Plane plane1, final Plane plane2, final Plane plane3) { + public static Coordinates3D intersection(final Plane plane1, final Plane plane2, final Plane plane3) { // coefficients of the three planes linear equations final double a1 = plane1.w.getX(); @@ -417,7 +416,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu } final double r = 1.0 / determinant; - return new Vector3D( + return new Coordinates3D( (-a23 * d1 - (c1 * b3 - c3 * b1) * d2 - (c2 * b1 - c1 * b2) * d3) * r, (-b23 * d1 - (c3 * a1 - c1 * a3) * d2 - (c1 * a2 - c2 * a1) * d3) * r, (-c23 * d1 - (b1 * a3 - b3 * a1) * d2 - (b2 * a1 - b1 * a2) * d3) * r); @@ -445,7 +444,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param p point to check * @return true if p belongs to the plane */ - public boolean contains(final Vector3D p) { + public boolean contains(final Coordinates3D p) { return FastMath.abs(getOffset(p)) < tolerance; } @@ -467,9 +466,9 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu * @param vector vector to check * @return offset of the vector */ - public double getOffset(Vector<Euclidean3D> vector) { - return getOffset((Point<Euclidean3D>) vector); - } +// public double getOffset(Vector<Euclidean3D> vector) { +// return getOffset((Point<Euclidean3D>) vector); +// } /** Get the offset (oriented distance) of a point. * <p>The offset is 0 if the point is on the underlying hyperplane, @@ -481,7 +480,7 @@ public class Plane implements Hyperplane<Euclidean3D>, Embedding<Euclidean3D, Eu */ @Override public double getOffset(final Point<Euclidean3D> point) { - return ((Vector3D) point).dotProduct(w) + originOffset; + return ((Coordinates3D) point).dotProduct(w) + originOffset; } /** Check if the instance has the same orientation as another hyperplane. http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 b99c9c2..fcf26f5 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 @@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D; import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D; import org.apache.commons.math4.geometry.euclidean.twod.PolygonsSet; import org.apache.commons.math4.geometry.euclidean.twod.SubLine; -import org.apache.commons.math4.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D; import org.apache.commons.math4.geometry.partitioning.AbstractRegion; import org.apache.commons.math4.geometry.partitioning.BSPTree; import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor; @@ -123,7 +123,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @exception MathIllegalArgumentException if some basic sanity checks fail * @since 3.5 */ - public PolyhedronsSet(final List<Vector3D> vertices, final List<int[]> facets, + public PolyhedronsSet(final List<Coordinates3D> vertices, final List<int[]> facets, final double tolerance) { super(buildBoundary(vertices, facets, tolerance), tolerance); } @@ -164,12 +164,12 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { // too thin box, build an empty polygons set 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); - final Plane pyMin = new Plane(new Vector3D(0, yMin, 0), Vector3D.MINUS_J, tolerance); - final Plane pyMax = new Plane(new Vector3D(0, yMax, 0), Vector3D.PLUS_J, tolerance); - final Plane pzMin = new Plane(new Vector3D(0, 0, zMin), Vector3D.MINUS_K, tolerance); - final Plane pzMax = new Plane(new Vector3D(0, 0, zMax), Vector3D.PLUS_K, tolerance); + final Plane pxMin = new Plane(new Coordinates3D(xMin, 0, 0), Coordinates3D.MINUS_I, tolerance); + final Plane pxMax = new Plane(new Coordinates3D(xMax, 0, 0), Coordinates3D.PLUS_I, tolerance); + final Plane pyMin = new Plane(new Coordinates3D(0, yMin, 0), Coordinates3D.MINUS_J, tolerance); + final Plane pyMax = new Plane(new Coordinates3D(0, yMax, 0), Coordinates3D.PLUS_J, tolerance); + final Plane pzMin = new Plane(new Coordinates3D(0, 0, zMin), Coordinates3D.MINUS_K, tolerance); + final Plane pzMax = new Plane(new Coordinates3D(0, 0, zMax), Coordinates3D.PLUS_K, tolerance); final Region<Euclidean3D> boundary = new RegionFactory<Euclidean3D>().buildConvex(pxMin, pxMax, pyMin, pyMax, pzMin, pzMax); return boundary.getTree(false); @@ -183,15 +183,15 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @exception MathIllegalArgumentException if some basic sanity checks fail * @since 3.5 */ - private static List<SubHyperplane<Euclidean3D>> buildBoundary(final List<Vector3D> vertices, + private static List<SubHyperplane<Euclidean3D>> buildBoundary(final List<Coordinates3D> vertices, final List<int[]> facets, final double tolerance) { // check vertices distances for (int i = 0; i < vertices.size() - 1; ++i) { - final Vector3D vi = vertices.get(i); + final Coordinates3D vi = vertices.get(i); for (int j = i + 1; j < vertices.size(); ++j) { - if (Vector3D.distance(vi, vertices.get(j)) <= tolerance) { + if (Coordinates3D.distance(vi, vertices.get(j)) <= tolerance) { throw new MathIllegalArgumentException(LocalizedFormats.CLOSE_VERTICES, vi.getX(), vi.getY(), vi.getZ()); } @@ -216,8 +216,8 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { found = found || (v == vA); } if (!found) { - final Vector3D start = vertices.get(vA); - final Vector3D end = vertices.get(vB); + final Coordinates3D start = vertices.get(vA); + final Coordinates3D end = vertices.get(vB); throw new MathIllegalArgumentException(LocalizedFormats.EDGE_CONNECTED_TO_ONE_FACET, start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ()); @@ -235,9 +235,9 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { tolerance); // check all points are in the plane - final Vector2D[] two2Points = new Vector2D[facet.length]; + final Coordinates2D[] two2Points = new Coordinates2D[facet.length]; for (int i = 0 ; i < facet.length; ++i) { - final Vector3D v = vertices.get(facet[i]); + final Coordinates3D v = vertices.get(facet[i]); if (!plane.contains(v)) { throw new MathIllegalArgumentException(LocalizedFormats.OUT_OF_PLANE, v.getX(), v.getY(), v.getZ()); @@ -261,7 +261,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @exception MathIllegalArgumentException if some facets have fewer than 3 vertices * @since 3.5 */ - private static int[][] findReferences(final List<Vector3D> vertices, final List<int[]> facets) { + private static int[][] findReferences(final List<Coordinates3D> vertices, final List<int[]> facets) { // find the maximum number of facets a vertex belongs to final int[] nbFacets = new int[vertices.size()]; @@ -306,7 +306,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * once in the successors list (which means one facet orientation is wrong) * @since 3.5 */ - private static int[][] successors(final List<Vector3D> vertices, final List<int[]> facets, + private static int[][] successors(final List<Coordinates3D> vertices, final List<int[]> facets, final int[][] references) { // create an array large enough @@ -329,8 +329,8 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { successors[v][k] = facet[(i + 1) % facet.length]; for (int l = 0; l < k; ++l) { if (successors[v][l] == successors[v][k]) { - final Vector3D start = vertices.get(v); - final Vector3D end = vertices.get(successors[v][k]); + final Coordinates3D start = vertices.get(v); + final Coordinates3D end = vertices.get(successors[v][k]); throw new MathIllegalArgumentException(LocalizedFormats.FACET_ORIENTATION_MISMATCH, start.getX(), start.getY(), start.getZ(), end.getX(), end.getY(), end.getZ()); @@ -361,11 +361,11 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { // the polyhedrons set as a finite outside // surrounded by an infinite inside setSize(Double.POSITIVE_INFINITY); - setBarycenter((Point<Euclidean3D>) Vector3D.NaN); + setBarycenter((Point<Euclidean3D>) Coordinates3D.NaN); } else { // the polyhedrons set is finite, apply the remaining scaling factors setSize(getSize() / 3.0); - setBarycenter((Point<Euclidean3D>) new Vector3D(1.0 / (4 * getSize()), (Vector3D) getBarycenter())); + setBarycenter((Point<Euclidean3D>) new Coordinates3D(1.0 / (4 * getSize()), (Coordinates3D) getBarycenter())); } } @@ -376,7 +376,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { /** Simple constructor. */ FacetsContributionVisitor() { setSize(0); - setBarycenter((Point<Euclidean3D>) new Vector3D(0, 0, 0)); + setBarycenter((Point<Euclidean3D>) new Coordinates3D(0, 0, 0)); } /** {@inheritDoc} */ @@ -415,18 +415,18 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { if (Double.isInfinite(area)) { setSize(Double.POSITIVE_INFINITY); - setBarycenter((Point<Euclidean3D>) Vector3D.NaN); + setBarycenter((Point<Euclidean3D>) Coordinates3D.NaN); } else { final Plane plane = (Plane) facet.getHyperplane(); - final Vector3D facetB = plane.toSpace(polygon.getBarycenter()); + final Coordinates3D facetB = plane.toSpace(polygon.getBarycenter()); double scaled = area * facetB.dotProduct(plane.getNormal()); if (reversed) { scaled = -scaled; } setSize(getSize() + scaled); - setBarycenter((Point<Euclidean3D>) new Vector3D(1.0, (Vector3D) getBarycenter(), scaled, facetB)); + setBarycenter((Point<Euclidean3D>) new Coordinates3D(1.0, (Coordinates3D) getBarycenter(), scaled, facetB)); } @@ -441,7 +441,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * given point, or null if the line does not intersect any * sub-hyperplane */ - public SubHyperplane<Euclidean3D> firstIntersection(final Vector3D point, final Line line) { + public SubHyperplane<Euclidean3D> firstIntersection(final Coordinates3D point, final Line line) { return recurseFirstIntersection(getTree(true), point, line); } @@ -454,7 +454,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * sub-hyperplane */ private SubHyperplane<Euclidean3D> recurseFirstIntersection(final BSPTree<Euclidean3D> node, - final Vector3D point, + final Coordinates3D point, final Line line) { final SubHyperplane<Euclidean3D> cut = node.getCut(); @@ -494,7 +494,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { if (!in) { // search in the cut hyperplane - final Vector3D hit3D = plane.intersection(line); + final Coordinates3D hit3D = plane.intersection(line); if (hit3D != null && line.getAbscissa(hit3D) > line.getAbscissa(point)) { final SubHyperplane<Euclidean3D> facet = boundaryFacet(hit3D, node); if (facet != null) { @@ -514,9 +514,9 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @return the boundary facet this points belongs to (or null if it * does not belong to any boundary facet) */ - private SubHyperplane<Euclidean3D> boundaryFacet(final Vector3D point, + private SubHyperplane<Euclidean3D> boundaryFacet(final Coordinates3D point, final BSPTree<Euclidean3D> node) { - final Vector2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace((Point<Euclidean3D>) point); + final Coordinates2D point2D = ((Plane) node.getCut().getHyperplane()).toSubSpace((Point<Euclidean3D>) point); @SuppressWarnings("unchecked") final BoundaryAttribute<Euclidean3D> attribute = (BoundaryAttribute<Euclidean3D>) node.getAttribute(); @@ -537,7 +537,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @param rotation vectorial rotation operator * @return a new instance representing the rotated region */ - public PolyhedronsSet rotate(final Vector3D center, final Rotation rotation) { + public PolyhedronsSet rotate(final Coordinates3D center, final Rotation rotation) { return (PolyhedronsSet) applyTransform(new RotationTransform(center, rotation)); } @@ -545,7 +545,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { private static class RotationTransform implements Transform<Euclidean3D, Euclidean2D> { /** Center point of the rotation. */ - private final Vector3D center; + private final Coordinates3D center; /** Vectorial rotation. */ private final Rotation rotation; @@ -560,16 +560,16 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @param center center point of the rotation * @param rotation vectorial rotation */ - RotationTransform(final Vector3D center, final Rotation rotation) { + RotationTransform(final Coordinates3D center, final Rotation rotation) { this.center = center; this.rotation = rotation; } /** {@inheritDoc} */ @Override - public Vector3D apply(final Point<Euclidean3D> point) { - final Vector3D delta = ((Vector3D) point).subtract(center); - return new Vector3D(1.0, center, 1.0, rotation.applyTo(delta)); + public Coordinates3D apply(final Point<Euclidean3D> point) { + final Coordinates3D delta = ((Coordinates3D) point).subtract(center); + return new Coordinates3D(1.0, center, 1.0, rotation.applyTo(delta)); } /** {@inheritDoc} */ @@ -588,12 +588,12 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; - final Vector3D p00 = oPlane.getOrigin(); - final Vector3D p10 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(1.0, 0.0)); - final Vector3D p01 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(0.0, 1.0)); - final Vector2D tP00 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00)); - final Vector2D tP10 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10)); - final Vector2D tP01 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01)); + final Coordinates3D p00 = oPlane.getOrigin(); + final Coordinates3D p10 = oPlane.toSpace((Point<Euclidean2D>) new Coordinates2D(1.0, 0.0)); + final Coordinates3D p01 = oPlane.toSpace((Point<Euclidean2D>) new Coordinates2D(0.0, 1.0)); + final Coordinates2D tP00 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00)); + final Coordinates2D tP10 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10)); + final Coordinates2D tP01 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01)); cachedOriginal = (Plane) original; cachedTransform = @@ -615,7 +615,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { * @param translation translation to apply * @return a new instance representing the translated region */ - public PolyhedronsSet translate(final Vector3D translation) { + public PolyhedronsSet translate(final Coordinates3D translation) { return (PolyhedronsSet) applyTransform(new TranslationTransform(translation)); } @@ -623,7 +623,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { private static class TranslationTransform implements Transform<Euclidean3D, Euclidean2D> { /** Translation vector. */ - private final Vector3D translation; + private final Coordinates3D translation; /** Cached original hyperplane. */ private Plane cachedOriginal; @@ -634,14 +634,14 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { /** Build a translation transform. * @param translation translation vector */ - TranslationTransform(final Vector3D translation) { + TranslationTransform(final Coordinates3D translation) { this.translation = translation; } /** {@inheritDoc} */ @Override - public Vector3D apply(final Point<Euclidean3D> point) { - return new Vector3D(1.0, (Vector3D) point, 1.0, translation); + public Coordinates3D apply(final Point<Euclidean3D> point) { + return new Coordinates3D(1.0, (Coordinates3D) point, 1.0, translation); } /** {@inheritDoc} */ @@ -660,7 +660,7 @@ public class PolyhedronsSet extends AbstractRegion<Euclidean3D, Euclidean2D> { final Plane oPlane = (Plane) original; final Plane tPlane = (Plane) transformed; - final Vector2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin())); + final Coordinates2D shift = tPlane.toSubSpace((Point<Euclidean3D>) apply(oPlane.getOrigin())); cachedOriginal = (Plane) original; cachedTransform =