You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ra...@apache.org on 2017/05/12 21:32:28 UTC
[19/31] [math] MATH-1284: Replace/rename Coordinate?D classes (nee
Vector?D) as Cartesian?D classes as per discussion. When there are existing
overridden methods accepting Vector and Point,
add a disambiguating method accepting
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
index 7df7277..36f0998 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Line.java
@@ -19,10 +19,11 @@ package org.apache.commons.math4.geometry.euclidean.twod;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
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.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.Embedding;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
@@ -84,7 +85,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public Line(final Coordinates2D p1, final Coordinates2D p2, final double tolerance) {
+ public Line(final Cartesian2D p1, final Cartesian2D p2, final double tolerance) {
reset(p1, p2);
this.tolerance = tolerance;
}
@@ -95,7 +96,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public Line(final Coordinates2D p, final double angle, final double tolerance) {
+ public Line(final Cartesian2D p, final double angle, final double tolerance) {
reset(p, angle);
this.tolerance = tolerance;
}
@@ -143,7 +144,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p1 first point
* @param p2 second point
*/
- public void reset(final Coordinates2D p1, final Coordinates2D p2) {
+ public void reset(final Cartesian2D p1, final Cartesian2D p2) {
unlinkReverse();
final double dx = p2.getX() - p1.getX();
final double dy = p2.getY() - p1.getY();
@@ -165,7 +166,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p point belonging to the line
* @param alpha angle of the line with respect to abscissa axis
*/
- public void reset(final Coordinates2D p, final double alpha) {
+ public void reset(final Cartesian2D p, final double alpha) {
unlinkReverse();
this.angle = MathUtils.normalizeAngle(alpha, FastMath.PI);
cos = FastMath.cos(this.angle);
@@ -225,31 +226,48 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return (n-1)-dimension point of the sub-space corresponding to
* the specified space point
*/
-// public Coordinates1D toSubSpace(Vector<Euclidean2D> vector) {
-// return toSubSpace((Point<Euclidean2D>) vector);
-// }
+ public Cartesian1D toSubSpace(Vector<Euclidean2D> vector) {
+ return toSubSpace((Cartesian2D) 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 Coordinates2D toSpace(Vector<Euclidean1D> vector) {
-// return toSpace((Point<Euclidean1D>) vector);
-// }
+ public Cartesian2D toSpace(Vector<Euclidean1D> vector) {
+ return toSpace((Cartesian1D) vector);
+ }
/** {@inheritDoc} */
@Override
- public Coordinates1D toSubSpace(final Point<Euclidean2D> point) {
- Coordinates2D p2 = (Coordinates2D) point;
- return new Coordinates1D(MathArrays.linearCombination(cos, p2.getX(), sin, p2.getY()));
+ public Cartesian1D toSubSpace(final Point<Euclidean2D> point) {
+ return toSubSpace((Cartesian2D) point);
}
/** {@inheritDoc} */
@Override
- public Coordinates2D toSpace(final Point<Euclidean1D> point) {
- final double abscissa = ((Coordinates1D) point).getX();
- return new Coordinates2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin),
+ public Cartesian2D toSpace(final Point<Euclidean1D> point) {
+ return toSpace((Cartesian1D) point);
+ }
+
+ /** Transform a space point into a sub-space point.
+ * @param cartesian n-dimension point of the space
+ * @return (n-1)-dimension point of the sub-space corresponding to
+ * the specified space point
+ */
+ public Cartesian1D toSubSpace(final Cartesian2D cartesian) {
+ return new Cartesian1D(MathArrays.linearCombination(cos, cartesian.getX(), sin, cartesian.getY()));
+ }
+
+ /** Transform a sub-space point into a space point.
+ * @param cartesian (n-1)-dimension point of the sub-space
+ * @return n-dimension point of the space corresponding to the
+ * specified sub-space point
+ */
+ public Cartesian2D toSpace(Cartesian1D cartesian) {
+ final double abscissa = cartesian.getX();
+ return new Cartesian2D(MathArrays.linearCombination(abscissa, cos, -originOffset, sin),
MathArrays.linearCombination(abscissa, sin, originOffset, cos));
}
@@ -258,12 +276,12 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return intersection point of the instance and the other line
* or null if there are no intersection points
*/
- public Coordinates2D intersection(final Line other) {
+ public Cartesian2D intersection(final Line other) {
final double d = MathArrays.linearCombination(sin, other.cos, -other.sin, cos);
if (FastMath.abs(d) < tolerance) {
return null;
}
- return new Coordinates2D(MathArrays.linearCombination(cos, other.originOffset, -other.cos, originOffset) / d,
+ return new Cartesian2D(MathArrays.linearCombination(cos, other.originOffset, -other.cos, originOffset) / d,
MathArrays.linearCombination(sin, other.originOffset, -other.sin, originOffset) / d);
}
@@ -317,15 +335,22 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param vector vector to check
* @return offset of the vector
*/
-// public double getOffset(Vector<Euclidean2D> vector) {
-// return getOffset((Point<Euclidean2D>) vector);
-// }
+ public double getOffset(Vector<Euclidean2D> vector) {
+ return getOffset((Cartesian2D) vector);
+ }
/** {@inheritDoc} */
@Override
public double getOffset(final Point<Euclidean2D> point) {
- Coordinates2D p2 = (Coordinates2D) point;
- return MathArrays.linearCombination(sin, p2.getX(), -cos, p2.getY(), 1.0, originOffset);
+ return getOffset((Cartesian2D) point);
+ }
+
+ /** Get the offset (oriented distance) of a point.
+ * @param cartesian point to check
+ * @return offset of the point
+ */
+ public double getOffset(Cartesian2D cartesian) {
+ return MathArrays.linearCombination(sin, cartesian.getX(), -cos, cartesian.getY(), 1.0, originOffset);
}
/** {@inheritDoc} */
@@ -341,10 +366,10 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return one point in the plane, with given abscissa and offset
* relative to the line
*/
- public Coordinates2D getPointAt(final Coordinates1D abscissa, final double offset) {
+ public Cartesian2D getPointAt(final Cartesian1D abscissa, final double offset) {
final double x = abscissa.getX();
final double dOffset = offset - originOffset;
- return new Coordinates2D(MathArrays.linearCombination(x, cos, dOffset, sin),
+ return new Cartesian2D(MathArrays.linearCombination(x, cos, dOffset, sin),
MathArrays.linearCombination(x, sin, -dOffset, cos));
}
@@ -352,7 +377,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param p point to check
* @return true if p belongs to the line
*/
- public boolean contains(final Coordinates2D p) {
+ public boolean contains(final Cartesian2D p) {
return FastMath.abs(getOffset(p)) < tolerance;
}
@@ -365,7 +390,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @return distance between the instance and the point
* @since 3.1
*/
- public double distance(final Coordinates2D p) {
+ public double distance(final Cartesian2D p) {
return FastMath.abs(getOffset(p));
}
@@ -381,7 +406,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** Translate the line to force it passing by a point.
* @param p point by which the line should pass
*/
- public void translateToPoint(final Coordinates2D p) {
+ public void translateToPoint(final Cartesian2D p) {
originOffset = MathArrays.linearCombination(cos, p.getY(), -sin, p.getX());
}
@@ -426,7 +451,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
* @param cX1 transform addendum for output abscissa
* @param cY1 transform addendum for output ordinate
* @return a new transform that can be applied to either {@link
- * Coordinates2D Vector2D}, {@link Line Line} or {@link
+ * Cartesian2D}, {@link Line Line} or {@link
* org.apache.commons.math4.geometry.partitioning.SubHyperplane
* SubHyperplane} instances
* @exception MathIllegalArgumentException if the transform is non invertible
@@ -511,11 +536,11 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
/** {@inheritDoc} */
@Override
- public Coordinates2D apply(final Point<Euclidean2D> point) {
- final Coordinates2D p2D = (Coordinates2D) point;
+ public Cartesian2D apply(final Point<Euclidean2D> point) {
+ final Cartesian2D p2D = (Cartesian2D) point;
final double x = p2D.getX();
final double y = p2D.getY();
- return new Coordinates2D(MathArrays.linearCombination(cXX, x, cXY, y, cX1, 1),
+ return new Cartesian2D(MathArrays.linearCombination(cXX, x, cXY, y, cX1, 1),
MathArrays.linearCombination(cYX, x, cYY, y, cY1, 1));
}
@@ -540,7 +565,7 @@ public class Line implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D, Euc
final OrientedPoint op = (OrientedPoint) sub.getHyperplane();
final Line originalLine = (Line) original;
final Line transformedLine = (Line) transformed;
- final Coordinates1D newLoc =
+ final Cartesian1D newLoc =
transformedLine.toSubSpace(apply(originalLine.toSpace(op.getLocation())));
return new OrientedPoint(newLoc, op.isDirect(), originalLine.tolerance).wholeHyperplane();
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
index 5affbfc..3a5038e 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/NestedLoops.java
@@ -48,7 +48,7 @@ import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
class NestedLoops {
/** Boundary loop. */
- private Coordinates2D[] loop;
+ private Cartesian2D[] loop;
/** Surrounded loops. */
private List<NestedLoops> surrounded;
@@ -82,7 +82,7 @@ class NestedLoops {
* @exception MathIllegalArgumentException if an outline has an open boundary loop
* @since 3.3
*/
- private NestedLoops(final Coordinates2D[] loop, final double tolerance)
+ private NestedLoops(final Cartesian2D[] loop, final double tolerance)
throws MathIllegalArgumentException {
if (loop[0] == null) {
@@ -95,9 +95,9 @@ class NestedLoops {
// build the polygon defined by the loop
final ArrayList<SubHyperplane<Euclidean2D>> edges = new ArrayList<>();
- Coordinates2D current = loop[loop.length - 1];
+ Cartesian2D current = loop[loop.length - 1];
for (int i = 0; i < loop.length; ++i) {
- final Coordinates2D previous = current;
+ final Cartesian2D previous = current;
current = loop[i];
final Line line = new Line(previous, current, tolerance);
final IntervalsSet region =
@@ -123,7 +123,7 @@ class NestedLoops {
* @exception MathIllegalArgumentException if an outline has crossing
* boundary loops or open boundary loops
*/
- public void add(final Coordinates2D[] bLoop) throws MathIllegalArgumentException {
+ public void add(final Cartesian2D[] bLoop) throws MathIllegalArgumentException {
add(new NestedLoops(bLoop, tolerance));
}
@@ -185,7 +185,7 @@ class NestedLoops {
int min = -1;
int max = loop.length;
while (++min < --max) {
- final Coordinates2D tmp = loop[min];
+ final Cartesian2D tmp = loop[min];
loop[min] = loop[max];
loop[max] = tmp;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
index eb2d66a..87e81bc 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/PolygonsSet.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.AbstractRegion;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
@@ -42,7 +42,7 @@ import org.apache.commons.math4.util.Precision;
public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Vertices organized as boundary loops. */
- private Coordinates2D[][] vertices;
+ private Cartesian2D[][] vertices;
/** Build a polygons set representing the whole plane.
* @param tolerance tolerance below which points are considered identical
@@ -147,7 +147,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* belong to the hyperplane (which is therefore more a slab)
* @param vertices vertices of the simple loop boundary
*/
- public PolygonsSet(final double hyperplaneThickness, final Coordinates2D ... vertices) {
+ public PolygonsSet(final double hyperplaneThickness, final Cartesian2D ... vertices) {
super(verticesToTree(hyperplaneThickness, vertices), hyperplaneThickness);
}
@@ -166,10 +166,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
// too thin box, build an empty polygons set
return null;
}
- final Coordinates2D minMin = new Coordinates2D(xMin, yMin);
- final Coordinates2D minMax = new Coordinates2D(xMin, yMax);
- final Coordinates2D maxMin = new Coordinates2D(xMax, yMin);
- final Coordinates2D maxMax = new Coordinates2D(xMax, yMax);
+ final Cartesian2D minMin = new Cartesian2D(xMin, yMin);
+ final Cartesian2D minMax = new Cartesian2D(xMin, yMax);
+ final Cartesian2D maxMin = new Cartesian2D(xMax, yMin);
+ final Cartesian2D maxMax = new Cartesian2D(xMax, yMax);
return new Line[] {
new Line(minMin, maxMin, tolerance),
new Line(maxMin, maxMax, tolerance),
@@ -194,7 +194,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @return the BSP tree of the input vertices
*/
private static BSPTree<Euclidean2D> verticesToTree(final double hyperplaneThickness,
- final Coordinates2D ... vertices) {
+ final Cartesian2D ... vertices) {
final int n = vertices.length;
if (n == 0) {
@@ -347,7 +347,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
private static class Vertex {
/** Vertex location. */
- private final Coordinates2D location;
+ private final Cartesian2D location;
/** Incoming edge. */
private Edge incoming;
@@ -361,7 +361,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Build a non-processed vertex not owned by any node yet.
* @param location vertex location
*/
- Vertex(final Coordinates2D location) {
+ Vertex(final Cartesian2D location) {
this.location = location;
this.incoming = null;
this.outgoing = null;
@@ -371,7 +371,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
/** Get Vertex location.
* @return vertex location
*/
- public Coordinates2D getLocation() {
+ public Cartesian2D getLocation() {
return location;
}
@@ -543,22 +543,22 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
@Override
protected void computeGeometricalProperties() {
- final Coordinates2D[][] v = getVertices();
+ final Cartesian2D[][] v = getVertices();
if (v.length == 0) {
final BSPTree<Euclidean2D> tree = getTree(false);
if (tree.getCut() == null && (Boolean) tree.getAttribute()) {
// the instance covers the whole space
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
setSize(0);
- setBarycenter((Point<Euclidean2D>) new Coordinates2D(0, 0));
+ setBarycenter((Point<Euclidean2D>) new Cartesian2D(0, 0));
}
} else if (v[0][0] == null) {
// there is at least one open-loop: the polygon is infinite
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
// all loops are closed, we compute some integrals around the shape
@@ -566,10 +566,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
double sumX = 0;
double sumY = 0;
- for (Coordinates2D[] loop : v) {
+ for (Cartesian2D[] loop : v) {
double x1 = loop[loop.length - 1].getX();
double y1 = loop[loop.length - 1].getY();
- for (final Coordinates2D point : loop) {
+ for (final Cartesian2D point : loop) {
final double x0 = x1;
final double y0 = y1;
x1 = point.getX();
@@ -584,10 +584,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
if (sum < 0) {
// the polygon as a finite outside surrounded by an infinite inside
setSize(Double.POSITIVE_INFINITY);
- setBarycenter((Point<Euclidean2D>) Coordinates2D.NaN);
+ setBarycenter((Point<Euclidean2D>) Cartesian2D.NaN);
} else {
setSize(sum / 2);
- setBarycenter((Point<Euclidean2D>) new Coordinates2D(sumX / (3 * sum), sumY / (3 * sum)));
+ setBarycenter((Point<Euclidean2D>) new Cartesian2D(sumX / (3 * sum), sumY / (3 * sum)));
}
}
@@ -617,10 +617,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* loops with the open loops first (the returned value is guaranteed
* to be non-null)
*/
- public Coordinates2D[][] getVertices() {
+ public Cartesian2D[][] getVertices() {
if (vertices == null) {
if (getTree(false).getCut() == null) {
- vertices = new Coordinates2D[0][];
+ vertices = new Cartesian2D[0][];
} else {
// build the unconnected segments
@@ -655,7 +655,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
}
// transform the loops in an array of arrays of points
- vertices = new Coordinates2D[loops.size()][];
+ vertices = new Cartesian2D[loops.size()][];
int i = 0;
for (final List<Segment> loop : loops) {
@@ -663,23 +663,23 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
(loop.size() == 2 && loop.get(0).getStart() == null && loop.get(1).getEnd() == null)) {
// single infinite line
final Line line = loop.get(0).getLine();
- vertices[i++] = new Coordinates2D[] {
+ vertices[i++] = new Cartesian2D[] {
null,
- line.toSpace((Point<Euclidean1D>) new Coordinates1D(-Float.MAX_VALUE)),
- line.toSpace((Point<Euclidean1D>) new Coordinates1D(+Float.MAX_VALUE))
+ line.toSpace(new Cartesian1D(-Float.MAX_VALUE)),
+ line.toSpace(new Cartesian1D(+Float.MAX_VALUE))
};
} else if (loop.get(0).getStart() == null) {
// open loop with at least one real point
- final Coordinates2D[] array = new Coordinates2D[loop.size() + 2];
+ final Cartesian2D[] array = new Cartesian2D[loop.size() + 2];
int j = 0;
for (Segment segment : loop) {
if (j == 0) {
// null point and first dummy point
- double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getEnd()).getX();
+ double x = segment.getLine().toSubSpace(segment.getEnd()).getX();
x -= FastMath.max(1.0, FastMath.abs(x / 2));
array[j++] = null;
- array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Coordinates1D(x));
+ array[j++] = segment.getLine().toSpace(new Cartesian1D(x));
}
if (j < (array.length - 1)) {
@@ -689,15 +689,15 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
if (j == (array.length - 1)) {
// last dummy point
- double x = segment.getLine().toSubSpace((Point<Euclidean2D>) segment.getStart()).getX();
+ double x = segment.getLine().toSubSpace(segment.getStart()).getX();
x += FastMath.max(1.0, FastMath.abs(x / 2));
- array[j++] = segment.getLine().toSpace((Point<Euclidean1D>) new Coordinates1D(x));
+ array[j++] = segment.getLine().toSpace(new Cartesian1D(x));
}
}
vertices[i++] = array;
} else {
- final Coordinates2D[] array = new Coordinates2D[loop.size()];
+ final Cartesian2D[] array = new Cartesian2D[loop.size()];
int j = 0;
for (Segment segment : loop) {
array[j++] = segment.getStart();
@@ -777,12 +777,12 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
int connected = 0;
for (final ConnectableSegment segment : segments) {
if (segment.getNext() == null && segment.getEnd() != null) {
- final Coordinates2D end = segment.getEnd();
+ final Cartesian2D end = segment.getEnd();
ConnectableSegment selectedNext = null;
double min = Double.POSITIVE_INFINITY;
for (final ConnectableSegment candidateNext : segments) {
if (candidateNext.getPrevious() == null && candidateNext.getStart() != null) {
- final double distance = Coordinates2D.distance(end, candidateNext.getStart());
+ final double distance = Cartesian2D.distance(end, candidateNext.getStart());
if (distance < min) {
selectedNext = candidateNext;
min = distance;
@@ -906,7 +906,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @param startNode node whose intersection with current node defines start point
* @param endNode node whose intersection with current node defines end point
*/
- ConnectableSegment(final Coordinates2D start, final Coordinates2D end, final Line line,
+ ConnectableSegment(final Cartesian2D start, final Cartesian2D end, final Line line,
final BSPTree<Euclidean2D> node,
final BSPTree<Euclidean2D> startNode,
final BSPTree<Euclidean2D> endNode) {
@@ -1044,10 +1044,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
for (final Interval i : intervals) {
// find the 2D points
- final Coordinates2D startV = Double.isInfinite(i.getInf()) ?
- null : (Coordinates2D) line.toSpace((Point<Euclidean1D>) new Coordinates1D(i.getInf()));
- final Coordinates2D endV = Double.isInfinite(i.getSup()) ?
- null : (Coordinates2D) line.toSpace((Point<Euclidean1D>) new Coordinates1D(i.getSup()));
+ final Cartesian2D startV = Double.isInfinite(i.getInf()) ?
+ null : line.toSpace(new Cartesian1D(i.getInf()));
+ final Cartesian2D endV = Double.isInfinite(i.getSup()) ?
+ null : line.toSpace(new Cartesian1D(i.getSup()));
// recover the connectivity information
final BSPTree<Euclidean2D> startN = selectClosest(startV, splitters);
@@ -1069,7 +1069,7 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
* @param candidates candidate nodes
* @return node closest to point, or null if no node is closer than tolerance
*/
- private BSPTree<Euclidean2D> selectClosest(final Coordinates2D point, final Iterable<BSPTree<Euclidean2D>> candidates) {
+ private BSPTree<Euclidean2D> selectClosest(final Cartesian2D point, final Iterable<BSPTree<Euclidean2D>> candidates) {
BSPTree<Euclidean2D> selected = null;
double min = Double.POSITIVE_INFINITY;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
index 2e48541..70ce579 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Segment.java
@@ -25,10 +25,10 @@ import org.apache.commons.math4.util.FastMath;
public class Segment {
/** Start point of the segment. */
- private final Coordinates2D start;
+ private final Cartesian2D start;
/** End point of the segment. */
- private final Coordinates2D end;
+ private final Cartesian2D end;
/** Line containing the segment. */
private final Line line;
@@ -38,7 +38,7 @@ public class Segment {
* @param end end point of the segment
* @param line line containing the segment
*/
- public Segment(final Coordinates2D start, final Coordinates2D end, final Line line) {
+ public Segment(final Cartesian2D start, final Cartesian2D end, final Line line) {
this.start = start;
this.end = end;
this.line = line;
@@ -47,14 +47,14 @@ public class Segment {
/** Get the start point of the segment.
* @return start point of the segment
*/
- public Coordinates2D getStart() {
+ public Cartesian2D getStart() {
return start;
}
/** Get the end point of the segment.
* @return end point of the segment
*/
- public Coordinates2D getEnd() {
+ public Cartesian2D getEnd() {
return end;
}
@@ -80,7 +80,7 @@ public class Segment {
* @return distance between the instance and the point
* @since 3.1
*/
- public double distance(final Coordinates2D p) {
+ public double distance(final Cartesian2D p) {
final double deltaX = end.getX() - start.getX();
final double deltaY = end.getY() - start.getY();
@@ -105,7 +105,7 @@ public class Segment {
final double px = start.getX() + r * deltaX;
final double py = start.getY() + r * deltaY;
- final Coordinates2D interPt = new Coordinates2D(px, py);
+ final Cartesian2D interPt = new Cartesian2D(px, py);
return interPt.distance((Point<Euclidean2D>) p);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
index c7c0530..ae66659 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/SubLine.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.euclidean.oned.Euclidean1D;
import org.apache.commons.math4.geometry.euclidean.oned.Interval;
import org.apache.commons.math4.geometry.euclidean.oned.IntervalsSet;
import org.apache.commons.math4.geometry.euclidean.oned.OrientedPoint;
-import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Cartesian1D;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
@@ -53,7 +53,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* @param tolerance tolerance below which points are considered identical
* @since 3.3
*/
- public SubLine(final Coordinates2D start, final Coordinates2D end, final double tolerance) {
+ public SubLine(final Cartesian2D start, final Cartesian2D end, final double tolerance) {
super(new Line(start, end, tolerance), buildIntervalSet(start, end, tolerance));
}
@@ -86,8 +86,8 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
final List<Segment> segments = new ArrayList<>(list.size());
for (final Interval interval : list) {
- final Coordinates2D start = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getInf()));
- final Coordinates2D end = line.toSpace((Point<Euclidean1D>) new Coordinates1D(interval.getSup()));
+ final Cartesian2D start = line.toSpace(new Cartesian1D(interval.getInf()));
+ final Cartesian2D end = line.toSpace(new Cartesian1D(interval.getSup()));
segments.add(new Segment(start, end, line));
}
@@ -109,14 +109,14 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* occurring on endpoints lead to null being returned
* @return the intersection point if there is one, null if the sub-lines don't intersect
*/
- public Coordinates2D intersection(final SubLine subLine, final boolean includeEndPoints) {
+ public Cartesian2D intersection(final SubLine subLine, final boolean includeEndPoints) {
// retrieve the underlying lines
Line line1 = (Line) getHyperplane();
Line line2 = (Line) subLine.getHyperplane();
// compute the intersection on infinite line
- Coordinates2D v2D = line1.intersection(line2);
+ Cartesian2D v2D = line1.intersection(line2);
if (v2D == null) {
return null;
}
@@ -141,7 +141,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
* @param tolerance tolerance below which points are considered identical
* @return an interval set
*/
- private static IntervalsSet buildIntervalSet(final Coordinates2D start, final Coordinates2D end, final double tolerance) {
+ private static IntervalsSet buildIntervalSet(final Cartesian2D start, final Cartesian2D end, final double tolerance) {
final Line line = new Line(start, end, tolerance);
return new IntervalsSet(line.toSubSpace(start).getX(),
line.toSubSpace(end).getX(),
@@ -161,7 +161,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
final Line thisLine = (Line) getHyperplane();
final Line otherLine = (Line) hyperplane;
- final Coordinates2D crossing = thisLine.intersection(otherLine);
+ final Cartesian2D crossing = thisLine.intersection(otherLine);
final double tolerance = thisLine.getTolerance();
if (crossing == null) {
@@ -178,7 +178,7 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
// the lines do intersect
final boolean direct = FastMath.sin(thisLine.getAngle() - otherLine.getAngle()) < 0;
- final Coordinates1D x = thisLine.toSubSpace((Point<Euclidean2D>) crossing);
+ final Cartesian1D x = thisLine.toSubSpace(crossing);
final SubHyperplane<Euclidean1D> subPlus =
new OrientedPoint(x, !direct, tolerance).wholeHyperplane();
final SubHyperplane<Euclidean1D> subMinus =
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
index 04e825b..936450a 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/Vector2DFormat.java
@@ -108,31 +108,31 @@ public class Vector2DFormat extends VectorFormat<Euclidean2D> {
@Override
public StringBuffer format(final Vector<Euclidean2D> vector, final StringBuffer toAppendTo,
final FieldPosition pos) {
- final Coordinates2D p2 = (Coordinates2D) vector;
+ final Cartesian2D p2 = (Cartesian2D) vector;
return format(toAppendTo, pos, p2.getX(), p2.getY());
}
/** {@inheritDoc} */
@Override
- public Coordinates2D parse(final String source) throws MathParseException {
+ public Cartesian2D parse(final String source) throws MathParseException {
ParsePosition parsePosition = new ParsePosition(0);
- Coordinates2D result = parse(source, parsePosition);
+ Cartesian2D result = parse(source, parsePosition);
if (parsePosition.getIndex() == 0) {
throw new MathParseException(source,
parsePosition.getErrorIndex(),
- Coordinates2D.class);
+ Cartesian2D.class);
}
return result;
}
/** {@inheritDoc} */
@Override
- public Coordinates2D parse(final String source, final ParsePosition pos) {
+ public Cartesian2D parse(final String source, final ParsePosition pos) {
final double[] coordinates = parseCoordinates(2, source, pos);
if (coordinates == null) {
return null;
}
- return new Coordinates2D(coordinates[0], coordinates[1]);
+ return new Cartesian2D(coordinates[0], coordinates[1]);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
index 38b5b4a..d3ecc64 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AbstractConvexHullGenerator2D.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import org.apache.commons.math4.exception.ConvergenceException;
import org.apache.commons.math4.exception.MathIllegalArgumentException;
import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.MathUtils;
/**
@@ -86,12 +86,12 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
/** {@inheritDoc} */
@Override
- public ConvexHull2D generate(final Collection<Coordinates2D> points)
+ public ConvexHull2D generate(final Collection<Cartesian2D> points)
throws NullArgumentException, ConvergenceException {
// check for null points
MathUtils.checkNotNull(points);
- Collection<Coordinates2D> hullVertices = null;
+ Collection<Cartesian2D> hullVertices = null;
if (points.size() < 2) {
hullVertices = points;
} else {
@@ -99,7 +99,7 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
}
try {
- return new ConvexHull2D(hullVertices.toArray(new Coordinates2D[hullVertices.size()]),
+ return new ConvexHull2D(hullVertices.toArray(new Cartesian2D[hullVertices.size()]),
tolerance);
} catch (MathIllegalArgumentException e) {
// the hull vertices may not form a convex hull if the tolerance value is to large
@@ -112,6 +112,6 @@ abstract class AbstractConvexHullGenerator2D implements ConvexHullGenerator2D {
* @param points the set of input points
* @return the convex hull vertices in CCW winding
*/
- protected abstract Collection<Coordinates2D> findHullVertices(Collection<Coordinates2D> points);
+ protected abstract Collection<Cartesian2D> findHullVertices(Collection<Cartesian2D> points);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
index 49c399f..e1d5009 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/AklToussaintHeuristic.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
/**
* A simple heuristic to improve the performance of convex hull algorithms.
@@ -50,15 +50,15 @@ public final class AklToussaintHeuristic {
* @param points the original point set
* @return a reduced point set, useful as input for convex hull algorithms
*/
- public static Collection<Coordinates2D> reducePoints(final Collection<Coordinates2D> points) {
+ public static Collection<Cartesian2D> reducePoints(final Collection<Cartesian2D> points) {
// find the leftmost point
int size = 0;
- Coordinates2D minX = null;
- Coordinates2D maxX = null;
- Coordinates2D minY = null;
- Coordinates2D maxY = null;
- for (Coordinates2D p : points) {
+ Cartesian2D minX = null;
+ Cartesian2D maxX = null;
+ Cartesian2D minY = null;
+ Cartesian2D maxY = null;
+ for (Cartesian2D p : points) {
if (minX == null || p.getX() < minX.getX()) {
minX = p;
}
@@ -78,14 +78,14 @@ public final class AklToussaintHeuristic {
return points;
}
- final List<Coordinates2D> quadrilateral = buildQuadrilateral(minY, maxX, maxY, minX);
+ final List<Cartesian2D> quadrilateral = buildQuadrilateral(minY, maxX, maxY, minX);
// if the quadrilateral is not well formed, e.g. only 2 points, do not attempt to reduce
if (quadrilateral.size() < 3) {
return points;
}
- final List<Coordinates2D> reducedPoints = new ArrayList<>(quadrilateral);
- for (final Coordinates2D p : points) {
+ final List<Cartesian2D> reducedPoints = new ArrayList<>(quadrilateral);
+ for (final Cartesian2D p : points) {
// check all points if they are within the quadrilateral
// in which case they can not be part of the convex hull
if (!insideQuadrilateral(p, quadrilateral)) {
@@ -102,9 +102,9 @@ public final class AklToussaintHeuristic {
* @param points the respective points with min/max x/y coordinate
* @return the quadrilateral
*/
- private static List<Coordinates2D> buildQuadrilateral(final Coordinates2D... points) {
- List<Coordinates2D> quadrilateral = new ArrayList<>();
- for (Coordinates2D p : points) {
+ private static List<Cartesian2D> buildQuadrilateral(final Cartesian2D... points) {
+ List<Cartesian2D> quadrilateral = new ArrayList<>();
+ for (Cartesian2D p : points) {
if (!quadrilateral.contains(p)) {
quadrilateral.add(p);
}
@@ -118,11 +118,11 @@ public final class AklToussaintHeuristic {
* @param quadrilateralPoints the convex quadrilateral, represented by 4 points
* @return {@code true} if the point is inside the quadrilateral, {@code false} otherwise
*/
- private static boolean insideQuadrilateral(final Coordinates2D point,
- final List<Coordinates2D> quadrilateralPoints) {
+ private static boolean insideQuadrilateral(final Cartesian2D point,
+ final List<Cartesian2D> quadrilateralPoints) {
- Coordinates2D p1 = quadrilateralPoints.get(0);
- Coordinates2D p2 = quadrilateralPoints.get(1);
+ Cartesian2D p1 = quadrilateralPoints.get(0);
+ Cartesian2D p2 = quadrilateralPoints.get(1);
if (point.equals(p1) || point.equals(p2)) {
return true;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
index 801f4d7..425cd67 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHull2D.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.exception.util.LocalizedFormats;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
import org.apache.commons.math4.geometry.euclidean.twod.Segment;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.hull.ConvexHull;
import org.apache.commons.math4.geometry.partitioning.Region;
import org.apache.commons.math4.geometry.partitioning.RegionFactory;
@@ -36,13 +36,13 @@ import org.apache.commons.math4.util.Precision;
*
* @since 3.3
*/
-public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Serializable {
+public class ConvexHull2D implements ConvexHull<Euclidean2D, Cartesian2D>, Serializable {
/** Serializable UID. */
private static final long serialVersionUID = 20140129L;
/** Vertices of the hull. */
- private final Coordinates2D[] vertices;
+ private final Cartesian2D[] vertices;
/** Tolerance threshold used during creation of the hull vertices. */
private final double tolerance;
@@ -59,7 +59,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
* @param tolerance tolerance below which points are considered identical
* @throws MathIllegalArgumentException if the vertices do not form a convex hull
*/
- public ConvexHull2D(final Coordinates2D[] vertices, final double tolerance)
+ public ConvexHull2D(final Cartesian2D[] vertices, final double tolerance)
throws MathIllegalArgumentException {
// assign tolerance as it will be used by the isConvex method
@@ -77,19 +77,19 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
* @param hullVertices the hull vertices
* @return {@code true} if the vertices form a convex hull, {@code false} otherwise
*/
- private boolean isConvex(final Coordinates2D[] hullVertices) {
+ private boolean isConvex(final Cartesian2D[] hullVertices) {
if (hullVertices.length < 3) {
return true;
}
int sign = 0;
for (int i = 0; i < hullVertices.length; i++) {
- final Coordinates2D p1 = hullVertices[i == 0 ? hullVertices.length - 1 : i - 1];
- final Coordinates2D p2 = hullVertices[i];
- final Coordinates2D p3 = hullVertices[i == hullVertices.length - 1 ? 0 : i + 1];
+ final Cartesian2D p1 = hullVertices[i == 0 ? hullVertices.length - 1 : i - 1];
+ final Cartesian2D p2 = hullVertices[i];
+ final Cartesian2D p3 = hullVertices[i == hullVertices.length - 1 ? 0 : i + 1];
- final Coordinates2D d1 = p2.subtract(p1);
- final Coordinates2D d2 = p3.subtract(p2);
+ final Cartesian2D d1 = p2.subtract(p1);
+ final Cartesian2D d2 = p3.subtract(p2);
final double crossProduct = MathArrays.linearCombination(d1.getX(), d2.getY(), -d1.getY(), d2.getX());
final int cmp = Precision.compareTo(crossProduct, 0.0, tolerance);
@@ -107,7 +107,7 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
/** {@inheritDoc} */
@Override
- public Coordinates2D[] getVertices() {
+ public Cartesian2D[] getVertices() {
return vertices.clone();
}
@@ -132,15 +132,15 @@ public class ConvexHull2D implements ConvexHull<Euclidean2D, Coordinates2D>, Ser
this.lineSegments = new Segment[0];
} else if (size == 2) {
this.lineSegments = new Segment[1];
- final Coordinates2D p1 = vertices[0];
- final Coordinates2D p2 = vertices[1];
+ final Cartesian2D p1 = vertices[0];
+ final Cartesian2D p2 = vertices[1];
this.lineSegments[0] = new Segment(p1, p2, new Line(p1, p2, tolerance));
} else {
this.lineSegments = new Segment[size];
- Coordinates2D firstPoint = null;
- Coordinates2D lastPoint = null;
+ Cartesian2D firstPoint = null;
+ Cartesian2D lastPoint = null;
int index = 0;
- for (Coordinates2D point : vertices) {
+ for (Cartesian2D point : vertices) {
if (lastPoint == null) {
firstPoint = point;
lastPoint = point;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
index 310cb0d..0c49b91 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/ConvexHullGenerator2D.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import org.apache.commons.math4.exception.ConvergenceException;
import org.apache.commons.math4.exception.NullArgumentException;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.geometry.hull.ConvexHullGenerator;
/**
@@ -29,10 +29,10 @@ import org.apache.commons.math4.geometry.hull.ConvexHullGenerator;
*
* @since 3.3
*/
-public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Coordinates2D> {
+public interface ConvexHullGenerator2D extends ConvexHullGenerator<Euclidean2D, Cartesian2D> {
/** {@inheritDoc} */
@Override
- ConvexHull2D generate(Collection<Coordinates2D> points) throws NullArgumentException, ConvergenceException;
+ ConvexHull2D generate(Collection<Cartesian2D> points) throws NullArgumentException, ConvergenceException;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
index 08d27f8..42cbc33 100644
--- a/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
+++ b/src/main/java/org/apache/commons/math4/geometry/euclidean/twod/hull/MonotoneChain.java
@@ -23,7 +23,7 @@ import java.util.Comparator;
import java.util.List;
import org.apache.commons.math4.geometry.euclidean.twod.Line;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
@@ -75,15 +75,15 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
/** {@inheritDoc} */
@Override
- public Collection<Coordinates2D> findHullVertices(final Collection<Coordinates2D> points) {
+ public Collection<Cartesian2D> findHullVertices(final Collection<Cartesian2D> points) {
- final List<Coordinates2D> pointsSortedByXAxis = new ArrayList<>(points);
+ final List<Cartesian2D> pointsSortedByXAxis = new ArrayList<>(points);
// sort the points in increasing order on the x-axis
- Collections.sort(pointsSortedByXAxis, new Comparator<Coordinates2D>() {
+ Collections.sort(pointsSortedByXAxis, new Comparator<Cartesian2D>() {
/** {@inheritDoc} */
@Override
- public int compare(final Coordinates2D o1, final Coordinates2D o2) {
+ public int compare(final Cartesian2D o1, final Cartesian2D o2) {
final double tolerance = getTolerance();
// need to take the tolerance value into account, otherwise collinear points
// will not be handled correctly when building the upper/lower hull
@@ -97,21 +97,21 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
});
// build lower hull
- final List<Coordinates2D> lowerHull = new ArrayList<>();
- for (Coordinates2D p : pointsSortedByXAxis) {
+ final List<Cartesian2D> lowerHull = new ArrayList<>();
+ for (Cartesian2D p : pointsSortedByXAxis) {
updateHull(p, lowerHull);
}
// build upper hull
- final List<Coordinates2D> upperHull = new ArrayList<>();
+ final List<Cartesian2D> upperHull = new ArrayList<>();
for (int idx = pointsSortedByXAxis.size() - 1; idx >= 0; idx--) {
- final Coordinates2D p = pointsSortedByXAxis.get(idx);
+ final Cartesian2D p = pointsSortedByXAxis.get(idx);
updateHull(p, upperHull);
}
// concatenate the lower and upper hulls
// the last point of each list is omitted as it is repeated at the beginning of the other list
- final List<Coordinates2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2);
+ final List<Cartesian2D> hullVertices = new ArrayList<>(lowerHull.size() + upperHull.size() - 2);
for (int idx = 0; idx < lowerHull.size() - 1; idx++) {
hullVertices.add(lowerHull.get(idx));
}
@@ -133,12 +133,12 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
* @param point the current point
* @param hull the partial hull
*/
- private void updateHull(final Coordinates2D point, final List<Coordinates2D> hull) {
+ private void updateHull(final Cartesian2D point, final List<Cartesian2D> hull) {
final double tolerance = getTolerance();
if (hull.size() == 1) {
// ensure that we do not add an identical point
- final Coordinates2D p1 = hull.get(0);
+ final Cartesian2D p1 = hull.get(0);
if (p1.distance(point) < tolerance) {
return;
}
@@ -146,8 +146,8 @@ public class MonotoneChain extends AbstractConvexHullGenerator2D {
while (hull.size() >= 2) {
final int size = hull.size();
- final Coordinates2D p1 = hull.get(size - 2);
- final Coordinates2D p2 = hull.get(size - 1);
+ final Cartesian2D p1 = hull.get(size - 2);
+ final Cartesian2D p2 = hull.get(size - 1);
final double offset = new Line(p1, p2, tolerance).getOffset(point);
if (FastMath.abs(offset) < tolerance) {
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
index 841d1db..d57d02c 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/oned/S1Point.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.oned;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Cartesian2D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -30,7 +30,7 @@ public class S1Point implements Point<Sphere1D> {
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final S1Point NaN = new S1Point(Double.NaN, Coordinates2D.NaN);
+ public static final S1Point NaN = new S1Point(Double.NaN, Cartesian2D.NaN);
// CHECKSTYLE: resume ConstantName
/** Serializable UID. */
@@ -40,7 +40,7 @@ public class S1Point implements Point<Sphere1D> {
private final double alpha;
/** Corresponding 2D normalized vector. */
- private final Coordinates2D vector;
+ private final Cartesian2D vector;
/** Simple constructor.
* Build a vector from its coordinates
@@ -49,14 +49,14 @@ public class S1Point implements Point<Sphere1D> {
*/
public S1Point(final double alpha) {
this(MathUtils.normalizeAngle(alpha, FastMath.PI),
- new Coordinates2D(FastMath.cos(alpha), FastMath.sin(alpha)));
+ new Cartesian2D(FastMath.cos(alpha), FastMath.sin(alpha)));
}
/** Build a point from its internal components.
* @param alpha azimuthal angle \( \alpha \)
* @param vector corresponding vector
*/
- private S1Point(final double alpha, final Coordinates2D vector) {
+ private S1Point(final double alpha, final Cartesian2D vector) {
this.alpha = alpha;
this.vector = vector;
}
@@ -72,7 +72,7 @@ public class S1Point implements Point<Sphere1D> {
/** Get the corresponding normalized vector in the 2D euclidean space.
* @return normalized vector
*/
- public Coordinates2D getVector() {
+ public Cartesian2D getVector() {
return vector;
}
@@ -100,7 +100,7 @@ public class S1Point implements Point<Sphere1D> {
* @return the angular separation between p1 and p2
*/
public static double distance(S1Point p1, S1Point p2) {
- return Coordinates2D.angle(p1.vector, p2.vector);
+ return Cartesian2D.angle(p1.vector, p2.vector);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
index 871f729..ab8c2c5 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Circle.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.partitioning.Embedding;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.SubHyperplane;
@@ -45,13 +45,13 @@ import org.apache.commons.math4.util.FastMath;
public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1D> {
/** Pole or circle center. */
- private Coordinates3D pole;
+ private Cartesian3D pole;
/** First axis in the equator plane, origin of the phase angles. */
- private Coordinates3D x;
+ private Cartesian3D x;
/** Second axis in the equator plane, in quadrature with respect to x. */
- private Coordinates3D y;
+ private Cartesian3D y;
/** Tolerance below which close sub-arcs are merged together. */
private final double tolerance;
@@ -61,7 +61,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @param pole circle pole
* @param tolerance tolerance below which close sub-arcs are merged together
*/
- public Circle(final Coordinates3D pole, final double tolerance) {
+ public Circle(final Cartesian3D pole, final double tolerance) {
reset(pole);
this.tolerance = tolerance;
}
@@ -84,7 +84,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @param y second axis in the equator plane
* @param tolerance tolerance below which close sub-arcs are merged together
*/
- private Circle(final Coordinates3D pole, final Coordinates3D x, final Coordinates3D y,
+ private Circle(final Cartesian3D pole, final Cartesian3D x, final Cartesian3D y,
final double tolerance) {
this.pole = pole;
this.x = x;
@@ -111,10 +111,10 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* <p>The circle is oriented in the trigonometric direction around pole.</p>
* @param newPole circle pole
*/
- public void reset(final Coordinates3D newPole) {
+ public void reset(final Cartesian3D newPole) {
this.pole = newPole.normalize();
this.x = newPole.orthogonal();
- this.y = Coordinates3D.crossProduct(newPole, x).normalize();
+ this.y = Cartesian3D.crossProduct(newPole, x).normalize();
}
/** Revert the instance.
@@ -164,7 +164,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @return phase angle of the direction around the circle
* @see #toSubSpace(Point)
*/
- public double getPhase(final Coordinates3D direction) {
+ public double getPhase(final Cartesian3D direction) {
return FastMath.PI + FastMath.atan2(-direction.dotProduct(y), -direction.dotProduct(x));
}
@@ -183,8 +183,8 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getYAxis()
*/
- public Coordinates3D getPointAt(final double alpha) {
- return new Coordinates3D(FastMath.cos(alpha), x, FastMath.sin(alpha), y);
+ public Cartesian3D getPointAt(final double alpha) {
+ return new Cartesian3D(FastMath.cos(alpha), x, FastMath.sin(alpha), y);
}
/** Get the X axis of the circle.
@@ -198,7 +198,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getYAxis()
* @see #getPole()
*/
- public Coordinates3D getXAxis() {
+ public Cartesian3D getXAxis() {
return x;
}
@@ -213,7 +213,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getPole()
*/
- public Coordinates3D getYAxis() {
+ public Cartesian3D getYAxis() {
return y;
}
@@ -226,7 +226,7 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @see #getXAxis()
* @see #getYAxis()
*/
- public Coordinates3D getPole() {
+ public Cartesian3D getPole() {
return pole;
}
@@ -272,15 +272,15 @@ public class Circle implements Hyperplane<Sphere2D>, Embedding<Sphere2D, Sphere1
* @return offset of the direction
* @see #getOffset(Point)
*/
- public double getOffset(final Coordinates3D direction) {
- return Coordinates3D.angle(pole, direction) - 0.5 * FastMath.PI;
+ public double getOffset(final Cartesian3D direction) {
+ return Cartesian3D.angle(pole, direction) - 0.5 * FastMath.PI;
}
/** {@inheritDoc} */
@Override
public boolean sameOrientationAs(final Hyperplane<Sphere2D> other) {
final Circle otherC = (Circle) other;
- return Coordinates3D.dotProduct(pole, otherC.pole) >= 0.0;
+ return Cartesian3D.dotProduct(pole, otherC.pole) >= 0.0;
}
/** Get a {@link org.apache.commons.math4.geometry.partitioning.Transform
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
index 6fe2635..975407d 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/Edge.java
@@ -18,7 +18,7 @@ package org.apache.commons.math4.geometry.spherical.twod;
import java.util.List;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.spherical.oned.Arc;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -99,7 +99,7 @@ public class Edge {
* @param alpha angle along the edge, counted from {@link #getStart()}
* @return an intermediate point
*/
- public Coordinates3D getPointAt(final double alpha) {
+ public Cartesian3D getPointAt(final double alpha) {
return circle.getPointAt(alpha + circle.getPhase(start.getLocation().getVector()));
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
index 5e3f918..0c5d40f 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/EdgesBuilder.java
@@ -23,7 +23,7 @@ import java.util.Map;
import org.apache.commons.math4.exception.MathIllegalStateException;
import org.apache.commons.math4.exception.util.LocalizedFormats;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
import org.apache.commons.math4.geometry.partitioning.BoundaryAttribute;
@@ -128,8 +128,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
for (final BSPTree<Sphere2D> node : candidates) {
for (final Edge edge : nodeToEdgesList.get(node)) {
if (edge != previous && edge.getStart().getIncoming() == null) {
- final Coordinates3D edgeStart = edge.getStart().getLocation().getVector();
- final double gap = Coordinates3D.angle(point.getVector(), edgeStart);
+ final Cartesian3D edgeStart = edge.getStart().getLocation().getVector();
+ final double gap = Cartesian3D.angle(point.getVector(), edgeStart);
if (gap <= closest) {
closest = gap;
following = edge;
@@ -139,8 +139,8 @@ class EdgesBuilder implements BSPTreeVisitor<Sphere2D> {
}
if (following == null) {
- final Coordinates3D previousStart = previous.getStart().getLocation().getVector();
- if (Coordinates3D.angle(point.getVector(), previousStart) <= tolerance) {
+ final Cartesian3D previousStart = previous.getStart().getLocation().getVector();
+ if (Cartesian3D.angle(point.getVector(), previousStart) <= tolerance) {
// the edge connects back to itself
return previous;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
index 4d61de1..d6a4f27 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/PropertiesComputer.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.math4.exception.MathInternalError;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BSPTreeVisitor;
import org.apache.commons.math4.util.FastMath;
@@ -38,10 +38,10 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
private double summedArea;
/** Summed barycenter. */
- private Coordinates3D summedBarycenter;
+ private Cartesian3D summedBarycenter;
/** List of points strictly inside convex cells. */
- private final List<Coordinates3D> convexCellsInsidePoints;
+ private final List<Cartesian3D> convexCellsInsidePoints;
/** Simple constructor.
* @param tolerance below which points are consider to be identical
@@ -49,7 +49,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
PropertiesComputer(final double tolerance) {
this.tolerance = tolerance;
this.summedArea = 0;
- this.summedBarycenter = Coordinates3D.ZERO;
+ this.summedBarycenter = Cartesian3D.ZERO;
this.convexCellsInsidePoints = new ArrayList<>();
}
@@ -86,12 +86,12 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
// compute the geometrical properties of the convex cell
final double area = convexCellArea(boundary.get(0));
- final Coordinates3D barycenter = convexCellBarycenter(boundary.get(0));
+ final Cartesian3D barycenter = convexCellBarycenter(boundary.get(0));
convexCellsInsidePoints.add(barycenter);
// add the cell contribution to the global properties
summedArea += area;
- summedBarycenter = new Coordinates3D(1, summedBarycenter, area, barycenter);
+ summedBarycenter = new Cartesian3D(1, summedBarycenter, area, barycenter);
}
}
@@ -109,11 +109,11 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
// find path interior angle at vertex
- final Coordinates3D previousPole = e.getCircle().getPole();
- final Coordinates3D nextPole = e.getEnd().getOutgoing().getCircle().getPole();
- final Coordinates3D point = e.getEnd().getLocation().getVector();
- double alpha = FastMath.atan2(Coordinates3D.dotProduct(nextPole, Coordinates3D.crossProduct(point, previousPole)),
- -Coordinates3D.dotProduct(nextPole, previousPole));
+ final Cartesian3D previousPole = e.getCircle().getPole();
+ final Cartesian3D nextPole = e.getEnd().getOutgoing().getCircle().getPole();
+ final Cartesian3D point = e.getEnd().getLocation().getVector();
+ double alpha = FastMath.atan2(Cartesian3D.dotProduct(nextPole, Cartesian3D.crossProduct(point, previousPole)),
+ -Cartesian3D.dotProduct(nextPole, previousPole));
if (alpha < 0) {
alpha += MathUtils.TWO_PI;
}
@@ -133,14 +133,14 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
* @param start start vertex of the convex cell boundary
* @return barycenter
*/
- private Coordinates3D convexCellBarycenter(final Vertex start) {
+ private Cartesian3D convexCellBarycenter(final Vertex start) {
int n = 0;
- Coordinates3D sumB = Coordinates3D.ZERO;
+ Cartesian3D sumB = Cartesian3D.ZERO;
// loop around the cell
for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
- sumB = new Coordinates3D(1, sumB, e.getLength(), e.getCircle().getPole());
+ sumB = new Cartesian3D(1, sumB, e.getLength(), e.getCircle().getPole());
n++;
}
@@ -169,7 +169,7 @@ class PropertiesComputer implements BSPTreeVisitor<Sphere2D> {
/** Get the points strictly inside convex cells.
* @return points strictly inside convex cells
*/
- public List<Coordinates3D> getConvexCellsInsidePoints() {
+ public List<Cartesian3D> getConvexCellsInsidePoints() {
return convexCellsInsidePoints;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
index 58aea47..6931ac0 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/S2Point.java
@@ -20,7 +20,7 @@ import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.exception.OutOfRangeException;
import org.apache.commons.math4.geometry.Point;
import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.MathUtils;
@@ -38,26 +38,26 @@ import org.apache.commons.math4.util.MathUtils;
public class S2Point implements Point<Sphere2D> {
/** +I (coordinates: \( \theta = 0, \varphi = \pi/2 \)). */
- public static final S2Point PLUS_I = new S2Point(0, 0.5 * FastMath.PI, Coordinates3D.PLUS_I);
+ public static final S2Point PLUS_I = new S2Point(0, 0.5 * FastMath.PI, Cartesian3D.PLUS_I);
/** +J (coordinates: \( \theta = \pi/2, \varphi = \pi/2 \))). */
- public static final S2Point PLUS_J = new S2Point(0.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.PLUS_J);
+ public static final S2Point PLUS_J = new S2Point(0.5 * FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.PLUS_J);
/** +K (coordinates: \( \theta = any angle, \varphi = 0 \)). */
- public static final S2Point PLUS_K = new S2Point(0, 0, Coordinates3D.PLUS_K);
+ public static final S2Point PLUS_K = new S2Point(0, 0, Cartesian3D.PLUS_K);
/** -I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)). */
- public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.MINUS_I);
+ public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.MINUS_I);
/** -J (coordinates: \( \theta = 3\pi/2, \varphi = \pi/2 \)). */
- public static final S2Point MINUS_J = new S2Point(1.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.MINUS_J);
+ public static final S2Point MINUS_J = new S2Point(1.5 * FastMath.PI, 0.5 * FastMath.PI, Cartesian3D.MINUS_J);
/** -K (coordinates: \( \theta = any angle, \varphi = \pi \)). */
- public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Coordinates3D.MINUS_K);
+ public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Cartesian3D.MINUS_K);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Coordinates3D.NaN);
+ public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Cartesian3D.NaN);
// CHECKSTYLE: resume ConstantName
/** Serializable UID. */
@@ -70,7 +70,7 @@ public class S2Point implements Point<Sphere2D> {
private final double phi;
/** Corresponding 3D normalized vector. */
- private final Coordinates3D vector;
+ private final Cartesian3D vector;
/** Simple constructor.
* Build a vector from its spherical coordinates
@@ -90,8 +90,8 @@ public class S2Point implements Point<Sphere2D> {
* @param vector 3D vector
* @exception MathArithmeticException if vector norm is zero
*/
- public S2Point(final Coordinates3D vector) throws MathArithmeticException {
- this(FastMath.atan2(vector.getY(), vector.getX()), Coordinates3D.angle(Coordinates3D.PLUS_K, vector),
+ public S2Point(final Cartesian3D vector) throws MathArithmeticException {
+ this(FastMath.atan2(vector.getY(), vector.getX()), Cartesian3D.angle(Cartesian3D.PLUS_K, vector),
vector.normalize());
}
@@ -100,7 +100,7 @@ public class S2Point implements Point<Sphere2D> {
* @param phi polar angle \( \varphi \)
* @param vector corresponding vector
*/
- private S2Point(final double theta, final double phi, final Coordinates3D vector) {
+ private S2Point(final double theta, final double phi, final Cartesian3D vector) {
this.theta = theta;
this.phi = phi;
this.vector = vector;
@@ -112,7 +112,7 @@ public class S2Point implements Point<Sphere2D> {
* @return normalized vector
* @exception OutOfRangeException if \( \varphi \) is not in the [\( 0; \pi \)] range
*/
- private static Coordinates3D vector(final double theta, final double phi)
+ private static Cartesian3D vector(final double theta, final double phi)
throws OutOfRangeException {
if (phi < 0 || phi > FastMath.PI) {
@@ -124,7 +124,7 @@ public class S2Point implements Point<Sphere2D> {
final double cosPhi = FastMath.cos(phi);
final double sinPhi = FastMath.sin(phi);
- return new Coordinates3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
+ return new Cartesian3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
}
@@ -147,7 +147,7 @@ public class S2Point implements Point<Sphere2D> {
/** Get the corresponding normalized vector in the 3D euclidean space.
* @return normalized vector
*/
- public Coordinates3D getVector() {
+ public Cartesian3D getVector() {
return vector;
}
@@ -182,7 +182,7 @@ public class S2Point implements Point<Sphere2D> {
* @return the angular separation between p1 and p2
*/
public static double distance(S2Point p1, S2Point p2) {
- return Coordinates3D.angle(p1.vector, p2.vector);
+ return Cartesian3D.angle(p1.vector, p2.vector);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e21d4d43/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
index cbdf2d6..0f5d115 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SphericalPolygonsSet.java
@@ -29,7 +29,7 @@ import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D;
import org.apache.commons.math4.geometry.euclidean.threed.Rotation;
import org.apache.commons.math4.geometry.euclidean.threed.RotationConvention;
import org.apache.commons.math4.geometry.euclidean.threed.SphereGenerator;
-import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Cartesian3D;
import org.apache.commons.math4.geometry.partitioning.AbstractRegion;
import org.apache.commons.math4.geometry.partitioning.BSPTree;
import org.apache.commons.math4.geometry.partitioning.BoundaryProjection;
@@ -58,7 +58,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param pole pole of the hemisphere (the pole is in the inside half)
* @param tolerance below which points are consider to be identical
*/
- public SphericalPolygonsSet(final Coordinates3D pole, final double tolerance) {
+ public SphericalPolygonsSet(final Cartesian3D pole, final double tolerance) {
super(new BSPTree<>(new Circle(pole, tolerance).wholeHyperplane(),
new BSPTree<Sphere2D>(Boolean.FALSE),
new BSPTree<Sphere2D>(Boolean.TRUE),
@@ -73,7 +73,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param n number of sides of the polygon
* @param tolerance below which points are consider to be identical
*/
- public SphericalPolygonsSet(final Coordinates3D center, final Coordinates3D meridian,
+ public SphericalPolygonsSet(final Cartesian3D center, final Cartesian3D meridian,
final double outsideRadius, final int n,
final double tolerance) {
this(tolerance, createRegularPolygonVertices(center, meridian, outsideRadius, n));
@@ -159,10 +159,10 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
* @param n number of sides of the polygon
* @return vertices array
*/
- private static S2Point[] createRegularPolygonVertices(final Coordinates3D center, final Coordinates3D meridian,
+ private static S2Point[] createRegularPolygonVertices(final Cartesian3D center, final Cartesian3D meridian,
final double outsideRadius, final int n) {
final S2Point[] array = new S2Point[n];
- final Rotation r0 = new Rotation(Coordinates3D.crossProduct(center, meridian),
+ final Rotation r0 = new Rotation(Cartesian3D.crossProduct(center, meridian),
outsideRadius, RotationConvention.VECTOR_OPERATOR);
array[0] = new S2Point(r0.applyTo(center));
@@ -226,7 +226,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// create the edge and store it
edges.add(new Edge(start, end,
- Coordinates3D.angle(start.getLocation().getVector(),
+ Cartesian3D.angle(start.getLocation().getVector(),
end.getLocation().getVector()),
circle));
@@ -490,7 +490,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
}
// gather some inside points, to be used by the encloser
- final List<Coordinates3D> points = getInsidePoints();
+ final List<Cartesian3D> points = getInsidePoints();
// extract points from the boundary loops, to be used by the encloser as well
final List<Vertex> boundary = getBoundaryLoops();
@@ -504,10 +504,10 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// find the smallest enclosing 3D sphere
final SphereGenerator generator = new SphereGenerator();
- final WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
+ final WelzlEncloser<Euclidean3D, Cartesian3D> encloser =
new WelzlEncloser<>(getTolerance(), generator);
- EnclosingBall<Euclidean3D, Coordinates3D> enclosing3D = encloser.enclose(points);
- final Coordinates3D[] support3D = enclosing3D.getSupport();
+ EnclosingBall<Euclidean3D, Cartesian3D> enclosing3D = encloser.enclose(points);
+ final Cartesian3D[] support3D = enclosing3D.getSupport();
// convert to 3D sphere to spherical cap
final double r = enclosing3D.getRadius();
@@ -517,7 +517,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
// fall back to a crude approximation, based only on outside convex cells
EnclosingBall<Sphere2D, S2Point> enclosingS2 =
new EnclosingBall<>(S2Point.PLUS_K, Double.POSITIVE_INFINITY);
- for (Coordinates3D outsidePoint : getOutsidePoints()) {
+ for (Cartesian3D outsidePoint : getOutsidePoints()) {
final S2Point outsideS2 = new S2Point(outsidePoint);
final BoundaryProjection<Sphere2D> projection = projectToBoundary(outsideS2);
if (FastMath.PI - projection.getOffset() < enclosingS2.getRadius()) {
@@ -545,7 +545,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
/** Gather some inside points.
* @return list of points known to be strictly in all inside convex cells
*/
- private List<Coordinates3D> getInsidePoints() {
+ private List<Cartesian3D> getInsidePoints() {
final PropertiesComputer pc = new PropertiesComputer(getTolerance());
getTree(true).visit(pc);
return pc.getConvexCellsInsidePoints();
@@ -554,7 +554,7 @@ public class SphericalPolygonsSet extends AbstractRegion<Sphere2D, Sphere1D> {
/** Gather some outside points.
* @return list of points known to be strictly in all outside convex cells
*/
- private List<Coordinates3D> getOutsidePoints() {
+ private List<Cartesian3D> getOutsidePoints() {
final SphericalPolygonsSet complement =
(SphericalPolygonsSet) new RegionFactory<Sphere2D>().getComplement(this);
final PropertiesComputer pc = new PropertiesComputer(getTolerance());