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/04/25 22:57:03 UTC
[07/11] [math] MATH-1284: Vector no longer extends Point.
Replace/rename Vector?D classes with Coordinate?D classes which implement
both Vector and Point. When there are multiple implementations of the same
method which would confuse the compiler, prefer
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 b7bcbf0..4d61de1 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.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
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 Vector3D summedBarycenter;
+ private Coordinates3D summedBarycenter;
/** List of points strictly inside convex cells. */
- private final List<Vector3D> convexCellsInsidePoints;
+ private final List<Coordinates3D> 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 = Vector3D.ZERO;
+ this.summedBarycenter = Coordinates3D.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 Vector3D barycenter = convexCellBarycenter(boundary.get(0));
+ final Coordinates3D barycenter = convexCellBarycenter(boundary.get(0));
convexCellsInsidePoints.add(barycenter);
// add the cell contribution to the global properties
summedArea += area;
- summedBarycenter = new Vector3D(1, summedBarycenter, area, barycenter);
+ summedBarycenter = new Coordinates3D(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 Vector3D previousPole = e.getCircle().getPole();
- final Vector3D nextPole = e.getEnd().getOutgoing().getCircle().getPole();
- final Vector3D point = e.getEnd().getLocation().getVector();
- double alpha = FastMath.atan2(Vector3D.dotProduct(nextPole, Vector3D.crossProduct(point, previousPole)),
- -Vector3D.dotProduct(nextPole, previousPole));
+ 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));
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 Vector3D convexCellBarycenter(final Vertex start) {
+ private Coordinates3D convexCellBarycenter(final Vertex start) {
int n = 0;
- Vector3D sumB = Vector3D.ZERO;
+ Coordinates3D sumB = Coordinates3D.ZERO;
// loop around the cell
for (Edge e = start.getOutgoing(); n == 0 || e.getStart() != start; e = e.getEnd().getOutgoing()) {
- sumB = new Vector3D(1, sumB, e.getLength(), e.getCircle().getPole());
+ sumB = new Coordinates3D(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<Vector3D> getConvexCellsInsidePoints() {
+ public List<Coordinates3D> getConvexCellsInsidePoints() {
return convexCellsInsidePoints;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 94fc0c5..58aea47 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.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
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, Vector3D.PLUS_I);
+ public static final S2Point PLUS_I = new S2Point(0, 0.5 * FastMath.PI, Coordinates3D.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, Vector3D.PLUS_J);
+ public static final S2Point PLUS_J = new S2Point(0.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.PLUS_J);
/** +K (coordinates: \( \theta = any angle, \varphi = 0 \)). */
- public static final S2Point PLUS_K = new S2Point(0, 0, Vector3D.PLUS_K);
+ public static final S2Point PLUS_K = new S2Point(0, 0, Coordinates3D.PLUS_K);
/** -I (coordinates: \( \theta = \pi, \varphi = \pi/2 \)). */
- public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Vector3D.MINUS_I);
+ public static final S2Point MINUS_I = new S2Point(FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.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, Vector3D.MINUS_J);
+ public static final S2Point MINUS_J = new S2Point(1.5 * FastMath.PI, 0.5 * FastMath.PI, Coordinates3D.MINUS_J);
/** -K (coordinates: \( \theta = any angle, \varphi = \pi \)). */
- public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Vector3D.MINUS_K);
+ public static final S2Point MINUS_K = new S2Point(0, FastMath.PI, Coordinates3D.MINUS_K);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
- public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Vector3D.NaN);
+ public static final S2Point NaN = new S2Point(Double.NaN, Double.NaN, Coordinates3D.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 Vector3D vector;
+ private final Coordinates3D 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 Vector3D vector) throws MathArithmeticException {
- this(FastMath.atan2(vector.getY(), vector.getX()), Vector3D.angle(Vector3D.PLUS_K, vector),
+ public S2Point(final Coordinates3D vector) throws MathArithmeticException {
+ this(FastMath.atan2(vector.getY(), vector.getX()), Coordinates3D.angle(Coordinates3D.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 Vector3D vector) {
+ private S2Point(final double theta, final double phi, final Coordinates3D 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 Vector3D vector(final double theta, final double phi)
+ private static Coordinates3D 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 Vector3D(cosTheta * sinPhi, sinTheta * sinPhi, cosPhi);
+ return new Coordinates3D(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 Vector3D getVector() {
+ public Coordinates3D 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 Vector3D.angle(p1.vector, p2.vector);
+ return Coordinates3D.angle(p1.vector, p2.vector);
}
/**
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/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 6d4d980..cbdf2d6 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.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
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 Vector3D pole, final double tolerance) {
+ public SphericalPolygonsSet(final Coordinates3D 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 Vector3D center, final Vector3D meridian,
+ public SphericalPolygonsSet(final Coordinates3D center, final Coordinates3D 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 Vector3D center, final Vector3D meridian,
+ private static S2Point[] createRegularPolygonVertices(final Coordinates3D center, final Coordinates3D meridian,
final double outsideRadius, final int n) {
final S2Point[] array = new S2Point[n];
- final Rotation r0 = new Rotation(Vector3D.crossProduct(center, meridian),
+ final Rotation r0 = new Rotation(Coordinates3D.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,
- Vector3D.angle(start.getLocation().getVector(),
+ Coordinates3D.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<Vector3D> points = getInsidePoints();
+ final List<Coordinates3D> 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, Vector3D> encloser =
+ final WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(getTolerance(), generator);
- EnclosingBall<Euclidean3D, Vector3D> enclosing3D = encloser.enclose(points);
- final Vector3D[] support3D = enclosing3D.getSupport();
+ EnclosingBall<Euclidean3D, Coordinates3D> enclosing3D = encloser.enclose(points);
+ final Coordinates3D[] 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 (Vector3D outsidePoint : getOutsidePoints()) {
+ for (Coordinates3D 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<Vector3D> getInsidePoints() {
+ private List<Coordinates3D> 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<Vector3D> getOutsidePoints() {
+ private List<Coordinates3D> getOutsidePoints() {
final SphericalPolygonsSet complement =
(SphericalPolygonsSet) new RegionFactory<Sphere2D>().getComplement(this);
final PropertiesComputer pc = new PropertiesComputer(getTolerance());
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
index ba74b52..1e09a2d 100644
--- a/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
+++ b/src/main/java/org/apache/commons/math4/geometry/spherical/twod/SubCircle.java
@@ -16,7 +16,7 @@
*/
package org.apache.commons.math4.geometry.spherical.twod;
-import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
import org.apache.commons.math4.geometry.partitioning.AbstractSubHyperplane;
import org.apache.commons.math4.geometry.partitioning.Hyperplane;
import org.apache.commons.math4.geometry.partitioning.Region;
@@ -52,7 +52,7 @@ public class SubCircle extends AbstractSubHyperplane<Sphere2D, Sphere1D> {
final Circle thisCircle = (Circle) getHyperplane();
final Circle otherCircle = (Circle) hyperplane;
- final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole());
+ final double angle = Coordinates3D.angle(thisCircle.getPole(), otherCircle.getPole());
if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) {
// the two circles are aligned or opposite
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java b/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
index 8dcf56b..16159ec 100644
--- a/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
+++ b/src/test/java/org/apache/commons/math4/complex/QuaternionTest.java
@@ -23,7 +23,7 @@ import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.ZeroException;
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.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
import org.apache.commons.math4.util.FastMath;
import org.junit.Test;
import org.junit.Assert;
@@ -121,16 +121,16 @@ public class QuaternionTest {
// qResult = (scalarA * scalarB - vectorA . vectorB) + (scalarA * vectorB + scalarB * vectorA + vectorA ^
// vectorB)
- final Vector3D vectorA = new Vector3D(qA.getVectorPart());
- final Vector3D vectorB = new Vector3D(qB.getVectorPart());
- final Vector3D vectorResult = new Vector3D(qResult.getVectorPart());
+ final Coordinates3D vectorA = new Coordinates3D(qA.getVectorPart());
+ final Coordinates3D vectorB = new Coordinates3D(qB.getVectorPart());
+ final Coordinates3D vectorResult = new Coordinates3D(qResult.getVectorPart());
- final double scalarPartRef = qA.getScalarPart() * qB.getScalarPart() - Vector3D.dotProduct(vectorA, vectorB);
+ final double scalarPartRef = qA.getScalarPart() * qB.getScalarPart() - Coordinates3D.dotProduct(vectorA, vectorB);
Assert.assertEquals(scalarPartRef, qResult.getScalarPart(), EPS);
- final Vector3D vectorPartRef = ((vectorA.scalarMultiply(qB.getScalarPart())).add(vectorB.scalarMultiply(qA
- .getScalarPart()))).add(Vector3D.crossProduct(vectorA, vectorB));
+ final Coordinates3D vectorPartRef = ((vectorA.scalarMultiply(qB.getScalarPart())).add(vectorB.scalarMultiply(qA
+ .getScalarPart()))).add(Coordinates3D.crossProduct(vectorA, vectorB));
final double norm = (vectorResult.subtract(vectorPartRef)).getNorm();
Assert.assertEquals(0, norm, EPS);
@@ -167,12 +167,12 @@ public class QuaternionTest {
final double[] vectorQ = quaternion.getVectorPart();
final double[] vectorResultQxV = qResultQxV.getVectorPart();
- final double scalarPartRefQxV = -Vector3D.dotProduct(new Vector3D(vectorQ), new Vector3D(vector));
+ final double scalarPartRefQxV = -Coordinates3D.dotProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector));
Assert.assertEquals(scalarPartRefQxV, qResultQxV.getScalarPart(), EPS);
- final Vector3D vectorPartRefQxV = (new Vector3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Vector3D
- .crossProduct(new Vector3D(vectorQ), new Vector3D(vector)));
- final double normQxV = (new Vector3D(vectorResultQxV).subtract(vectorPartRefQxV)).getNorm();
+ final Coordinates3D vectorPartRefQxV = (new Coordinates3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Coordinates3D
+ .crossProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector)));
+ final double normQxV = (new Coordinates3D(vectorResultQxV).subtract(vectorPartRefQxV)).getNorm();
Assert.assertEquals(0, normQxV, EPS);
// Case : Product between a vector and a quaternion : VxQ
@@ -189,12 +189,12 @@ public class QuaternionTest {
// comparison with the result given by the formula :
// qResult = (- vector . vectorQ) + (scalarQ * vector + vector ^ vectorQ)
- final double scalarPartRefVxQ = -Vector3D.dotProduct(new Vector3D(vectorQ), new Vector3D(vector));
+ final double scalarPartRefVxQ = -Coordinates3D.dotProduct(new Coordinates3D(vectorQ), new Coordinates3D(vector));
Assert.assertEquals(scalarPartRefVxQ, qResultVxQ.getScalarPart(), EPS);
- final Vector3D vectorPartRefVxQ = (new Vector3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Vector3D
- .crossProduct(new Vector3D(vector), new Vector3D(vectorQ)));
- final double normVxQ = (new Vector3D(vectorResultVxQ).subtract(vectorPartRefVxQ)).getNorm();
+ final Coordinates3D vectorPartRefVxQ = (new Coordinates3D(vector).scalarMultiply(quaternion.getScalarPart())).add(Coordinates3D
+ .crossProduct(new Coordinates3D(vector), new Coordinates3D(vectorQ)));
+ final double normVxQ = (new Coordinates3D(vectorResultVxQ).subtract(vectorPartRefVxQ)).getNorm();
Assert.assertEquals(0, normVxQ, EPS);
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
index a7d7374..648fee3 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
@@ -26,7 +26,7 @@ import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem;
import org.apache.commons.math4.fitting.leastsquares.MultivariateJacobianFunction;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem.Evaluation;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
import org.apache.commons.math4.linear.Array2DRowRealMatrix;
import org.apache.commons.math4.linear.ArrayRealVector;
import org.apache.commons.math4.linear.BlockRealMatrix;
@@ -412,7 +412,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
double rms = optimum.getRMS();
Assert.assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) * rms, TOl);
- Vector2D center = new Vector2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
+ Coordinates2D center = new Coordinates2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
Assert.assertEquals(69.96016176931406, circle.getRadius(center), 1e-6);
Assert.assertEquals(96.07590211815305, center.getX(), 1e-6);
Assert.assertEquals(48.13516790438953, center.getY(), 1e-6);
@@ -455,7 +455,7 @@ public abstract class AbstractLeastSquaresOptimizerAbstractTest {
Optimum optimum = optimizer.optimize(builder(circle).weight(new DiagonalMatrix(weights)).start(start).build());
- Vector2D center = new Vector2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
+ Coordinates2D center = new Coordinates2D(optimum.getPoint().getEntry(0), optimum.getPoint().getEntry(1));
Assert.assertTrue(optimum.getEvaluations() < 25);
Assert.assertEquals(0.043, optimum.getRMS(), 1e-3);
Assert.assertEquals(0.292235, circle.getRadius(center), 1e-6);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
index 69d0b01..414ee2c 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/CircleVectorial.java
@@ -20,29 +20,29 @@ import java.util.ArrayList;
import org.apache.commons.math4.analysis.MultivariateMatrixFunction;
import org.apache.commons.math4.analysis.MultivariateVectorFunction;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
/**
* Class used in the tests.
*/
class CircleVectorial {
- private ArrayList<Vector2D> points;
+ private ArrayList<Coordinates2D> points;
public CircleVectorial() {
points = new ArrayList<>();
}
public void addPoint(double px, double py) {
- points.add(new Vector2D(px, py));
+ points.add(new Coordinates2D(px, py));
}
public int getN() {
return points.size();
}
- public double getRadius(Vector2D center) {
+ public double getRadius(Coordinates2D center) {
double r = 0;
- for (Vector2D point : points) {
+ for (Coordinates2D point : points) {
r += point.distance(center);
}
return r / points.size();
@@ -52,7 +52,7 @@ class CircleVectorial {
return new MultivariateVectorFunction() {
@Override
public double[] value(double[] params) {
- Vector2D center = new Vector2D(params[0], params[1]);
+ Coordinates2D center = new Coordinates2D(params[0], params[1]);
double radius = getRadius(center);
double[] residuals = new double[points.size()];
for (int i = 0; i < residuals.length; i++) {
@@ -69,11 +69,11 @@ class CircleVectorial {
@Override
public double[][] value(double[] params) {
final int n = points.size();
- final Vector2D center = new Vector2D(params[0], params[1]);
+ final Coordinates2D center = new Coordinates2D(params[0], params[1]);
double dRdX = 0;
double dRdY = 0;
- for (Vector2D pk : points) {
+ for (Coordinates2D pk : points) {
double dk = pk.distance(center);
dRdX += (center.getX() - pk.getX()) / dk;
dRdY += (center.getY() - pk.getY()) / dk;
@@ -84,7 +84,7 @@ class CircleVectorial {
// Jacobian of the radius residuals.
double[][] jacobian = new double[n][2];
for (int i = 0; i < n; i++) {
- final Vector2D pi = points.get(i);
+ final Coordinates2D pi = points.get(i);
final double di = pi.distance(center);
jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX;
jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
index 3ad564e..5f121e0 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/GaussNewtonOptimizerWithSVDTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem;
import org.apache.commons.math4.fitting.leastsquares.GaussNewtonOptimizer.Decomposition;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.geometry.euclidean.threed.Plane;
-import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
import org.apache.commons.math4.optim.SimpleVectorValueChecker;
import org.apache.commons.math4.util.FastMath;
import org.junit.Assert;
@@ -140,8 +140,8 @@ public class GaussNewtonOptimizerWithSVDTest
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Plane span = new Plane(Vector3D.ZERO, new Vector3D(1, 2, -3), new Vector3D(2, 1, 0), TOl);
- double expected = FastMath.abs(span.getOffset(new Vector3D(1, 1, 1)));
+ Plane span = new Plane(Coordinates3D.ZERO, new Coordinates3D(1, 2, -3), new Coordinates3D(2, 1, 0), TOl);
+ double expected = FastMath.abs(span.getOffset(new Coordinates3D(1, 1, 1)));
double actual = optimum.getResiduals().getNorm();
//verify
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
index 29466b6..56980a6 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.math4.fitting.leastsquares.LevenbergMarquardtOptimizer
import org.apache.commons.math4.fitting.leastsquares.ParameterValidator;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresOptimizer.Optimum;
import org.apache.commons.math4.fitting.leastsquares.LeastSquaresProblem.Evaluation;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
import org.apache.commons.math4.linear.DiagonalMatrix;
import org.apache.commons.math4.linear.RealMatrix;
import org.apache.commons.math4.linear.RealVector;
@@ -270,7 +270,7 @@ public class LevenbergMarquardtOptimizerTest
final CircleProblem circle = new CircleProblem(xSigma, ySigma);
final int numPoints = 10;
- for (Vector2D p : factory.generate(numPoints)) {
+ for (Coordinates2D p : factory.generate(numPoints)) {
circle.addPoint(p.getX(), p.getY());
}
@@ -307,7 +307,7 @@ public class LevenbergMarquardtOptimizerTest
final CircleProblem circle = new CircleProblem(xSigma, ySigma);
final int numPoints = 10;
- for (Vector2D p : factory.generate(numPoints)) {
+ for (Coordinates2D p : factory.generate(numPoints)) {
circle.addPoint(p.getX(), p.getY());
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
index 5cb6601..a849c03 100644
--- a/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
+++ b/src/test/java/org/apache/commons/math4/fitting/leastsquares/RandomCirclePointGenerator.java
@@ -19,7 +19,7 @@ package org.apache.commons.math4.fitting.leastsquares;
import org.apache.commons.math4.distribution.NormalDistribution;
import org.apache.commons.math4.distribution.RealDistribution;
import org.apache.commons.math4.distribution.UniformRealDistribution;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.apache.commons.math4.util.FastMath;
@@ -65,8 +65,8 @@ public class RandomCirclePointGenerator {
* @param n Number of points to create.
* @return the cloud of {@code n} points.
*/
- public Vector2D[] generate(int n) {
- final Vector2D[] cloud = new Vector2D[n];
+ public Coordinates2D[] generate(int n) {
+ final Coordinates2D[] cloud = new Coordinates2D[n];
for (int i = 0; i < n; i++) {
cloud[i] = create();
}
@@ -78,11 +78,11 @@ public class RandomCirclePointGenerator {
*
* @return a point.
*/
- private Vector2D create() {
+ private Coordinates2D create() {
final double t = tP.sample();
final double pX = cX.sample() + radius * FastMath.cos(t);
final double pY = cY.sample() + radius * FastMath.sin(t);
- return new Vector2D(pX, pY);
+ return new Coordinates2D(pX, pY);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
index 51306b3..2e08195 100644
--- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser2DTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.enclosing.WelzlEncloser;
import org.apache.commons.math4.geometry.euclidean.twod.DiskGenerator;
import org.apache.commons.math4.geometry.euclidean.twod.Euclidean2D;
-import org.apache.commons.math4.geometry.euclidean.twod.Vector2D;
+import org.apache.commons.math4.geometry.euclidean.twod.Coordinates2D;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
import org.junit.Assert;
@@ -36,36 +36,36 @@ public class WelzlEncloser2DTest {
@Test
public void testNullList() {
DiskGenerator generator = new DiskGenerator();
- WelzlEncloser<Euclidean2D, Vector2D> encloser =
+ WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean2D, Vector2D> ball = encloser.enclose(null);
+ EnclosingBall<Euclidean2D, Coordinates2D> ball = encloser.enclose(null);
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testNoPoints() {
DiskGenerator generator = new DiskGenerator();
- WelzlEncloser<Euclidean2D, Vector2D> encloser =
+ WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean2D, Vector2D> ball = encloser.enclose(new ArrayList<Vector2D>());
+ EnclosingBall<Euclidean2D, Coordinates2D> ball = encloser.enclose(new ArrayList<Coordinates2D>());
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testRegularPoints() {
- List<Vector2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54, 11, 15);
+ List<Coordinates2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54, 11, 15);
checkDisk(list, Arrays.asList(list.get(2), list.get(3), list.get(4)));
}
@Test
public void testSolutionOnDiameter() {
- List<Vector2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54);
+ List<Coordinates2D> list = buildList(22, 26, 30, 38, 64, 28, 8, 54);
checkDisk(list, Arrays.asList(list.get(2), list.get(3)));
}
@Test
public void testReducingBall1() {
- List<Vector2D> list = buildList(0.05380958511396061, 0.57332359658700000,
+ List<Coordinates2D> list = buildList(0.05380958511396061, 0.57332359658700000,
0.99348810731127870, 0.02056421361521466,
0.01203950647796437, 0.99779675042261860,
0.00810189987706078, 0.00589246003827815,
@@ -75,7 +75,7 @@ public class WelzlEncloser2DTest {
@Test
public void testReducingBall2() {
- List<Vector2D> list = buildList(0.016930586154703, 0.333955448537779,
+ List<Coordinates2D> list = buildList(0.016930586154703, 0.333955448537779,
0.987189104892331, 0.969778855274507,
0.983696889599935, 0.012904580013266,
0.013114499572905, 0.034740156356895);
@@ -87,39 +87,39 @@ public class WelzlEncloser2DTest {
UniformRandomProvider random = RandomSource.create(RandomSource.WELL_1024_A, 0xa2a63cad12c01fb2l);
for (int k = 0; k < 100; ++k) {
int nbPoints = random.nextInt(10000);
- List<Vector2D> points = new ArrayList<>();
+ List<Coordinates2D> points = new ArrayList<>();
for (int i = 0; i < nbPoints; ++i) {
double x = random.nextDouble();
double y = random.nextDouble();
- points.add(new Vector2D(x, y));
+ points.add(new Coordinates2D(x, y));
}
checkDisk(points);
}
}
- private List<Vector2D> buildList(final double ... coordinates) {
- List<Vector2D> list = new ArrayList<>(coordinates.length / 2);
+ private List<Coordinates2D> buildList(final double ... coordinates) {
+ List<Coordinates2D> list = new ArrayList<>(coordinates.length / 2);
for (int i = 0; i < coordinates.length; i += 2) {
- list.add(new Vector2D(coordinates[i], coordinates[i + 1]));
+ list.add(new Coordinates2D(coordinates[i], coordinates[i + 1]));
}
return list;
}
- private void checkDisk(List<Vector2D> points, List<Vector2D> refSupport) {
+ private void checkDisk(List<Coordinates2D> points, List<Coordinates2D> refSupport) {
- EnclosingBall<Euclidean2D, Vector2D> disk = checkDisk(points);
+ EnclosingBall<Euclidean2D, Coordinates2D> disk = checkDisk(points);
// compare computed disk with expected disk
DiskGenerator generator = new DiskGenerator();
- EnclosingBall<Euclidean2D, Vector2D> expected = generator.ballOnSupport(refSupport);
+ EnclosingBall<Euclidean2D, Coordinates2D> expected = generator.ballOnSupport(refSupport);
Assert.assertEquals(refSupport.size(), disk.getSupportSize());
Assert.assertEquals(expected.getRadius(), disk.getRadius(), 1.0e-10);
Assert.assertEquals(expected.getCenter().getX(), disk.getCenter().getX(), 1.0e-10);
Assert.assertEquals(expected.getCenter().getY(), disk.getCenter().getY(), 1.0e-10);
- for (Vector2D s : disk.getSupport()) {
+ for (Coordinates2D s : disk.getSupport()) {
boolean found = false;
- for (Vector2D rs : refSupport) {
+ for (Coordinates2D rs : refSupport) {
if (s == rs) {
found = true;
}
@@ -129,14 +129,14 @@ public class WelzlEncloser2DTest {
// check removing any point of the support disk fails to enclose the point
for (int i = 0; i < disk.getSupportSize(); ++i) {
- List<Vector2D> reducedSupport = new ArrayList<>();
+ List<Coordinates2D> reducedSupport = new ArrayList<>();
int count = 0;
- for (Vector2D s : disk.getSupport()) {
+ for (Coordinates2D s : disk.getSupport()) {
if (count++ != i) {
reducedSupport.add(s);
}
}
- EnclosingBall<Euclidean2D, Vector2D> reducedDisk = generator.ballOnSupport(reducedSupport);
+ EnclosingBall<Euclidean2D, Coordinates2D> reducedDisk = generator.ballOnSupport(reducedSupport);
boolean foundOutside = false;
for (int j = 0; j < points.size() && !foundOutside; ++j) {
if (!reducedDisk.contains(points.get(j), 1.0e-10)) {
@@ -148,20 +148,20 @@ public class WelzlEncloser2DTest {
}
- private EnclosingBall<Euclidean2D, Vector2D> checkDisk(List<Vector2D> points) {
+ private EnclosingBall<Euclidean2D, Coordinates2D> checkDisk(List<Coordinates2D> points) {
- WelzlEncloser<Euclidean2D, Vector2D> encloser =
+ WelzlEncloser<Euclidean2D, Coordinates2D> encloser =
new WelzlEncloser<>(1.0e-10, new DiskGenerator());
- EnclosingBall<Euclidean2D, Vector2D> disk = encloser.enclose(points);
+ EnclosingBall<Euclidean2D, Coordinates2D> disk = encloser.enclose(points);
// all points are enclosed
- for (Vector2D v : points) {
+ for (Coordinates2D v : points) {
Assert.assertTrue(disk.contains(v, 1.0e-10));
}
- for (Vector2D v : points) {
+ for (Coordinates2D v : points) {
boolean inSupport = false;
- for (Vector2D s : disk.getSupport()) {
+ for (Coordinates2D s : disk.getSupport()) {
if (v == s) {
inSupport = true;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
index 0818657..c2af261 100644
--- a/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/enclosing/WelzlEncloser3DTest.java
@@ -25,7 +25,7 @@ import org.apache.commons.math4.geometry.enclosing.EnclosingBall;
import org.apache.commons.math4.geometry.enclosing.WelzlEncloser;
import org.apache.commons.math4.geometry.euclidean.threed.Euclidean3D;
import org.apache.commons.math4.geometry.euclidean.threed.SphereGenerator;
-import org.apache.commons.math4.geometry.euclidean.threed.Vector3D;
+import org.apache.commons.math4.geometry.euclidean.threed.Coordinates3D;
import org.apache.commons.math4.random.UnitSphereRandomVectorGenerator;
import org.apache.commons.rng.UniformRandomProvider;
import org.apache.commons.rng.simple.RandomSource;
@@ -38,67 +38,67 @@ public class WelzlEncloser3DTest {
@Test
public void testNullList() {
SphereGenerator generator = new SphereGenerator();
- WelzlEncloser<Euclidean3D, Vector3D> encloser =
+ WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean3D, Vector3D> ball = encloser.enclose(null);
+ EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(null);
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testNoPoints() {
SphereGenerator generator = new SphereGenerator();
- WelzlEncloser<Euclidean3D, Vector3D> encloser =
+ WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(1.0e-10, generator);
- EnclosingBall<Euclidean3D, Vector3D> ball = encloser.enclose(new ArrayList<Vector3D>());
+ EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(new ArrayList<Coordinates3D>());
Assert.assertTrue(ball.getRadius() < 0);
}
@Test
public void testReducingBall() {
- List<Vector3D> list =
- Arrays.asList(new Vector3D(-7.140397329568118, -16.571661242582177, 11.714458961735405),
- new Vector3D(-7.137986707455888, -16.570767323375720, 11.708602108715928),
- new Vector3D(-7.139185068549035, -16.570891204702250, 11.715554057357394),
- new Vector3D(-7.142682716997507, -16.571609818234290, 11.710787934580328),
- new Vector3D(-7.139018392423351, -16.574405614157020, 11.710518716711425),
- new Vector3D(-7.140870659936730, -16.567993074240455, 11.710914678204503),
- new Vector3D(-7.136350173659562, -16.570498228820930, 11.713965225900928),
- new Vector3D(-7.141675762759172, -16.572852471407028, 11.714033471449508),
- new Vector3D(-7.140453077221105, -16.570212820780647, 11.708624578004980),
- new Vector3D(-7.140322188726825, -16.574152894557717, 11.710305611121410),
- new Vector3D(-7.141116131477088, -16.574061164624560, 11.712938509321699));
- WelzlEncloser<Euclidean3D, Vector3D> encloser =
+ List<Coordinates3D> list =
+ Arrays.asList(new Coordinates3D(-7.140397329568118, -16.571661242582177, 11.714458961735405),
+ new Coordinates3D(-7.137986707455888, -16.570767323375720, 11.708602108715928),
+ new Coordinates3D(-7.139185068549035, -16.570891204702250, 11.715554057357394),
+ new Coordinates3D(-7.142682716997507, -16.571609818234290, 11.710787934580328),
+ new Coordinates3D(-7.139018392423351, -16.574405614157020, 11.710518716711425),
+ new Coordinates3D(-7.140870659936730, -16.567993074240455, 11.710914678204503),
+ new Coordinates3D(-7.136350173659562, -16.570498228820930, 11.713965225900928),
+ new Coordinates3D(-7.141675762759172, -16.572852471407028, 11.714033471449508),
+ new Coordinates3D(-7.140453077221105, -16.570212820780647, 11.708624578004980),
+ new Coordinates3D(-7.140322188726825, -16.574152894557717, 11.710305611121410),
+ new Coordinates3D(-7.141116131477088, -16.574061164624560, 11.712938509321699));
+ WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Vector3D> ball = encloser.enclose(list);
+ EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(list);
Assert.assertTrue(ball.getRadius() > 0);
}
@Test
public void testInfiniteLoop() {
// this test used to generate an infinite loop
- List<Vector3D> list =
- Arrays.asList(new Vector3D( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
- new Vector3D( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
- new Vector3D( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
- new Vector3D( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
- new Vector3D( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
- new Vector3D( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
- new Vector3D( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
- new Vector3D( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
- new Vector3D( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
- new Vector3D( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
- new Vector3D( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
- new Vector3D( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
- new Vector3D( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
- new Vector3D( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
- new Vector3D( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
- new Vector3D( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
- new Vector3D( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
- new Vector3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
-
- WelzlEncloser<Euclidean3D, Vector3D> encloser =
+ List<Coordinates3D> list =
+ Arrays.asList(new Coordinates3D( -0.89227075512164380, -2.89317694645713900, 14.84572323743355500),
+ new Coordinates3D( -0.92099498940693580, -2.31086108263908940, 12.92071026467688300),
+ new Coordinates3D( -0.85227999411005200, -3.06314731441320730, 15.40163831651287000),
+ new Coordinates3D( -1.77399413020785970, -3.65630391378114260, 14.13190097751873400),
+ new Coordinates3D( 0.33157833272465354, -2.22813591757792160, 14.21225234159008200),
+ new Coordinates3D( -1.53065579165484400, -1.65692084770139570, 14.61483055714788500),
+ new Coordinates3D( -1.08457093941217140, -1.96100325935602980, 13.09265170575555000),
+ new Coordinates3D( 0.30029469589708850, -3.05470831395667370, 14.56352400426342600),
+ new Coordinates3D( -0.95007443938638460, -1.86810946486118360, 15.14491234340057000),
+ new Coordinates3D( -1.89661503804130830, -2.17004080885185860, 14.81235128513927000),
+ new Coordinates3D( -0.72193328761607530, -1.44513142833618270, 14.52355724218561800),
+ new Coordinates3D( -0.26895980939606550, -3.69512371522084140, 14.72272846327652000),
+ new Coordinates3D( -1.53501693431786170, -3.25055166611021900, 15.15509062584274800),
+ new Coordinates3D( -0.71727553535519410, -3.62284279460799100, 13.26256700929380700),
+ new Coordinates3D( -0.30220950676137365, -3.25410412500779070, 13.13682612771606000),
+ new Coordinates3D( -0.04543996608267075, -1.93081853923797750, 14.79497997883171400),
+ new Coordinates3D( -1.53348892951571640, -3.66688919703524900, 14.73095600812074200),
+ new Coordinates3D( -0.98034899533935820, -3.34004481162763960, 13.03245014017556800));
+
+ WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Vector3D> ball = encloser.enclose(list);
+ EnclosingBall<Euclidean3D, Coordinates3D> ball = encloser.enclose(list);
Assert.assertTrue(ball.getRadius() > 0);
}
@@ -112,13 +112,13 @@ public class WelzlEncloser3DTest {
// define the reference sphere we want to compute
double d = 25 * random.nextDouble();
double refRadius = 10 * random.nextDouble();
- Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector()));
+ Coordinates3D refCenter = new Coordinates3D(d, new Coordinates3D(sr.nextVector()));
// set up a large sample inside the reference sphere
int nbPoints = random.nextInt(1000);
- List<Vector3D> points = new ArrayList<>();
+ List<Coordinates3D> points = new ArrayList<>();
for (int i = 0; i < nbPoints; ++i) {
double r = refRadius * random.nextDouble();
- points.add(new Vector3D(1.0, refCenter, r, new Vector3D(sr.nextVector())));
+ points.add(new Coordinates3D(1.0, refCenter, r, new Coordinates3D(sr.nextVector())));
}
// test we find a sphere at most as large as the one used for random drawings
@@ -127,23 +127,23 @@ public class WelzlEncloser3DTest {
}
}
- private void checkSphere(List<Vector3D> points, double refRadius) {
+ private void checkSphere(List<Coordinates3D> points, double refRadius) {
- EnclosingBall<Euclidean3D, Vector3D> sphere = checkSphere(points);
+ EnclosingBall<Euclidean3D, Coordinates3D> sphere = checkSphere(points);
// compare computed sphere with bounding sphere
Assert.assertTrue(sphere.getRadius() <= refRadius);
// check removing any point of the support Sphere fails to enclose the point
for (int i = 0; i < sphere.getSupportSize(); ++i) {
- List<Vector3D> reducedSupport = new ArrayList<>();
+ List<Coordinates3D> reducedSupport = new ArrayList<>();
int count = 0;
- for (Vector3D s : sphere.getSupport()) {
+ for (Coordinates3D s : sphere.getSupport()) {
if (count++ != i) {
reducedSupport.add(s);
}
}
- EnclosingBall<Euclidean3D, Vector3D> reducedSphere =
+ EnclosingBall<Euclidean3D, Coordinates3D> reducedSphere =
new SphereGenerator().ballOnSupport(reducedSupport);
boolean foundOutside = false;
for (int j = 0; j < points.size() && !foundOutside; ++j) {
@@ -156,20 +156,20 @@ public class WelzlEncloser3DTest {
}
- private EnclosingBall<Euclidean3D, Vector3D> checkSphere(List<Vector3D> points) {
+ private EnclosingBall<Euclidean3D, Coordinates3D> checkSphere(List<Coordinates3D> points) {
- WelzlEncloser<Euclidean3D, Vector3D> encloser =
+ WelzlEncloser<Euclidean3D, Coordinates3D> encloser =
new WelzlEncloser<>(1.0e-10, new SphereGenerator());
- EnclosingBall<Euclidean3D, Vector3D> Sphere = encloser.enclose(points);
+ EnclosingBall<Euclidean3D, Coordinates3D> Sphere = encloser.enclose(points);
// all points are enclosed
- for (Vector3D v : points) {
+ for (Coordinates3D v : points) {
Assert.assertTrue(Sphere.contains(v, 1.0e-10));
}
- for (Vector3D v : points) {
+ for (Coordinates3D v : points) {
boolean inSupport = false;
- for (Vector3D s : Sphere.getSupport()) {
+ for (Coordinates3D s : Sphere.getSupport()) {
if (v == s) {
inSupport = true;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
index b7c8399..50b406b 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/IntervalsSetTest.java
@@ -21,7 +21,7 @@ import java.util.List;
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.Vector1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
import org.apache.commons.math4.geometry.partitioning.Region;
import org.apache.commons.math4.geometry.partitioning.RegionFactory;
import org.apache.commons.math4.util.FastMath;
@@ -35,12 +35,12 @@ public class IntervalsSetTest {
public void testInterval() {
IntervalsSet set = new IntervalsSet(2.3, 5.7, 1.0e-10);
Assert.assertEquals(3.4, set.getSize(), 1.0e-10);
- Assert.assertEquals(4.0, ((Vector1D) set.getBarycenter()).getX(), 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Vector1D(2.3)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Vector1D(5.7)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(1.2)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(8.7)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Vector1D(3.0)));
+ Assert.assertEquals(4.0, ((Coordinates1D) set.getBarycenter()).getX(), 1.0e-10);
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(2.3)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(5.7)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(1.2)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.7)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(3.0)));
Assert.assertEquals(2.3, set.getInf(), 1.0e-10);
Assert.assertEquals(5.7, set.getSup(), 1.0e-10);
}
@@ -48,11 +48,11 @@ public class IntervalsSetTest {
@Test
public void testInfinite() {
IntervalsSet set = new IntervalsSet(9.0, Double.POSITIVE_INFINITY, 1.0e-10);
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Vector1D(9.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(8.4)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(9.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.4)));
for (double e = 1.0; e <= 6.0; e += 1.0) {
Assert.assertEquals(Region.Location.INSIDE,
- set.checkPoint(new Vector1D(FastMath.pow(10.0, e))));
+ set.checkPoint(new Coordinates1D(FastMath.pow(10.0, e))));
}
Assert.assertTrue(Double.isInfinite(set.getSize()));
Assert.assertEquals(9.0, set.getInf(), 1.0e-10);
@@ -73,16 +73,16 @@ public class IntervalsSetTest {
new IntervalsSet(9.0, Double.POSITIVE_INFINITY, 1.0e-10)),
new IntervalsSet(Double.NEGATIVE_INFINITY, 11.0, 1.0e-10));
Assert.assertEquals(5.0, set.getSize(), 1.0e-10);
- Assert.assertEquals(5.9, ((Vector1D) set.getBarycenter()).getX(), 1.0e-10);
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(0.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(4.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(8.0)));
- Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Vector1D(12.0)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Vector1D(1.2)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Vector1D(5.9)));
- Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Vector1D(9.01)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Vector1D(5.0)));
- Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Vector1D(11.0)));
+ Assert.assertEquals(5.9, ((Coordinates1D) set.getBarycenter()).getX(), 1.0e-10);
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(0.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(4.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(8.0)));
+ Assert.assertEquals(Region.Location.OUTSIDE, set.checkPoint(new Coordinates1D(12.0)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(1.2)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(5.9)));
+ Assert.assertEquals(Region.Location.INSIDE, set.checkPoint(new Coordinates1D(9.01)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(5.0)));
+ Assert.assertEquals(Region.Location.BOUNDARY, set.checkPoint(new Coordinates1D(11.0)));
Assert.assertEquals( 1.0, set.getInf(), 1.0e-10);
Assert.assertEquals(11.0, set.getSup(), 1.0e-10);
@@ -101,7 +101,7 @@ public class IntervalsSetTest {
public void testSinglePoint() {
IntervalsSet set = new IntervalsSet(1.0, 1.0, 1.0e-10);
Assert.assertEquals(0.0, set.getSize(), Precision.SAFE_MIN);
- Assert.assertEquals(1.0, ((Vector1D) set.getBarycenter()).getX(), Precision.EPSILON);
+ Assert.assertEquals(1.0, ((Coordinates1D) set.getBarycenter()).getX(), Precision.EPSILON);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
index 699ff13..2e26cef 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DFormatAbstractTest.java
@@ -22,7 +22,7 @@ import java.text.ParsePosition;
import java.util.Locale;
import org.apache.commons.math4.exception.MathParseException;
-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.oned.Vector1DFormat;
import org.junit.Assert;
import org.junit.Test;
@@ -45,7 +45,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleNoDecimals() {
- Vector1D c = new Vector1D(1);
+ Coordinates1D c = new Coordinates1D(1);
String expected = "{1}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -53,7 +53,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleWithDecimals() {
- Vector1D c = new Vector1D(1.23);
+ Coordinates1D c = new Coordinates1D(1.23);
String expected =
"{1" + getDecimalCharacter() +
"23}";
@@ -63,7 +63,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testSimpleWithDecimalsTrunc() {
- Vector1D c = new Vector1D(1.232323232323);
+ Coordinates1D c = new Coordinates1D(1.232323232323);
String expected =
"{1" + getDecimalCharacter() +
"2323232323}";
@@ -73,7 +73,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNegativeX() {
- Vector1D c = new Vector1D(-1.232323232323);
+ Coordinates1D c = new Coordinates1D(-1.232323232323);
String expected =
"{-1" + getDecimalCharacter() +
"2323232323}";
@@ -83,7 +83,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNonDefaultSetting() {
- Vector1D c = new Vector1D(1);
+ Coordinates1D c = new Coordinates1D(1);
String expected = "[1]";
String actual = vector1DFormatSquare.format(c);
Assert.assertEquals(expected, actual);
@@ -94,7 +94,7 @@ public abstract class Vector1DFormatAbstractTest {
Locale defaultLocal = Locale.getDefault();
Locale.setDefault(getLocale());
- Vector1D c = new Vector1D(232.22222222222);
+ Coordinates1D c = new Coordinates1D(232.22222222222);
String expected =
"{232" + getDecimalCharacter() +
"2222222222}";
@@ -106,7 +106,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testNan() {
- Vector1D c = Vector1D.NaN;
+ Coordinates1D c = Coordinates1D.NaN;
String expected = "{(NaN)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -114,7 +114,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testPositiveInfinity() {
- Vector1D c = Vector1D.POSITIVE_INFINITY;
+ Coordinates1D c = Coordinates1D.POSITIVE_INFINITY;
String expected = "{(Infinity)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -122,7 +122,7 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void tesNegativeInfinity() {
- Vector1D c = Vector1D.NEGATIVE_INFINITY;
+ Coordinates1D c = Coordinates1D.NEGATIVE_INFINITY;
String expected = "{(-Infinity)}";
String actual = vector1DFormat.format(c);
Assert.assertEquals(expected, actual);
@@ -131,14 +131,14 @@ public abstract class Vector1DFormatAbstractTest {
@Test
public void testParseSimpleNoDecimals() throws MathParseException {
String source = "{1}";
- Vector1D expected = new Vector1D(1);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(1);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseIgnoredWhitespace() {
- Vector1D expected = new Vector1D(1);
+ Coordinates1D expected = new Coordinates1D(1);
ParsePosition pos1 = new ParsePosition(0);
String source1 = "{1}";
Assert.assertEquals(expected, vector1DFormat.parse(source1, pos1));
@@ -154,8 +154,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"23}";
- Vector1D expected = new Vector1D(1.23);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(1.23);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -164,8 +164,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Vector1D expected = new Vector1D(1.2323);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(1.2323);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -174,8 +174,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Vector1D expected = new Vector1D(-1.2323);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(-1.2323);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -184,8 +184,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Vector1D expected = new Vector1D(1.2323);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(1.2323);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -194,8 +194,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{1" + getDecimalCharacter() +
"2323}";
- Vector1D expected = new Vector1D(1.2323);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(1.2323);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -204,8 +204,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{-1" + getDecimalCharacter() +
"2323}";
- Vector1D expected = new Vector1D(-1.2323);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(-1.2323);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -214,8 +214,8 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"{0" + getDecimalCharacter() +
"0}";
- Vector1D expected = new Vector1D(0.0);
- Vector1D actual = vector1DFormat.parse(source);
+ Coordinates1D expected = new Coordinates1D(0.0);
+ Coordinates1D actual = vector1DFormat.parse(source);
Assert.assertEquals(expected, actual);
}
@@ -224,30 +224,30 @@ public abstract class Vector1DFormatAbstractTest {
String source =
"[1" + getDecimalCharacter() +
"2323]";
- Vector1D expected = new Vector1D(1.2323);
- Vector1D actual = vector1DFormatSquare.parse(source);
+ Coordinates1D expected = new Coordinates1D(1.2323);
+ Coordinates1D actual = vector1DFormatSquare.parse(source);
Assert.assertEquals(expected, actual);
}
@Test
public void testParseNan() throws MathParseException {
String source = "{(NaN)}";
- Vector1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Vector1D.NaN, actual);
+ Coordinates1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Coordinates1D.NaN, actual);
}
@Test
public void testParsePositiveInfinity() throws MathParseException {
String source = "{(Infinity)}";
- Vector1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Vector1D.POSITIVE_INFINITY, actual);
+ Coordinates1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Coordinates1D.POSITIVE_INFINITY, actual);
}
@Test
public void testParseNegativeInfinity() throws MathParseException {
String source = "{(-Infinity)}";
- Vector1D actual = vector1DFormat.parse(source);
- Assert.assertEquals(Vector1D.NEGATIVE_INFINITY, actual);
+ Coordinates1D actual = vector1DFormat.parse(source);
+ Assert.assertEquals(Coordinates1D.NEGATIVE_INFINITY, actual);
}
@Test
http://git-wip-us.apache.org/repos/asf/commons-math/blob/b815d2af/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
index 0bf6b84..832716c 100644
--- a/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
+++ b/src/test/java/org/apache/commons/math4/geometry/euclidean/oned/Vector1DTest.java
@@ -25,7 +25,7 @@ import java.util.Locale;
import org.apache.commons.math4.exception.DimensionMismatchException;
import org.apache.commons.math4.exception.MathArithmeticException;
import org.apache.commons.math4.geometry.Space;
-import org.apache.commons.math4.geometry.euclidean.oned.Vector1D;
+import org.apache.commons.math4.geometry.euclidean.oned.Coordinates1D;
import org.apache.commons.math4.util.FastMath;
import org.apache.commons.math4.util.Precision;
import org.junit.Assert;
@@ -34,143 +34,143 @@ import org.junit.Test;
public class Vector1DTest {
@Test
public void testConstructors() throws DimensionMismatchException {
- checkVector(new Vector1D(3, new Vector1D(FastMath.PI / 3)),
+ checkVector(new Coordinates1D(3, new Coordinates1D(FastMath.PI / 3)),
FastMath.PI);
- checkVector(new Vector1D(2, Vector1D.ONE, -3, new Vector1D(2)),
+ checkVector(new Coordinates1D(2, Coordinates1D.ONE, -3, new Coordinates1D(2)),
-4);
- checkVector(new Vector1D(2, Vector1D.ONE,
- 5, new Vector1D(2),
- -3, new Vector1D(3)),
+ checkVector(new Coordinates1D(2, Coordinates1D.ONE,
+ 5, new Coordinates1D(2),
+ -3, new Coordinates1D(3)),
3);
- checkVector(new Vector1D(2, Vector1D.ONE,
- 5, new Vector1D(2),
- 5, new Vector1D(-2),
- -3, new Vector1D(-3)),
+ checkVector(new Coordinates1D(2, Coordinates1D.ONE,
+ 5, new Coordinates1D(2),
+ 5, new Coordinates1D(-2),
+ -3, new Coordinates1D(-3)),
11);
}
@Test
public void testSpace() {
- Space space = new Vector1D(1).getSpace();
+ Space space = new Coordinates1D(1).getSpace();
Assert.assertEquals(1, space.getDimension());
}
@Test
public void testZero() {
- Assert.assertEquals(0, new Vector1D(1).getZero().getNorm(), 1.0e-15);
+ Assert.assertEquals(0, new Coordinates1D(1).getZero().getNorm(), 1.0e-15);
}
@Test
public void testEquals() {
- Vector1D u1 = new Vector1D(1);
- Vector1D u2 = new Vector1D(1);
+ Coordinates1D u1 = new Coordinates1D(1);
+ Coordinates1D u2 = new Coordinates1D(1);
Assert.assertTrue(u1.equals(u1));
Assert.assertTrue(u1.equals(u2));
- Assert.assertFalse(u1.equals(new Vector1D(1 + 10 * Precision.EPSILON)));
- Assert.assertTrue(new Vector1D(Double.NaN).equals(new Vector1D(Double.NaN)));
+ Assert.assertFalse(u1.equals(new Coordinates1D(1 + 10 * Precision.EPSILON)));
+ Assert.assertTrue(new Coordinates1D(Double.NaN).equals(new Coordinates1D(Double.NaN)));
}
@Test
public void testHash() {
- Assert.assertEquals(new Vector1D(Double.NaN).hashCode(), new Vector1D(Double.NaN).hashCode());
- Vector1D u = new Vector1D(1);
- Vector1D v = new Vector1D(1 + 10 * Precision.EPSILON);
+ Assert.assertEquals(new Coordinates1D(Double.NaN).hashCode(), new Coordinates1D(Double.NaN).hashCode());
+ Coordinates1D u = new Coordinates1D(1);
+ Coordinates1D v = new Coordinates1D(1 + 10 * Precision.EPSILON);
Assert.assertTrue(u.hashCode() != v.hashCode());
}
@Test
public void testInfinite() {
- Assert.assertTrue(new Vector1D(Double.NEGATIVE_INFINITY).isInfinite());
- Assert.assertTrue(new Vector1D(Double.POSITIVE_INFINITY).isInfinite());
- Assert.assertFalse(new Vector1D(1).isInfinite());
- Assert.assertFalse(new Vector1D(Double.NaN).isInfinite());
+ Assert.assertTrue(new Coordinates1D(Double.NEGATIVE_INFINITY).isInfinite());
+ Assert.assertTrue(new Coordinates1D(Double.POSITIVE_INFINITY).isInfinite());
+ Assert.assertFalse(new Coordinates1D(1).isInfinite());
+ Assert.assertFalse(new Coordinates1D(Double.NaN).isInfinite());
}
@Test
public void testNaN() {
- Assert.assertTrue(new Vector1D(Double.NaN).isNaN());
- Assert.assertFalse(new Vector1D(1).isNaN());
- Assert.assertFalse(new Vector1D(Double.NEGATIVE_INFINITY).isNaN());
+ Assert.assertTrue(new Coordinates1D(Double.NaN).isNaN());
+ Assert.assertFalse(new Coordinates1D(1).isNaN());
+ Assert.assertFalse(new Coordinates1D(Double.NEGATIVE_INFINITY).isNaN());
}
@Test
public void testToString() {
- Assert.assertEquals("{3}", new Vector1D(3).toString());
+ Assert.assertEquals("{3}", new Coordinates1D(3).toString());
NumberFormat format = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
- Assert.assertEquals("{3.000}", new Vector1D(3).toString(format));
+ Assert.assertEquals("{3.000}", new Coordinates1D(3).toString(format));
}
@Test
public void testCoordinates() {
- Vector1D v = new Vector1D(1);
+ Coordinates1D v = new Coordinates1D(1);
Assert.assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12);
}
@Test
public void testNorm1() {
- Assert.assertEquals(0.0, Vector1D.ZERO.getNorm1(), 0);
- Assert.assertEquals(6.0, new Vector1D(6).getNorm1(), 0);
+ Assert.assertEquals(0.0, Coordinates1D.ZERO.getNorm1(), 0);
+ Assert.assertEquals(6.0, new Coordinates1D(6).getNorm1(), 0);
}
@Test
public void testNorm() {
- Assert.assertEquals(0.0, Vector1D.ZERO.getNorm(), 0);
- Assert.assertEquals(3.0, new Vector1D(-3).getNorm(), 1.0e-12);
+ Assert.assertEquals(0.0, Coordinates1D.ZERO.getNorm(), 0);
+ Assert.assertEquals(3.0, new Coordinates1D(-3).getNorm(), 1.0e-12);
}
@Test
public void testNormSq() {
- Assert.assertEquals(0.0, new Vector1D(0).getNormSq(), 0);
- Assert.assertEquals(9.0, new Vector1D(-3).getNormSq(), 1.0e-12);
+ Assert.assertEquals(0.0, new Coordinates1D(0).getNormSq(), 0);
+ Assert.assertEquals(9.0, new Coordinates1D(-3).getNormSq(), 1.0e-12);
}
@Test
public void testNormInf() {
- Assert.assertEquals(0.0, Vector1D.ZERO.getNormInf(), 0);
- Assert.assertEquals(3.0, new Vector1D(-3).getNormInf(), 0);
+ Assert.assertEquals(0.0, Coordinates1D.ZERO.getNormInf(), 0);
+ Assert.assertEquals(3.0, new Coordinates1D(-3).getNormInf(), 0);
}
@Test
public void testDistance1() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-4);
- Assert.assertEquals(0.0, new Vector1D(-1).distance1(new Vector1D(-1)), 0);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-4);
+ Assert.assertEquals(0.0, new Coordinates1D(-1).distance1(new Coordinates1D(-1)), 0);
Assert.assertEquals(5.0, v1.distance1(v2), 1.0e-12);
Assert.assertEquals(v1.subtract(v2).getNorm1(), v1.distance1(v2), 1.0e-12);
}
@Test
public void testDistance() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-4);
- Assert.assertEquals(0.0, Vector1D.distance(new Vector1D(-1), new Vector1D(-1)), 0);
- Assert.assertEquals(5.0, Vector1D.distance(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNorm(), Vector1D.distance(v1, v2), 1.0e-12);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-4);
+ Assert.assertEquals(0.0, Coordinates1D.distance(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
+ Assert.assertEquals(5.0, Coordinates1D.distance(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNorm(), Coordinates1D.distance(v1, v2), 1.0e-12);
}
@Test
public void testDistanceSq() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-4);
- Assert.assertEquals(0.0, Vector1D.distanceSq(new Vector1D(-1), new Vector1D(-1)), 0);
- Assert.assertEquals(25.0, Vector1D.distanceSq(v1, v2), 1.0e-12);
- Assert.assertEquals(Vector1D.distance(v1, v2) * Vector1D.distance(v1, v2),
- Vector1D.distanceSq(v1, v2), 1.0e-12);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-4);
+ Assert.assertEquals(0.0, Coordinates1D.distanceSq(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
+ Assert.assertEquals(25.0, Coordinates1D.distanceSq(v1, v2), 1.0e-12);
+ Assert.assertEquals(Coordinates1D.distance(v1, v2) * Coordinates1D.distance(v1, v2),
+ Coordinates1D.distanceSq(v1, v2), 1.0e-12);
}
@Test
public void testDistanceInf() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-4);
- Assert.assertEquals(0.0, Vector1D.distanceInf(new Vector1D(-1), new Vector1D(-1)), 0);
- Assert.assertEquals(5.0, Vector1D.distanceInf(v1, v2), 1.0e-12);
- Assert.assertEquals(v1.subtract(v2).getNormInf(), Vector1D.distanceInf(v1, v2), 1.0e-12);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-4);
+ Assert.assertEquals(0.0, Coordinates1D.distanceInf(new Coordinates1D(-1), new Coordinates1D(-1)), 0);
+ Assert.assertEquals(5.0, Coordinates1D.distanceInf(v1, v2), 1.0e-12);
+ Assert.assertEquals(v1.subtract(v2).getNormInf(), Coordinates1D.distanceInf(v1, v2), 1.0e-12);
}
@Test
public void testSubtract() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-3);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-3);
v1 = v1.subtract(v2);
checkVector(v1, 4);
@@ -180,8 +180,8 @@ public class Vector1DTest {
@Test
public void testAdd() {
- Vector1D v1 = new Vector1D(1);
- Vector1D v2 = new Vector1D(-3);
+ Coordinates1D v1 = new Coordinates1D(1);
+ Coordinates1D v2 = new Coordinates1D(-3);
v1 = v1.add(v2);
checkVector(v1, -2);
@@ -191,7 +191,7 @@ public class Vector1DTest {
@Test
public void testScalarProduct() {
- Vector1D v = new Vector1D(1);
+ Coordinates1D v = new Coordinates1D(1);
v = v.scalarMultiply(3);
checkVector(v, 3);
@@ -200,9 +200,9 @@ public class Vector1DTest {
@Test
public void testNormalize() throws MathArithmeticException {
- Assert.assertEquals(1.0, new Vector1D(5).normalize().getNorm(), 1.0e-12);
+ Assert.assertEquals(1.0, new Coordinates1D(5).normalize().getNorm(), 1.0e-12);
try {
- Vector1D.ZERO.normalize();
+ Coordinates1D.ZERO.normalize();
Assert.fail("an exception should have been thrown");
} catch (MathArithmeticException ae) {
// expected behavior
@@ -211,10 +211,10 @@ public class Vector1DTest {
@Test
public void testNegate() {
- checkVector(new Vector1D(0.1).negate(), -0.1);
+ checkVector(new Coordinates1D(0.1).negate(), -0.1);
}
- private void checkVector(Vector1D v, double x) {
+ private void checkVector(Coordinates1D v, double x) {
Assert.assertEquals(x, v.getX(), 1.0e-12);
}
}