You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/09/28 01:19:36 UTC
[commons-geometry] branch master updated: GEOMETRY-64: Parent class
must not refer to subclass during its initialization.
This is an automated email from the ASF dual-hosted git repository.
erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
The following commit(s) were added to refs/heads/master by this push:
new c07711d GEOMETRY-64: Parent class must not refer to subclass during its initialization.
c07711d is described below
commit c07711d6a63d7bbeb4d71599d27b23321cc3605c
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Sat Sep 28 03:15:15 2019 +0200
GEOMETRY-64: Parent class must not refer to subclass during its initialization.
Constants for unit vectors defined in "Unit" subclass.
---
.../geometry/euclidean/oned/OrientedPoint.java | 2 +-
.../commons/geometry/euclidean/oned/Vector1D.java | 14 +-
.../geometry/euclidean/threed/PolyhedronsSet.java | 16 +-
.../geometry/euclidean/threed/SubPlane.java | 2 +-
.../geometry/euclidean/threed/Vector3D.java | 34 +---
.../euclidean/threed/rotation/AxisSequence.java | 24 +--
.../threed/rotation/QuaternionRotation.java | 2 +-
.../commons/geometry/euclidean/twod/Vector2D.java | 24 +--
.../oned/AffineTransformMatrix1DTest.java | 4 +-
.../geometry/euclidean/oned/OrientedPointTest.java | 4 +-
.../geometry/euclidean/oned/Vector1DTest.java | 18 +--
.../threed/AffineTransformMatrix3DTest.java | 18 +--
.../geometry/euclidean/threed/PlaneTest.java | 44 ++---
.../euclidean/threed/PolyhedronsSetTest.java | 22 +--
.../geometry/euclidean/threed/Vector3DTest.java | 138 ++++++++--------
.../threed/rotation/AxisSequenceTest.java | 6 +-
.../threed/rotation/QuaternionRotationTest.java | 178 ++++++++++-----------
.../twod/AffineTransformMatrix2DTest.java | 4 +-
.../commons/geometry/euclidean/twod/LineTest.java | 134 ++++++++--------
.../geometry/euclidean/twod/PolygonsSetTest.java | 8 +-
.../geometry/euclidean/twod/Vector2DTest.java | 94 +++++------
.../commons/geometry/spherical/twod/S2Point.java | 12 +-
.../geometry/spherical/twod/CircleTest.java | 22 +--
.../spherical/twod/SphericalPolygonsSetTest.java | 92 +++++------
.../geometry/spherical/twod/SubCircleTest.java | 26 +--
25 files changed, 453 insertions(+), 489 deletions(-)
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
index 23ad001..8888eb9 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/OrientedPoint.java
@@ -68,7 +68,7 @@ public final class OrientedPoint implements Hyperplane<Vector1D>, Serializable {
* @return the hyperplane direction
*/
public Vector1D getDirection() {
- return positiveFacing ? Vector1D.ONE : Vector1D.MINUS_ONE;
+ return positiveFacing ? Vector1D.Unit.PLUS : Vector1D.Unit.MINUS;
}
/**
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
index 1447c1b..48a3c5f 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Vector1D.java
@@ -32,12 +32,6 @@ public class Vector1D extends EuclideanVector<Vector1D> {
/** Zero vector (coordinates: 0). */
public static final Vector1D ZERO = new Vector1D(0.0);
- /** Unit vector (coordinates: 1). */
- public static final Vector1D ONE = Unit.ONE;
-
- /** Negation of unit vector (coordinates: -1). */
- public static final Vector1D MINUS_ONE = Unit.MINUS_ONE;
-
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
public static final Vector1D NaN = new Vector1D(Double.NaN);
@@ -380,9 +374,9 @@ public class Vector1D extends EuclideanVector<Vector1D> {
*/
public static final class Unit extends Vector1D {
/** Unit vector (coordinates: 1). */
- static final Unit ONE = new Unit(1d);
+ public static final Unit PLUS = new Unit(1d);
/** Negation of unit vector (coordinates: -1). */
- static final Unit MINUS_ONE = new Unit(-1d);
+ public static final Unit MINUS = new Unit(-1d);
/** Serializable version identifier */
private static final long serialVersionUID = 20180903L;
@@ -404,7 +398,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
*/
public static Unit from(double x) {
Vectors.checkedNorm(Vectors.norm(x));
- return x > 0 ? ONE : MINUS_ONE;
+ return x > 0 ? PLUS : MINUS;
}
/**
@@ -447,7 +441,7 @@ public class Vector1D extends EuclideanVector<Vector1D> {
/** {@inheritDoc} */
@Override
public Vector1D negate() {
- return this == ONE ? MINUS_ONE : ONE;
+ return this == PLUS ? MINUS : PLUS;
}
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
index 27bd7f2..bea93e8 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSet.java
@@ -157,12 +157,12 @@ public class PolyhedronsSet extends AbstractRegion<Vector3D, Vector2D> {
// too thin box, build an empty polygons set
return new BSPTree<>(Boolean.FALSE);
}
- final Plane pxMin = Plane.fromPointAndNormal(Vector3D.of(xMin, 0, 0), Vector3D.MINUS_X, precision);
- final Plane pxMax = Plane.fromPointAndNormal(Vector3D.of(xMax, 0, 0), Vector3D.PLUS_X, precision);
- final Plane pyMin = Plane.fromPointAndNormal(Vector3D.of(0, yMin, 0), Vector3D.MINUS_Y, precision);
- final Plane pyMax = Plane.fromPointAndNormal(Vector3D.of(0, yMax, 0), Vector3D.PLUS_Y, precision);
- final Plane pzMin = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMin), Vector3D.MINUS_Z, precision);
- final Plane pzMax = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMax), Vector3D.PLUS_Z, precision);
+ final Plane pxMin = Plane.fromPointAndNormal(Vector3D.of(xMin, 0, 0), Vector3D.Unit.MINUS_X, precision);
+ final Plane pxMax = Plane.fromPointAndNormal(Vector3D.of(xMax, 0, 0), Vector3D.Unit.PLUS_X, precision);
+ final Plane pyMin = Plane.fromPointAndNormal(Vector3D.of(0, yMin, 0), Vector3D.Unit.MINUS_Y, precision);
+ final Plane pyMax = Plane.fromPointAndNormal(Vector3D.of(0, yMax, 0), Vector3D.Unit.PLUS_Y, precision);
+ final Plane pzMin = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMin), Vector3D.Unit.MINUS_Z, precision);
+ final Plane pzMax = Plane.fromPointAndNormal(Vector3D.of(0, 0, zMax), Vector3D.Unit.PLUS_Z, precision);
final Region<Vector3D> boundary =
new RegionFactory<Vector3D>().buildConvex(pxMin, pxMax, pyMin, pyMax, pzMin, pzMax);
return boundary.getTree(false);
@@ -693,8 +693,8 @@ public class PolyhedronsSet extends AbstractRegion<Vector3D, Vector2D> {
cachedOriginal = (Plane) original;
cachedTransform =
- org.apache.commons.geometry.euclidean.twod.Line.getTransform(Vector2D.PLUS_X,
- Vector2D.PLUS_Y,
+ org.apache.commons.geometry.euclidean.twod.Line.getTransform(Vector2D.Unit.PLUS_X,
+ Vector2D.Unit.PLUS_Y,
shift);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
index 02f646e..0520658 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SubPlane.java
@@ -76,7 +76,7 @@ public class SubPlane extends AbstractSubHyperplane<Vector3D, Vector2D> {
// the hyperplanes do intersect
Vector2D p = thisPlane.toSubSpace(inter.toSpace(Vector1D.ZERO));
- Vector2D q = thisPlane.toSubSpace(inter.toSpace(Vector1D.ONE));
+ Vector2D q = thisPlane.toSubSpace(inter.toSpace(Vector1D.Unit.PLUS));
Vector3D crossP = inter.getDirection().cross(thisPlane.getNormal());
if (crossP.dot(otherPlane.getNormal()) < 0) {
final Vector2D tmp = p;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
index 03a85e2..1434841 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/Vector3D.java
@@ -31,25 +31,7 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
/** Zero (null) vector (coordinates: 0, 0, 0). */
- public static final Vector3D ZERO = new Vector3D(0, 0, 0);
-
- /** First canonical vector (coordinates: 1, 0, 0). */
- public static final Vector3D PLUS_X = Unit.PLUS_X;
-
- /** Opposite of the first canonical vector (coordinates: -1, 0, 0). */
- public static final Vector3D MINUS_X = Unit.MINUS_X;
-
- /** Second canonical vector (coordinates: 0, 1, 0). */
- public static final Vector3D PLUS_Y = Unit.PLUS_Y;
-
- /** Opposite of the second canonical vector (coordinates: 0, -1, 0). */
- public static final Vector3D MINUS_Y = Unit.MINUS_Y;
-
- /** Third canonical vector (coordinates: 0, 0, 1). */
- public static final Vector3D PLUS_Z = Unit.PLUS_Z;
-
- /** Opposite of the third canonical vector (coordinates: 0, 0, -1). */
- public static final Vector3D MINUS_Z = Unit.MINUS_Z;
+ public static final Vector3D ZERO = new Vector3D(0, 0, 0);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
@@ -581,21 +563,21 @@ public class Vector3D extends MultiDimensionalEuclideanVector<Vector3D> {
/**
* Represents unit vectors.
- * This allows optimizations to be performed for certain operations.
+ * This allows optimizations for certain operations.
*/
public static final class Unit extends Vector3D {
/** Unit vector (coordinates: 1, 0, 0). */
- static final Unit PLUS_X = new Unit(1d, 0d, 0d);
+ public static final Unit PLUS_X = new Unit(1d, 0d, 0d);
/** Negation of unit vector (coordinates: -1, 0, 0). */
- static final Unit MINUS_X = new Unit(-1d, 0d, 0d);
+ public static final Unit MINUS_X = new Unit(-1d, 0d, 0d);
/** Unit vector (coordinates: 0, 1, 0). */
- static final Unit PLUS_Y = new Unit(0d, 1d, 0d);
+ public static final Unit PLUS_Y = new Unit(0d, 1d, 0d);
/** Negation of unit vector (coordinates: 0, -1, 0). */
- static final Unit MINUS_Y = new Unit(0d, -1d, 0d);
+ public static final Unit MINUS_Y = new Unit(0d, -1d, 0d);
/** Unit vector (coordinates: 0, 0, 1). */
- static final Unit PLUS_Z = new Unit(0d, 0d, 1d);
+ public static final Unit PLUS_Z = new Unit(0d, 0d, 1d);
/** Negation of unit vector (coordinates: 0, 0, -1). */
- static final Unit MINUS_Z = new Unit(0d, 0d, -1d);
+ public static final Unit MINUS_Z = new Unit(0d, 0d, -1d);
/** Serializable version identifier */
private static final long serialVersionUID = 20180903L;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequence.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequence.java
index 68c8fde..813d6c5 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequence.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequence.java
@@ -25,63 +25,63 @@ public enum AxisSequence {
/** Set of Tait-Bryan angles around the <strong>X</strong>, <strong>Y</strong>, and
* <strong>Z</strong> axes in that order.
*/
- XYZ(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.PLUS_Z),
+ XYZ(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z),
/** Set of Tait-Bryan angles around the <strong>X</strong>, <strong>Z</strong>, and
* <strong>Y</strong> axes in that order.
*/
- XZY(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_X, Vector3D.PLUS_Z, Vector3D.PLUS_Y),
+ XZY(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y),
/** Set of Tait-Bryan angles around the <strong>Y</strong>, <strong>X</strong>, and
* <strong>Z</strong> axes in that order.
*/
- YXZ(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_Y, Vector3D.PLUS_X, Vector3D.PLUS_Z),
+ YXZ(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z),
/** Set of Tait-Bryan angles around the <strong>Y</strong>, <strong>Z</strong>, and
* <strong>X</strong> axes in that order.
*/
- YZX(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_Y, Vector3D.PLUS_Z, Vector3D.PLUS_X),
+ YZX(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X),
/** Set of Cardan angles.
* this ordered set of rotations is around Z, then around X, then
* around Y
*/
- ZXY(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y),
+ ZXY(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y),
/** Set of Tait-Bryan angles around the <strong>Z</strong>, <strong>Y</strong>, and
* <strong>X</strong> axes in that order.
*/
- ZYX(AxisSequenceType.TAIT_BRYAN, Vector3D.PLUS_Z, Vector3D.PLUS_Y, Vector3D.PLUS_X),
+ ZYX(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X),
/** Set of Euler angles around the <strong>X</strong>, <strong>Y</strong>, and
* <strong>X</strong> axes in that order.
*/
- XYX(AxisSequenceType.EULER, Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.PLUS_X),
+ XYX(AxisSequenceType.EULER, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X),
/** Set of Euler angles around the <strong>X</strong>, <strong>Z</strong>, and
* <strong>X</strong> axes in that order.
*/
- XZX(AxisSequenceType.EULER, Vector3D.PLUS_X, Vector3D.PLUS_Z, Vector3D.PLUS_X),
+ XZX(AxisSequenceType.EULER, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X),
/** Set of Euler angles around the <strong>Y</strong>, <strong>X</strong>, and
* <strong>Y</strong> axes in that order.
*/
- YXY(AxisSequenceType.EULER, Vector3D.PLUS_Y, Vector3D.PLUS_X, Vector3D.PLUS_Y),
+ YXY(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y),
/** Set of Euler angles around the <strong>Y</strong>, <strong>Z</strong>, and
* <strong>Y</strong> axes in that order.
*/
- YZY(AxisSequenceType.EULER, Vector3D.PLUS_Y, Vector3D.PLUS_Z, Vector3D.PLUS_Y),
+ YZY(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y),
/** Set of Euler angles around the <strong>Z</strong>, <strong>X</strong>, and
* <strong>Z</strong> axes in that order.
*/
- ZXZ(AxisSequenceType.EULER, Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Z),
+ ZXZ(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z),
/** Set of Euler angles around the <strong>Z</strong>, <strong>Y</strong>, and
* <strong>Z</strong> axes in that order.
*/
- ZYZ(AxisSequenceType.EULER, Vector3D.PLUS_Z, Vector3D.PLUS_Y, Vector3D.PLUS_Z);
+ ZYZ(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z);
/** The type of axis sequence. */
private final AxisSequenceType type;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
index 2e67ce5..b32762f 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotation.java
@@ -94,7 +94,7 @@ public final class QuaternionRotation implements Rotation3D, Serializable {
return Vector3D.Unit.from(quat.getX(), quat.getY(), quat.getZ());
}
catch (IllegalNormException exc) {
- return Vector3D.PLUS_X;
+ return Vector3D.Unit.PLUS_X;
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
index b0d6665..d6ba2de 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Vector2D.java
@@ -30,19 +30,7 @@ import org.apache.commons.numbers.arrays.LinearCombination;
public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
/** Zero vector (coordinates: 0, 0). */
- public static final Vector2D ZERO = new Vector2D(0, 0);
-
- /** Unit vector pointing in the direction of the positive x-axis. */
- public static final Vector2D PLUS_X = Unit.PLUS_X;
-
- /** Unit vector pointing in the direction of the negative x-axis. */
- public static final Vector2D MINUS_X = Unit.MINUS_X;
-
- /** Unit vector pointing in the direction of the positive y-axis. */
- public static final Vector2D PLUS_Y = Unit.PLUS_Y;
-
- /** Unit vector pointing in the direction of the negative y-axis. */
- public static final Vector2D MINUS_Y = Unit.MINUS_Y;
+ public static final Vector2D ZERO = new Vector2D(0, 0);
// CHECKSTYLE: stop ConstantName
/** A vector with all coordinates set to NaN. */
@@ -517,17 +505,17 @@ public class Vector2D extends MultiDimensionalEuclideanVector<Vector2D> {
/**
* Represents unit vectors.
- * This allows optimizations to be performed for certain operations.
+ * This allows optimizations for certain operations.
*/
public static final class Unit extends Vector2D {
/** Unit vector (coordinates: 1, 0). */
- static final Unit PLUS_X = new Unit(1d, 0d);
+ public static final Unit PLUS_X = new Unit(1d, 0d);
/** Negation of unit vector (coordinates: -1, 0). */
- static final Unit MINUS_X = new Unit(-1d, 0d);
+ public static final Unit MINUS_X = new Unit(-1d, 0d);
/** Unit vector (coordinates: 0, 1). */
- static final Unit PLUS_Y = new Unit(0d, 1d);
+ public static final Unit PLUS_Y = new Unit(0d, 1d);
/** Negation of unit vector (coordinates: 0, -1). */
- static final Unit MINUS_Y = new Unit(0d, -1d);
+ public static final Unit MINUS_Y = new Unit(0d, -1d);
/** Serializable version identifier */
private static final long serialVersionUID = 20180903L;
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
index ef5022d..87cc71f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/AffineTransformMatrix1DTest.java
@@ -386,7 +386,7 @@ public class AffineTransformMatrix1DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(0).applyDirection(Vector1D.ONE),
+ GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(0).applyDirection(Vector1D.Unit.PLUS),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix1D.createScale(2).applyDirection(Vector1D.ZERO),
IllegalNormException.class);
@@ -531,7 +531,7 @@ public class AffineTransformMatrix1DTest {
public void testInverse_undoesOriginalTransform_translationAndScale() {
// arrange
Vector1D v1 = Vector1D.ZERO;
- Vector1D v2 = Vector1D.ONE;
+ Vector1D v2 = Vector1D.Unit.PLUS;
Vector1D v3 = Vector1D.of(1.5);
Vector1D v4 = Vector1D.of(-2);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
index e1aa221..f0d2dff 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/OrientedPointTest.java
@@ -35,10 +35,10 @@ public class OrientedPointTest {
@Test
public void testGetDirection() {
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.ONE,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.Unit.PLUS,
OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), true, TEST_PRECISION).getDirection(),
TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.MINUS_ONE,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.Unit.MINUS,
OrientedPoint.fromPointAndDirection(Vector1D.of(2.0), false, TEST_PRECISION).getDirection(),
TEST_EPS);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
index 3cd2534..a0d7804 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/Vector1DTest.java
@@ -35,8 +35,8 @@ public class Vector1DTest {
public void testConstants() {
// act/assert
checkVector(Vector1D.ZERO, 0.0);
- checkVector(Vector1D.ONE, 1.0);
- checkVector(Vector1D.MINUS_ONE, -1.0);
+ checkVector(Vector1D.Unit.PLUS, 1.0);
+ checkVector(Vector1D.Unit.MINUS, -1.0);
checkVector(Vector1D.NaN, Double.NaN);
checkVector(Vector1D.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
checkVector(Vector1D.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
@@ -54,8 +54,8 @@ public class Vector1DTest {
GeometryTestUtils.assertThrows(() -> Vector1D.NEGATIVE_INFINITY.normalize(),
IllegalNormException.class);
- Assert.assertSame(Vector1D.ONE.normalize(), Vector1D.ONE);
- Assert.assertSame(Vector1D.MINUS_ONE.normalize(), Vector1D.MINUS_ONE);
+ Assert.assertSame(Vector1D.Unit.PLUS.normalize(), Vector1D.Unit.PLUS);
+ Assert.assertSame(Vector1D.Unit.MINUS.normalize(), Vector1D.Unit.MINUS);
}
@Test
@@ -101,7 +101,7 @@ public class Vector1DTest {
// assert
checkVector(zero, 0.0);
- checkVector(Vector1D.ONE.add(zero), 1.0);
+ checkVector(Vector1D.Unit.PLUS.add(zero), 1.0);
}
@Test
@@ -141,7 +141,7 @@ public class Vector1DTest {
@Test
public void testWithNorm() {
// act/assert
- checkVector(Vector1D.ONE.withNorm(0.0), 0.0);
+ checkVector(Vector1D.Unit.PLUS.withNorm(0.0), 0.0);
checkVector(Vector1D.of(0.5).withNorm(2.0), 2.0);
checkVector(Vector1D.of(5).withNorm(3.0), 3.0);
@@ -169,8 +169,8 @@ public class Vector1DTest {
Vector1D v = Vector1D.of(2.0).normalize();
// act/assert
- checkVector(Vector1D.ONE.withNorm(2.5), 2.5);
- checkVector(Vector1D.MINUS_ONE.withNorm(3.14), -3.14);
+ checkVector(Vector1D.Unit.PLUS.withNorm(2.5), 2.5);
+ checkVector(Vector1D.Unit.MINUS.withNorm(3.14), -3.14);
for (double mag = -10.0; mag <= 10.0; ++mag)
{
@@ -598,7 +598,7 @@ public class Vector1DTest {
checkVector(Vector1D.parse("(NaN)"), Double.NaN);
checkVector(Vector1D.parse(Vector1D.ZERO.toString()), 0);
- checkVector(Vector1D.parse(Vector1D.ONE.toString()), 1);
+ checkVector(Vector1D.parse(Vector1D.Unit.PLUS.toString()), 1);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
index 2f4bfa9..754532e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AffineTransformMatrix3DTest.java
@@ -249,7 +249,7 @@ public class AffineTransformMatrix3DTest {
public void testCreateRotation() {
// arrange
Vector3D center = Vector3D.of(1, 2, 3);
- QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI);
+ QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI);
// act
AffineTransformMatrix3D result = AffineTransformMatrix3D.createRotation(center, rotation);
@@ -272,7 +272,7 @@ public class AffineTransformMatrix3DTest {
9, 10, 11, 12
);
- QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI);
+ QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI);
// act
AffineTransformMatrix3D result = a.rotate(rotation);
@@ -296,7 +296,7 @@ public class AffineTransformMatrix3DTest {
);
Vector3D center = Vector3D.of(1, 2, 3);
- QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI);
+ QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI);
// act
AffineTransformMatrix3D result = a.rotate(center, rotation);
@@ -431,7 +431,7 @@ public class AffineTransformMatrix3DTest {
// arrange
double scaleFactor = 2;
Vector3D center = Vector3D.of(3, -4, 5);
- QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI);
+ QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI);
AffineTransformMatrix3D transform = AffineTransformMatrix3D.identity()
.scale(scaleFactor)
@@ -504,7 +504,7 @@ public class AffineTransformMatrix3DTest {
AffineTransformMatrix3D transform = AffineTransformMatrix3D.identity()
.scale(1.5)
.translate(4, 6, 5)
- .rotate(QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI));
+ .rotate(QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI));
// act/assert
runWithCoordinates((x, y, z) -> {
@@ -572,7 +572,7 @@ public class AffineTransformMatrix3DTest {
AffineTransformMatrix3D transform = AffineTransformMatrix3D.identity()
.scale(1.5)
.translate(4, 6, 5)
- .rotate(QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI));
+ .rotate(QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI));
// act/assert
runWithCoordinates((x, y, z) -> {
@@ -588,7 +588,7 @@ public class AffineTransformMatrix3DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(1, 0, 1).applyDirection(Vector3D.PLUS_Y),
+ GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(1, 0, 1).applyDirection(Vector3D.Unit.PLUS_Y),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix3D.createScale(2).applyDirection(Vector3D.ZERO),
IllegalNormException.class);
@@ -777,7 +777,7 @@ public class AffineTransformMatrix3DTest {
public void testInverse_rotate() {
// arrange
Vector3D center = Vector3D.of(1, 2, 3);
- QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI);
+ QuaternionRotation rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI);
AffineTransformMatrix3D transform = AffineTransformMatrix3D.createRotation(center, rotation);
@@ -797,7 +797,7 @@ public class AffineTransformMatrix3DTest {
public void testInverse_undoesOriginalTransform() {
// arrange
Vector3D v1 = Vector3D.ZERO;
- Vector3D v2 = Vector3D.PLUS_X;
+ Vector3D v2 = Vector3D.Unit.PLUS_X;
Vector3D v3 = Vector3D.of(1, 1, 1);
Vector3D v4 = Vector3D.of(-2, 3, 4);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
index 9757ce3..d28c713 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlaneTest.java
@@ -222,7 +222,7 @@ public class PlaneTest {
Plane plane = Plane.fromPoints(pts, TEST_PRECISION);
// assert
- checkPlane(plane, Vector3D.PLUS_Y, Vector3D.MINUS_Z, Vector3D.MINUS_X);
+ checkPlane(plane, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Z, Vector3D.Unit.MINUS_X);
Assert.assertTrue(plane.contains(pts.get(0)));
Assert.assertTrue(plane.contains(pts.get(1)));
@@ -243,7 +243,7 @@ public class PlaneTest {
Plane plane = Plane.fromPoints(pts, TEST_PRECISION);
// assert
- checkPlane(plane, Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.PLUS_Y);
+ checkPlane(plane, Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y);
Assert.assertTrue(plane.contains(pts.get(0)));
Assert.assertTrue(plane.contains(pts.get(1)));
@@ -275,9 +275,9 @@ public class PlaneTest {
// act
checkPlane(Plane.fromPoints(pts, TEST_PRECISION),
- origin, Vector3D.MINUS_Z, Vector3D.PLUS_Y);
+ origin, Vector3D.Unit.MINUS_Z, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(rotate(pts, 1), TEST_PRECISION),
- origin, Vector3D.MINUS_Z, Vector3D.PLUS_Y);
+ origin, Vector3D.Unit.MINUS_Z, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(rotate(pts, 2), TEST_PRECISION),
origin, Vector3D.Unit.from(0, 1, -1), Vector3D.Unit.from(0, 1, 1));
@@ -298,12 +298,12 @@ public class PlaneTest {
origin, Vector3D.Unit.from(0, -1, 0.5), Vector3D.Unit.from(0, -0.5, -1));
checkPlane(Plane.fromPoints(rotate(pts, 9), TEST_PRECISION),
- origin, Vector3D.PLUS_Z, Vector3D.MINUS_Y);
+ origin, Vector3D.Unit.PLUS_Z, Vector3D.Unit.MINUS_Y);
checkPlane(Plane.fromPoints(rotate(pts, 10), TEST_PRECISION),
- origin, Vector3D.PLUS_Z, Vector3D.MINUS_Y);
+ origin, Vector3D.Unit.PLUS_Z, Vector3D.Unit.MINUS_Y);
checkPlane(Plane.fromPoints(rotate(pts, 11), TEST_PRECISION),
- origin, Vector3D.MINUS_Z, Vector3D.PLUS_Y);
+ origin, Vector3D.Unit.MINUS_Z, Vector3D.Unit.PLUS_Y);
}
@Test
@@ -314,14 +314,14 @@ public class PlaneTest {
Vector3D.of(2, 0, 2),
Vector3D.of(3, 0, 2),
Vector3D.of(3.5, 1, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.PLUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(1, 0, 2),
Vector3D.of(2, 0, 2),
Vector3D.of(3, 0, 2),
Vector3D.of(3.5, -1, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.MINUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.MINUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(1, 0, 2),
@@ -329,7 +329,7 @@ public class PlaneTest {
Vector3D.of(3, 0, 2),
Vector3D.of(3.5, -1, 2),
Vector3D.of(4, 0, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.PLUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(1, 0, 2),
@@ -337,7 +337,7 @@ public class PlaneTest {
Vector3D.of(3, 0, 2),
Vector3D.of(3.5, 1, 2),
Vector3D.of(4, -1, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.MINUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.MINUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(0, 0, 2),
@@ -345,7 +345,7 @@ public class PlaneTest {
Vector3D.of(1, 1, 2),
Vector3D.of(0, 1, 2),
Vector3D.of(0, 0, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.PLUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(0, 0, 2),
@@ -353,7 +353,7 @@ public class PlaneTest {
Vector3D.of(1, 1, 2),
Vector3D.of(1, 0, 2),
Vector3D.of(0, 0, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_Y, Vector3D.PLUS_X);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(0, 0, 2),
@@ -362,7 +362,7 @@ public class PlaneTest {
Vector3D.of(3, 0, 2),
Vector3D.of(2, 4, 2),
Vector3D.of(0, 0, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_X, Vector3D.PLUS_Y);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y);
checkPlane(Plane.fromPoints(Arrays.asList(
Vector3D.of(0, 0, 2),
@@ -371,14 +371,14 @@ public class PlaneTest {
Vector3D.of(3, 0, 2),
Vector3D.of(2, 1, 2),
Vector3D.of(0, 0, 2)
- ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.PLUS_Y, Vector3D.PLUS_X);
+ ), TEST_PRECISION), Vector3D.of(0, 0, 2), Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X);
}
@Test
public void testFromPoints_collection_illegalArguments() {
// arrange
Vector3D a = Vector3D.ZERO;
- Vector3D b = Vector3D.PLUS_X;
+ Vector3D b = Vector3D.Unit.PLUS_X;
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -400,7 +400,7 @@ public class PlaneTest {
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(Arrays.asList(
Vector3D.ZERO,
- Vector3D.PLUS_X,
+ Vector3D.Unit.PLUS_X,
Vector3D.of(2, 0, 0)
), TEST_PRECISION);
}, GeometryException.class);
@@ -408,7 +408,7 @@ public class PlaneTest {
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(Arrays.asList(
Vector3D.ZERO,
- Vector3D.PLUS_X,
+ Vector3D.Unit.PLUS_X,
Vector3D.of(2, 0, 0),
Vector3D.of(3, 0, 0)
), TEST_PRECISION);
@@ -423,7 +423,7 @@ public class PlaneTest {
Vector3D.ZERO,
Vector3D.ZERO,
Vector3D.of(1e-12, 1e-12, 0),
- Vector3D.PLUS_X
+ Vector3D.Unit.PLUS_X
), TEST_PRECISION);
}, GeometryException.class);
@@ -442,9 +442,9 @@ public class PlaneTest {
GeometryTestUtils.assertThrows(() -> {
Plane.fromPoints(Arrays.asList(
Vector3D.ZERO,
- Vector3D.PLUS_X,
- Vector3D.PLUS_Y,
- Vector3D.PLUS_Z
+ Vector3D.Unit.PLUS_X,
+ Vector3D.Unit.PLUS_Y,
+ Vector3D.Unit.PLUS_Z
), TEST_PRECISION);
}, GeometryException.class);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
index fe38389..228f3fc 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PolyhedronsSetTest.java
@@ -96,7 +96,7 @@ public class PolyhedronsSetTest {
public void testHalfSpace() {
// arrange
List<SubHyperplane<Vector3D>> boundaries = new ArrayList<>();
- boundaries.add(new SubPlane(Plane.fromPointAndNormal(Vector3D.ZERO, Vector3D.PLUS_Y, TEST_PRECISION),
+ boundaries.add(new SubPlane(Plane.fromPointAndNormal(Vector3D.ZERO, Vector3D.Unit.PLUS_Y, TEST_PRECISION),
new PolygonsSet(TEST_PRECISION)));
// act
@@ -1013,8 +1013,8 @@ public class PolyhedronsSetTest {
PolyhedronsSet polySet = new PolyhedronsSet(boundaries, TEST_PRECISION);
Vector3D pt = Vector3D.of(0.5, 0.5, 0);
- Line intoBoxLine = new Line(pt, pt.add(Vector3D.PLUS_Z), TEST_PRECISION);
- Line outOfBoxLine = new Line(pt, pt.add(Vector3D.MINUS_Z), TEST_PRECISION);
+ Line intoBoxLine = new Line(pt, pt.add(Vector3D.Unit.PLUS_Z), TEST_PRECISION);
+ Line outOfBoxLine = new Line(pt, pt.add(Vector3D.Unit.MINUS_Z), TEST_PRECISION);
// act/assert
SubPlane intoBoxResult = (SubPlane) polySet.firstIntersection(pt, intoBoxLine);
@@ -1517,12 +1517,12 @@ public class PolyhedronsSetTest {
double offset = size * 0.5;
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(eps);
- Plane xMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(-offset, 0, 0)), Vector3D.MINUS_X, precision);
- Plane xPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(offset, 0, 0)), Vector3D.PLUS_X, precision);
- Plane yPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, offset, 0)), Vector3D.PLUS_Y, precision);
- Plane yMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, -offset, 0)), Vector3D.MINUS_Y, precision);
- Plane zPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, offset)), Vector3D.PLUS_Z, precision);
- Plane zMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, -offset)), Vector3D.MINUS_Z, precision);
+ Plane xMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(-offset, 0, 0)), Vector3D.Unit.MINUS_X, precision);
+ Plane xPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(offset, 0, 0)), Vector3D.Unit.PLUS_X, precision);
+ Plane yPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, offset, 0)), Vector3D.Unit.PLUS_Y, precision);
+ Plane yMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, -offset, 0)), Vector3D.Unit.MINUS_Y, precision);
+ Plane zPlus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, offset)), Vector3D.Unit.PLUS_Z, precision);
+ Plane zMinus = Plane.fromPointAndNormal(center.add(Vector3D.of(0, 0, -offset)), Vector3D.Unit.MINUS_Z, precision);
// +x
boundaries.add(createSubPlane(xPlus,
@@ -1587,8 +1587,8 @@ public class PolyhedronsSetTest {
Vector3D topZ = Vector3D.of(center.getX(), center.getY(), center.getZ() + radius);
Vector3D bottomZ = Vector3D.of(center.getX(), center.getY(), center.getZ() - radius);
- planes.add(Plane.fromPointAndNormal(topZ, Vector3D.PLUS_Z, TEST_PRECISION));
- planes.add(Plane.fromPointAndNormal(bottomZ, Vector3D.MINUS_Z, TEST_PRECISION));
+ planes.add(Plane.fromPointAndNormal(topZ, Vector3D.Unit.PLUS_Z, TEST_PRECISION));
+ planes.add(Plane.fromPointAndNormal(bottomZ, Vector3D.Unit.MINUS_Z, TEST_PRECISION));
// add the side planes
double vDelta = Math.PI / stacks;
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
index f46b85a..9f55682 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Vector3DTest.java
@@ -40,14 +40,14 @@ public class Vector3DTest {
// act/assert
checkVector(Vector3D.ZERO, 0, 0, 0);
- checkVector(Vector3D.PLUS_X, 1, 0, 0);
- checkVector(Vector3D.MINUS_X, -1, 0, 0);
+ checkVector(Vector3D.Unit.PLUS_X, 1, 0, 0);
+ checkVector(Vector3D.Unit.MINUS_X, -1, 0, 0);
- checkVector(Vector3D.PLUS_Y, 0, 1, 0);
- checkVector(Vector3D.MINUS_Y, 0, -1, 0);
+ checkVector(Vector3D.Unit.PLUS_Y, 0, 1, 0);
+ checkVector(Vector3D.Unit.MINUS_Y, 0, -1, 0);
- checkVector(Vector3D.PLUS_Z, 0, 0, 1);
- checkVector(Vector3D.MINUS_Z, 0, 0, -1);
+ checkVector(Vector3D.Unit.PLUS_Z, 0, 0, 1);
+ checkVector(Vector3D.Unit.MINUS_Z, 0, 0, -1);
checkVector(Vector3D.NaN, Double.NaN, Double.NaN, Double.NaN);
checkVector(Vector3D.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
@@ -66,14 +66,14 @@ public class Vector3DTest {
GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.normalize(),
IllegalNormException.class);
- Assert.assertSame(Vector3D.PLUS_X.normalize(), Vector3D.PLUS_X);
- Assert.assertSame(Vector3D.MINUS_X.normalize(), Vector3D.MINUS_X);
+ Assert.assertSame(Vector3D.Unit.PLUS_X.normalize(), Vector3D.Unit.PLUS_X);
+ Assert.assertSame(Vector3D.Unit.MINUS_X.normalize(), Vector3D.Unit.MINUS_X);
- Assert.assertSame(Vector3D.PLUS_Y.normalize(), Vector3D.PLUS_Y);
- Assert.assertSame(Vector3D.MINUS_Y.normalize(), Vector3D.MINUS_Y);
+ Assert.assertSame(Vector3D.Unit.PLUS_Y.normalize(), Vector3D.Unit.PLUS_Y);
+ Assert.assertSame(Vector3D.Unit.MINUS_Y.normalize(), Vector3D.Unit.MINUS_Y);
- Assert.assertSame(Vector3D.PLUS_Z.normalize(), Vector3D.PLUS_Z);
- Assert.assertSame(Vector3D.MINUS_Z.normalize(), Vector3D.MINUS_Z);
+ Assert.assertSame(Vector3D.Unit.PLUS_Z.normalize(), Vector3D.Unit.PLUS_Z);
+ Assert.assertSame(Vector3D.Unit.MINUS_Z.normalize(), Vector3D.Unit.MINUS_Z);
}
@Test
@@ -242,9 +242,9 @@ public class Vector3DTest {
Vector3D v = Vector3D.of(2.0, -3.0, 4.0).normalize();
// act/assert
- checkVector(Vector3D.PLUS_X.withNorm(2.5), 2.5, 0.0, 0.0);
- checkVector(Vector3D.MINUS_Y.withNorm(3.14), 0.0, -3.14, 0.0);
- checkVector(Vector3D.PLUS_Z.withNorm(-1.1), 0.0, 0.0, -1.1);
+ checkVector(Vector3D.Unit.PLUS_X.withNorm(2.5), 2.5, 0.0, 0.0);
+ checkVector(Vector3D.Unit.MINUS_Y.withNorm(3.14), 0.0, -3.14, 0.0);
+ checkVector(Vector3D.Unit.PLUS_Z.withNorm(-1.1), 0.0, 0.0, -1.1);
for (double mag = -10.0; mag <= 10.0; ++mag)
{
@@ -421,9 +421,9 @@ public class Vector3DTest {
double invSqrt2 = 1.0 / Math.sqrt(2.0);
// act/assert
- checkVector(Vector3D.PLUS_X.orthogonal(Vector3D.of(-1.0, 0.1, 0.0)), 0.0, 1.0, 0.0);
- checkVector(Vector3D.PLUS_Y.orthogonal(Vector3D.of(2.0, 2.0, 2.0)), invSqrt2, 0.0, invSqrt2);
- checkVector(Vector3D.PLUS_Z.orthogonal(Vector3D.of(3.0, 3.0, -3.0)), invSqrt2, invSqrt2, 0.0);
+ checkVector(Vector3D.Unit.PLUS_X.orthogonal(Vector3D.of(-1.0, 0.1, 0.0)), 0.0, 1.0, 0.0);
+ checkVector(Vector3D.Unit.PLUS_Y.orthogonal(Vector3D.of(2.0, 2.0, 2.0)), invSqrt2, 0.0, invSqrt2);
+ checkVector(Vector3D.Unit.PLUS_Z.orthogonal(Vector3D.of(3.0, 3.0, -3.0)), invSqrt2, invSqrt2, 0.0);
checkVector(Vector3D.of(invSqrt2, invSqrt2, 0.0).orthogonal(Vector3D.of(1.0, 1.0, 0.2)), 0.0, 0.0, 1.0);
}
@@ -431,31 +431,31 @@ public class Vector3DTest {
@Test
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.ZERO.orthogonal(Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.NaN.orthogonal(Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.orthogonal(Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.POSITIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.orthogonal(Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.NEGATIVE_INFINITY.orthogonal(Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.ZERO),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.ZERO),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.NaN),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NaN),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.POSITIVE_INFINITY),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.NEGATIVE_INFINITY),
IllegalNormException.class);
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector3D.PLUS_X.orthogonal(Vector3D.MINUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector3D.Unit.PLUS_X.orthogonal(Vector3D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> Vector3D.of(1.0, 1.0, 1.0).orthogonal(Vector3D.of(2.0, 2.0, 2.0)),
IllegalNormException.class);
@@ -476,13 +476,13 @@ public class Vector3DTest {
Assert.assertEquals(7.98595620686106654517199e-8, v1.angle(Vector3D.of(2, 4, 6.000001)), tolerance);
Assert.assertEquals(3.14159257373023116985197793156, v1.angle(Vector3D.of(-2, -4, -6.000001)), tolerance);
- Assert.assertEquals(0.0, Vector3D.PLUS_X.angle(Vector3D.PLUS_X), tolerance);
- Assert.assertEquals(Geometry.PI, Vector3D.PLUS_X.angle(Vector3D.MINUS_X), tolerance);
+ Assert.assertEquals(0.0, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.PLUS_X), tolerance);
+ Assert.assertEquals(Geometry.PI, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.MINUS_X), tolerance);
- Assert.assertEquals(Geometry.HALF_PI, Vector3D.PLUS_X.angle(Vector3D.PLUS_Y), tolerance);
- Assert.assertEquals(Geometry.HALF_PI, Vector3D.PLUS_X.angle(Vector3D.MINUS_Y), tolerance);
- Assert.assertEquals(Geometry.HALF_PI, Vector3D.PLUS_X.angle(Vector3D.PLUS_Z), tolerance);
- Assert.assertEquals(Geometry.HALF_PI, Vector3D.PLUS_X.angle(Vector3D.MINUS_Z), tolerance);
+ Assert.assertEquals(Geometry.HALF_PI, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.PLUS_Y), tolerance);
+ Assert.assertEquals(Geometry.HALF_PI, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.MINUS_Y), tolerance);
+ Assert.assertEquals(Geometry.HALF_PI, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.PLUS_Z), tolerance);
+ Assert.assertEquals(Geometry.HALF_PI, Vector3D.Unit.PLUS_X.angle(Vector3D.Unit.MINUS_Z), tolerance);
}
@Test
@@ -526,11 +526,11 @@ public class Vector3DTest {
@Test
public void testCrossProduct() {
// act/assert
- checkVector(Vector3D.PLUS_X.cross(Vector3D.PLUS_Y), 0, 0, 1);
- checkVector(Vector3D.PLUS_X.cross(Vector3D.MINUS_Y), 0, 0, -1);
+ checkVector(Vector3D.Unit.PLUS_X.cross(Vector3D.Unit.PLUS_Y), 0, 0, 1);
+ checkVector(Vector3D.Unit.PLUS_X.cross(Vector3D.Unit.MINUS_Y), 0, 0, -1);
- checkVector(Vector3D.MINUS_X.cross(Vector3D.MINUS_Y), 0, 0, 1);
- checkVector(Vector3D.MINUS_X.cross(Vector3D.PLUS_Y), 0, 0, -1);
+ checkVector(Vector3D.Unit.MINUS_X.cross(Vector3D.Unit.MINUS_Y), 0, 0, 1);
+ checkVector(Vector3D.Unit.MINUS_X.cross(Vector3D.Unit.PLUS_Y), 0, 0, -1);
checkVector(Vector3D.of(2, 1, -4).cross(Vector3D.of(3, 1, -1)), 3, -10, -1);
@@ -734,21 +734,21 @@ public class Vector3DTest {
Vector3D v2 = Vector3D.of(-5.0, -6.0, -7.0);
// act/assert
- checkVector(Vector3D.ZERO.project(Vector3D.PLUS_X), 0.0, 0.0, 0.0);
-
- checkVector(v1.project(Vector3D.PLUS_X), 2.0, 0.0, 0.0);
- checkVector(v1.project(Vector3D.MINUS_X), 2.0, 0.0, 0.0);
- checkVector(v1.project(Vector3D.PLUS_Y), 0.0, 3.0, 0.0);
- checkVector(v1.project(Vector3D.MINUS_Y), 0.0, 3.0, 0.0);
- checkVector(v1.project(Vector3D.PLUS_Z), 0.0, 0.0, 4.0);
- checkVector(v1.project(Vector3D.MINUS_Z), 0.0, 0.0, 4.0);
-
- checkVector(v2.project(Vector3D.PLUS_X), -5.0, 0.0, 0.0);
- checkVector(v2.project(Vector3D.MINUS_X), -5.0, 0.0, 0.0);
- checkVector(v2.project(Vector3D.PLUS_Y), 0.0, -6.0, 0.0);
- checkVector(v2.project(Vector3D.MINUS_Y), 0.0, -6.0, 0.0);
- checkVector(v2.project(Vector3D.PLUS_Z), 0.0, 0.0, -7.0);
- checkVector(v2.project(Vector3D.MINUS_Z), 0.0, 0.0, -7.0);
+ checkVector(Vector3D.ZERO.project(Vector3D.Unit.PLUS_X), 0.0, 0.0, 0.0);
+
+ checkVector(v1.project(Vector3D.Unit.PLUS_X), 2.0, 0.0, 0.0);
+ checkVector(v1.project(Vector3D.Unit.MINUS_X), 2.0, 0.0, 0.0);
+ checkVector(v1.project(Vector3D.Unit.PLUS_Y), 0.0, 3.0, 0.0);
+ checkVector(v1.project(Vector3D.Unit.MINUS_Y), 0.0, 3.0, 0.0);
+ checkVector(v1.project(Vector3D.Unit.PLUS_Z), 0.0, 0.0, 4.0);
+ checkVector(v1.project(Vector3D.Unit.MINUS_Z), 0.0, 0.0, 4.0);
+
+ checkVector(v2.project(Vector3D.Unit.PLUS_X), -5.0, 0.0, 0.0);
+ checkVector(v2.project(Vector3D.Unit.MINUS_X), -5.0, 0.0, 0.0);
+ checkVector(v2.project(Vector3D.Unit.PLUS_Y), 0.0, -6.0, 0.0);
+ checkVector(v2.project(Vector3D.Unit.MINUS_Y), 0.0, -6.0, 0.0);
+ checkVector(v2.project(Vector3D.Unit.PLUS_Z), 0.0, 0.0, -7.0);
+ checkVector(v2.project(Vector3D.Unit.MINUS_Z), 0.0, 0.0, -7.0);
checkVector(v1.project(Vector3D.of(1.0, 1.0, 1.0)), 3.0, 3.0, 3.0);
checkVector(v1.project(Vector3D.of(-1.0, -1.0, -1.0)), 3.0, 3.0, 3.0);
@@ -780,21 +780,21 @@ public class Vector3DTest {
Vector3D v2 = Vector3D.of(-5.0, -6.0, -7.0);
// act/assert
- checkVector(Vector3D.ZERO.reject(Vector3D.PLUS_X), 0.0, 0.0, 0.0);
-
- checkVector(v1.reject(Vector3D.PLUS_X), 0.0, 3.0, 4.0);
- checkVector(v1.reject(Vector3D.MINUS_X), 0.0, 3.0, 4.0);
- checkVector(v1.reject(Vector3D.PLUS_Y), 2.0, 0.0, 4.0);
- checkVector(v1.reject(Vector3D.MINUS_Y), 2.0, 0.0, 4.0);
- checkVector(v1.reject(Vector3D.PLUS_Z), 2.0, 3.0, 0.0);
- checkVector(v1.reject(Vector3D.MINUS_Z), 2.0, 3.0, 0.0);
-
- checkVector(v2.reject(Vector3D.PLUS_X), 0.0, -6.0, -7.0);
- checkVector(v2.reject(Vector3D.MINUS_X), 0.0, -6.0, -7.0);
- checkVector(v2.reject(Vector3D.PLUS_Y), -5.0, 0.0, -7.0);
- checkVector(v2.reject(Vector3D.MINUS_Y), -5.0, 0.0, -7.0);
- checkVector(v2.reject(Vector3D.PLUS_Z), -5.0, -6.0, 0.0);
- checkVector(v2.reject(Vector3D.MINUS_Z), -5.0, -6.0, 0.0);
+ checkVector(Vector3D.ZERO.reject(Vector3D.Unit.PLUS_X), 0.0, 0.0, 0.0);
+
+ checkVector(v1.reject(Vector3D.Unit.PLUS_X), 0.0, 3.0, 4.0);
+ checkVector(v1.reject(Vector3D.Unit.MINUS_X), 0.0, 3.0, 4.0);
+ checkVector(v1.reject(Vector3D.Unit.PLUS_Y), 2.0, 0.0, 4.0);
+ checkVector(v1.reject(Vector3D.Unit.MINUS_Y), 2.0, 0.0, 4.0);
+ checkVector(v1.reject(Vector3D.Unit.PLUS_Z), 2.0, 3.0, 0.0);
+ checkVector(v1.reject(Vector3D.Unit.MINUS_Z), 2.0, 3.0, 0.0);
+
+ checkVector(v2.reject(Vector3D.Unit.PLUS_X), 0.0, -6.0, -7.0);
+ checkVector(v2.reject(Vector3D.Unit.MINUS_X), 0.0, -6.0, -7.0);
+ checkVector(v2.reject(Vector3D.Unit.PLUS_Y), -5.0, 0.0, -7.0);
+ checkVector(v2.reject(Vector3D.Unit.MINUS_Y), -5.0, 0.0, -7.0);
+ checkVector(v2.reject(Vector3D.Unit.PLUS_Z), -5.0, -6.0, 0.0);
+ checkVector(v2.reject(Vector3D.Unit.MINUS_Z), -5.0, -6.0, 0.0);
checkVector(v1.reject(Vector3D.of(1.0, 1.0, 1.0)), -1.0, 0.0, 1.0);
checkVector(v1.reject(Vector3D.of(-1.0, -1.0, -1.0)), -1.0, 0.0, 1.0);
@@ -1097,7 +1097,7 @@ public class Vector3DTest {
checkVector(Vector3D.parse("(NaN, -Infinity, Infinity)"), Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
checkVector(Vector3D.parse(Vector3D.ZERO.toString()), 0, 0, 0);
- checkVector(Vector3D.parse(Vector3D.MINUS_X.toString()), -1, 0, 0);
+ checkVector(Vector3D.parse(Vector3D.Unit.MINUS_X.toString()), -1, 0, 0);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
index fc9ef7e..25bf641 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/AxisSequenceTest.java
@@ -49,13 +49,13 @@ public class AxisSequenceTest {
private Vector3D getAxisForName(String name) {
if ("X".equals(name)) {
- return Vector3D.PLUS_X;
+ return Vector3D.Unit.PLUS_X;
}
if ("Y".equals(name)) {
- return Vector3D.PLUS_Y;
+ return Vector3D.Unit.PLUS_Y;
}
if ("Z".equals(name)) {
- return Vector3D.PLUS_Z;
+ return Vector3D.Unit.PLUS_Z;
}
throw new IllegalArgumentException("Unknown axis: " + name);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
index 0283700..f4f40d0 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/rotation/QuaternionRotationTest.java
@@ -123,7 +123,7 @@ public class QuaternionRotationTest {
QuaternionRotation q = QuaternionRotation.identity();
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, q.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, q.getAxis(), EPS);
}
@Test
@@ -146,7 +146,7 @@ public class QuaternionRotationTest {
QuaternionRotation rot = QuaternionRotation.of(1, 0, 0, 0);
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, rot.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, rot.getAxis(), EPS);
}
@Test
@@ -266,11 +266,11 @@ public class QuaternionRotationTest {
@Test
public void testFromAxisAngle_invalidAngle() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Double.NaN), IllegalArgumentException.class,
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NaN), IllegalArgumentException.class,
"Invalid angle: NaN");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Double.POSITIVE_INFINITY), IllegalArgumentException.class,
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.POSITIVE_INFINITY), IllegalArgumentException.class,
"Invalid angle: Infinity");
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Double.NEGATIVE_INFINITY), IllegalArgumentException.class,
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Double.NEGATIVE_INFINITY), IllegalArgumentException.class,
"Invalid angle: -Infinity");
}
@@ -355,14 +355,14 @@ public class QuaternionRotationTest {
@Test
public void testMultiply_sameAxis_simple() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, 0.1 * Geometry.PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, 0.4 * Geometry.PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, 0.1 * Geometry.PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, 0.4 * Geometry.PI);
// act
QuaternionRotation result = q1.multiply(q2);
// assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, result.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, result.getAxis(), EPS);
Assert.assertEquals(Geometry.HALF_PI, result.getAngle(), EPS);
assertRotationEquals(StandardRotations.PLUS_X_HALF_PI, result);
@@ -391,8 +391,8 @@ public class QuaternionRotationTest {
@Test
public void testMultiply_differentAxes() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.HALF_PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.HALF_PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.HALF_PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.HALF_PI);
// act
QuaternionRotation result = q1.multiply(q2);
@@ -412,9 +412,9 @@ public class QuaternionRotationTest {
@Test
public void testMultiply_orderOfOperations() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.HALF_PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.PI);
- QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Z, Geometry.HALF_PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.HALF_PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.PI);
+ QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Z, Geometry.HALF_PI);
// act
QuaternionRotation result = q3.multiply(q2).multiply(q1);
@@ -456,14 +456,14 @@ public class QuaternionRotationTest {
@Test
public void testPremultiply_sameAxis_simple() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, 0.1 * Geometry.PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, 0.4 * Geometry.PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, 0.1 * Geometry.PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, 0.4 * Geometry.PI);
// act
QuaternionRotation result = q1.premultiply(q2);
// assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, result.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, result.getAxis(), EPS);
Assert.assertEquals(Geometry.HALF_PI, result.getAngle(), EPS);
assertRotationEquals(StandardRotations.PLUS_X_HALF_PI, result);
@@ -492,8 +492,8 @@ public class QuaternionRotationTest {
@Test
public void testPremultiply_differentAxes() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.HALF_PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.HALF_PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.HALF_PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.HALF_PI);
// act
QuaternionRotation result = q2.premultiply(q1);
@@ -513,9 +513,9 @@ public class QuaternionRotationTest {
@Test
public void testPremultiply_orderOfOperations() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.HALF_PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.PI);
- QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Z, Geometry.HALF_PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.HALF_PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.PI);
+ QuaternionRotation q3 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Z, Geometry.HALF_PI);
// act
QuaternionRotation result = q1.premultiply(q2).premultiply(q3);
@@ -531,8 +531,8 @@ public class QuaternionRotationTest {
@Test
public void testSlerp_simple() {
// arrange
- QuaternionRotation q0 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.ZERO_PI);
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.PI);
+ QuaternionRotation q0 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.ZERO_PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.PI);
final Slerp transform = q0.slerp(q1);
Vector3D v = Vector3D.of(2, 0, 1);
@@ -550,29 +550,29 @@ public class QuaternionRotationTest {
public void testSlerp_multipleCombinations() {
// arrange
QuaternionRotation[] rotations = {
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_X, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_X, Geometry.PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_X, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_X, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_X, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_X, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_X, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_X, Geometry.PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Y, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Y, Geometry.PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Y, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Y, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Y, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Y, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Y, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Y, Geometry.PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, Geometry.PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Z, Geometry.ZERO_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Z, Geometry.HALF_PI),
- QuaternionRotation.fromAxisAngle(Vector3D.MINUS_Z, Geometry.PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Z, Geometry.ZERO_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Z, Geometry.HALF_PI),
+ QuaternionRotation.fromAxisAngle(Vector3D.Unit.MINUS_Z, Geometry.PI),
};
// act/assert
@@ -619,8 +619,8 @@ public class QuaternionRotationTest {
@Test
public void testSlerp_followsShortestPath() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, 0.75 * Geometry.PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, -0.75 * Geometry.PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.75 * Geometry.PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, -0.75 * Geometry.PI);
// act
QuaternionRotation result = QuaternionRotation.of(q1.slerp(q2).apply(0.5));
@@ -628,9 +628,9 @@ public class QuaternionRotationTest {
// assert
// the slerp should have followed the path around the pi coordinate of the circle rather than
// the one through the zero coordinate
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.MINUS_X, result.apply(Vector3D.PLUS_X), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_X, result.apply(Vector3D.Unit.PLUS_X), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_Z, result.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Z, result.getAxis(), EPS);
Assert.assertEquals(Geometry.PI, result.getAngle(), EPS);
}
@@ -644,17 +644,17 @@ public class QuaternionRotationTest {
QuaternionRotation result = QuaternionRotation.of(q1.slerp(q2).apply(0.5));
// assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_Y, result.apply(Vector3D.PLUS_X), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Y, result.apply(Vector3D.Unit.PLUS_X), EPS);
Assert.assertEquals(Geometry.HALF_PI, result.getAngle(), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_Z, result.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Z, result.getAxis(), EPS);
}
@Test
public void testSlerp_outputQuaternionIsNormalizedForAllT() {
// arrange
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, 0.25 * Geometry.PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, 0.75 * Geometry.PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.25 * Geometry.PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.75 * Geometry.PI);
final int numSteps = 200;
final double delta = 1d / numSteps;
@@ -672,23 +672,23 @@ public class QuaternionRotationTest {
@Test
public void testSlerp_tOutsideOfZeroToOne_apply() {
// arrange
- Vector3D vec = Vector3D.PLUS_X;
+ Vector3D vec = Vector3D.Unit.PLUS_X;
- QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, 0.25 * Geometry.PI);
- QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.PLUS_Z, 0.75 * Geometry.PI);
+ QuaternionRotation q1 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.25 * Geometry.PI);
+ QuaternionRotation q2 = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.75 * Geometry.PI);
// act/assert
final Slerp slerp12 = q1.slerp(q2);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, QuaternionRotation.of(slerp12.apply(-4.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, QuaternionRotation.of(slerp12.apply(-0.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.MINUS_X, QuaternionRotation.of(slerp12.apply(1.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.MINUS_X, QuaternionRotation.of(slerp12.apply(5.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, QuaternionRotation.of(slerp12.apply(-4.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, QuaternionRotation.of(slerp12.apply(-0.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_X, QuaternionRotation.of(slerp12.apply(1.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_X, QuaternionRotation.of(slerp12.apply(5.5)).apply(vec), EPS);
final Slerp slerp21 = q2.slerp(q1);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.MINUS_X, QuaternionRotation.of(slerp21.apply(-4.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.MINUS_X, QuaternionRotation.of(slerp21.apply(-0.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, QuaternionRotation.of(slerp21.apply(1.5)).apply(vec), EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, QuaternionRotation.of(slerp21.apply(5.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_X, QuaternionRotation.of(slerp21.apply(-4.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.MINUS_X, QuaternionRotation.of(slerp21.apply(-0.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, QuaternionRotation.of(slerp21.apply(1.5)).apply(vec), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, QuaternionRotation.of(slerp21.apply(5.5)).apply(vec), EPS);
}
@Test
@@ -1049,8 +1049,8 @@ public class QuaternionRotationTest {
@Test
public void testCreateVectorRotation_simple() {
// arrange
- Vector3D u1 = Vector3D.PLUS_X;
- Vector3D u2 = Vector3D.PLUS_Y;
+ Vector3D u1 = Vector3D.Unit.PLUS_X;
+ Vector3D u2 = Vector3D.Unit.PLUS_Y;
// act
QuaternionRotation q = QuaternionRotation.createVectorRotation(u1, u2);
@@ -1060,7 +1060,7 @@ public class QuaternionRotationTest {
checkQuaternion(q, val, 0, 0, val);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_Z, q.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_Z, q.getAxis(), EPS);
Assert.assertEquals(Geometry.HALF_PI, q.getAngle(), EPS);
EuclideanTestUtils.assertCoordinatesEqual(u2, q.apply(u1), EPS);
@@ -1079,7 +1079,7 @@ public class QuaternionRotationTest {
// assert
checkQuaternion(q, 1, 0, 0, 0);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, q.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, q.getAxis(), EPS);
Assert.assertEquals(Geometry.ZERO_PI, q.getAngle(), EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 2, 0), q.apply(u1), EPS);
@@ -1098,7 +1098,7 @@ public class QuaternionRotationTest {
// assert
checkQuaternion(q, 1, 0, 0, 0);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.PLUS_X, q.getAxis(), EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.Unit.PLUS_X, q.getAxis(), EPS);
Assert.assertEquals(Geometry.ZERO_PI, q.getAngle(), EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 2, 0), q.apply(u1), EPS);
@@ -1147,27 +1147,27 @@ public class QuaternionRotationTest {
@Test
public void testCreateVectorRotation_invalidArgs() {
// act/assert
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.ZERO, Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.ZERO, Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.PLUS_X, Vector3D.ZERO),
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.ZERO),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.NaN, Vector3D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.NaN, Vector3D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.PLUS_X, Vector3D.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.POSITIVE_INFINITY),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.PLUS_X, Vector3D.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> QuaternionRotation.createVectorRotation(Vector3D.Unit.PLUS_X, Vector3D.NEGATIVE_INFINITY),
IllegalNormException.class);
}
@Test
public void testCreateBasisRotation_simple() {
// arrange
- Vector3D u1 = Vector3D.PLUS_X;
- Vector3D u2 = Vector3D.PLUS_Y;
+ Vector3D u1 = Vector3D.Unit.PLUS_X;
+ Vector3D u2 = Vector3D.Unit.PLUS_Y;
- Vector3D v1 = Vector3D.PLUS_Y;
- Vector3D v2 = Vector3D.MINUS_X;
+ Vector3D v1 = Vector3D.Unit.PLUS_Y;
+ Vector3D v2 = Vector3D.Unit.MINUS_X;
// act
QuaternionRotation q = QuaternionRotation.createBasisRotation(u1, u2, v1, v2);
@@ -1187,11 +1187,11 @@ public class QuaternionRotationTest {
@Test
public void testCreateBasisRotation_diagonalAxis() {
// arrange
- Vector3D u1 = Vector3D.PLUS_X;
- Vector3D u2 = Vector3D.PLUS_Y;
+ Vector3D u1 = Vector3D.Unit.PLUS_X;
+ Vector3D u2 = Vector3D.Unit.PLUS_Y;
- Vector3D v1 = Vector3D.PLUS_Y;
- Vector3D v2 = Vector3D.PLUS_Z;
+ Vector3D v1 = Vector3D.Unit.PLUS_Y;
+ Vector3D v2 = Vector3D.Unit.PLUS_Z;
// act
QuaternionRotation q = QuaternionRotation.createBasisRotation(u1, u2, v1, v2);
@@ -1212,8 +1212,8 @@ public class QuaternionRotationTest {
@Test
public void testCreateBasisRotation_identity() {
// arrange
- Vector3D u1 = Vector3D.PLUS_X;
- Vector3D u2 = Vector3D.PLUS_Y;
+ Vector3D u1 = Vector3D.Unit.PLUS_X;
+ Vector3D u2 = Vector3D.Unit.PLUS_Y;
Vector3D v1 = u1;
Vector3D v2 = u2;
@@ -1312,9 +1312,9 @@ public class QuaternionRotationTest {
Assert.assertTrue(angle >= Geometry.ZERO_PI);
Assert.assertTrue(angle <= Geometry.PI);
- Vector3D transformedX = q.apply(Vector3D.PLUS_X);
- Vector3D transformedY = q.apply(Vector3D.PLUS_Y);
- Vector3D transformedZ = q.apply(Vector3D.PLUS_Z);
+ Vector3D transformedX = q.apply(Vector3D.Unit.PLUS_X);
+ Vector3D transformedY = q.apply(Vector3D.Unit.PLUS_Y);
+ Vector3D transformedZ = q.apply(Vector3D.Unit.PLUS_Z);
Assert.assertEquals(1.0, transformedX.norm(), EPS);
Assert.assertEquals(1.0, transformedY.norm(), EPS);
@@ -1335,24 +1335,24 @@ public class QuaternionRotationTest {
public void testCreateBasisRotation_invalidArgs() {
// act/assert
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.ZERO, Vector3D.PLUS_Y, Vector3D.PLUS_Y, Vector3D.MINUS_X),
+ Vector3D.ZERO, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.PLUS_X, Vector3D.NaN, Vector3D.PLUS_Y, Vector3D.MINUS_X),
+ Vector3D.Unit.PLUS_X, Vector3D.NaN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.POSITIVE_INFINITY, Vector3D.MINUS_X),
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.POSITIVE_INFINITY, Vector3D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.PLUS_Y, Vector3D.NEGATIVE_INFINITY),
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.NEGATIVE_INFINITY),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.PLUS_X, Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.MINUS_X),
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> QuaternionRotation.createBasisRotation(
- Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.PLUS_Y, Vector3D.MINUS_Y),
+ Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_Y),
IllegalNormException.class);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
index 9235793..fd819b4 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/AffineTransformMatrix2DTest.java
@@ -625,7 +625,7 @@ public class AffineTransformMatrix2DTest {
@Test
public void testApplyDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(1, 0).applyDirection(Vector2D.PLUS_Y),
+ GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(1, 0).applyDirection(Vector2D.Unit.PLUS_Y),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> AffineTransformMatrix2D.createScale(2).applyDirection(Vector2D.ZERO),
IllegalNormException.class);
@@ -836,7 +836,7 @@ public class AffineTransformMatrix2DTest {
public void testInverse_undoesOriginalTransform() {
// arrange
Vector2D v1 = Vector2D.ZERO;
- Vector2D v2 = Vector2D.PLUS_X;
+ Vector2D v2 = Vector2D.Unit.PLUS_X;
Vector2D v3 = Vector2D.of(1, 1);
Vector2D v4 = Vector2D.of(-2, 3);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
index 0e26c92..3907ec1 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineTest.java
@@ -38,14 +38,14 @@ public class LineTest {
@Test
public void testFromPoints() {
// act/assert
- checkLine(Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ checkLine(Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION),
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPoints(Vector2D.ZERO, Vector2D.of(100, 0), TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPoints(Vector2D.of(100, 0), Vector2D.ZERO, TEST_PRECISION),
- Vector2D.ZERO, Vector2D.MINUS_X);
+ Vector2D.ZERO, Vector2D.Unit.MINUS_X);
checkLine(Line.fromPoints(Vector2D.of(-100, 0), Vector2D.of(100, 0), TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPoints(Vector2D.of(-2, 0), Vector2D.of(0, 2), TEST_PRECISION),
Vector2D.of(-1, 1), Vector2D.of(1, 1).normalize());
@@ -56,21 +56,21 @@ public class LineTest {
@Test
public void testFromPoints_pointsTooClose() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.PLUS_X, Vector2D.PLUS_X, TEST_PRECISION),
+ GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.Unit.PLUS_X, TEST_PRECISION),
GeometryValueException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.PLUS_X, Vector2D.of(1 + 1e-11, 1e-11), TEST_PRECISION),
+ GeometryTestUtils.assertThrows(() -> Line.fromPoints(Vector2D.Unit.PLUS_X, Vector2D.of(1 + 1e-11, 1e-11), TEST_PRECISION),
GeometryValueException.class, "Line direction cannot be zero");
}
@Test
public void testFromPointAndDirection() {
// act/assert
- checkLine(Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ checkLine(Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION),
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.of(100, 0), TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPointAndDirection(Vector2D.of(-100, 0), Vector2D.of(100, 0), TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPointAndDirection(Vector2D.of(-2, 0), Vector2D.of(1, 1), TEST_PRECISION),
Vector2D.of(-1, 1), Vector2D.of(1, 1).normalize());
@@ -81,9 +81,9 @@ public class LineTest {
@Test
public void testFromPointAndDirection_directionIsZero() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.PLUS_X, Vector2D.ZERO, TEST_PRECISION),
+ GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.ZERO, TEST_PRECISION),
GeometryValueException.class, "Line direction cannot be zero");
- GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.PLUS_X, Vector2D.of(1e-11, -1e-12), TEST_PRECISION),
+ GeometryTestUtils.assertThrows(() -> Line.fromPointAndDirection(Vector2D.Unit.PLUS_X, Vector2D.of(1e-11, -1e-12), TEST_PRECISION),
GeometryValueException.class, "Line direction cannot be zero");
}
@@ -91,15 +91,15 @@ public class LineTest {
public void testFromPointAndAngle() {
// act/assert
checkLine(Line.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION),
- Vector2D.ZERO, Vector2D.PLUS_X);
+ Vector2D.ZERO, Vector2D.Unit.PLUS_X);
checkLine(Line.fromPointAndAngle(Vector2D.of(1, 1), Geometry.HALF_PI, TEST_PRECISION),
- Vector2D.of(1, 0), Vector2D.PLUS_Y);
+ Vector2D.of(1, 0), Vector2D.Unit.PLUS_Y);
checkLine(Line.fromPointAndAngle(Vector2D.of(-1, -1), Geometry.PI, TEST_PRECISION),
- Vector2D.of(0, -1), Vector2D.MINUS_X);
+ Vector2D.of(0, -1), Vector2D.Unit.MINUS_X);
checkLine(Line.fromPointAndAngle(Vector2D.of(1, -1), Geometry.MINUS_HALF_PI, TEST_PRECISION),
- Vector2D.of(1, 0), Vector2D.MINUS_Y);
+ Vector2D.of(1, 0), Vector2D.Unit.MINUS_Y);
checkLine(Line.fromPointAndAngle(Vector2D.of(-1, 1), Geometry.TWO_PI, TEST_PRECISION),
- Vector2D.of(0, 1), Vector2D.PLUS_X);
+ Vector2D.of(0, 1), Vector2D.Unit.PLUS_X);
}
@Test
@@ -134,19 +134,19 @@ public class LineTest {
@Test
public void testGetDirection() {
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.PLUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.PLUS_X,
Line.fromPoints(Vector2D.of(0, 0), Vector2D.of(1, 0), TEST_PRECISION).getDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_Y,
Line.fromPoints(Vector2D.of(0, 1), Vector2D.of(0, -1), TEST_PRECISION).getDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_X,
Line.fromPoints(Vector2D.of(2, 2), Vector2D.of(1, 2), TEST_PRECISION).getDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.PLUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.PLUS_X,
Line.fromPoints(Vector2D.of(10, -2), Vector2D.of(10.1, -2), TEST_PRECISION).getDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_Y,
Line.fromPoints(Vector2D.of(3, 2), Vector2D.of(3, 1), TEST_PRECISION).getDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.PLUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.PLUS_Y,
Line.fromPoints(Vector2D.of(-3, 10), Vector2D.of(-3, 10.1), TEST_PRECISION).getDirection(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, -1).normalize(),
@@ -158,19 +158,19 @@ public class LineTest {
@Test
public void testGetOffsetDirection() {
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_Y,
Line.fromPoints(Vector2D.of(0, 0), Vector2D.of(1, 0), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_X,
Line.fromPoints(Vector2D.of(0, 1), Vector2D.of(0, -1), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.PLUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.PLUS_Y,
Line.fromPoints(Vector2D.of(2, 2), Vector2D.of(1, 2), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_Y,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_Y,
Line.fromPoints(Vector2D.of(10, -2), Vector2D.of(10.1, -2), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.MINUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.MINUS_X,
Line.fromPoints(Vector2D.of(3, 2), Vector2D.of(3, 1), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.PLUS_X,
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.Unit.PLUS_X,
Line.fromPoints(Vector2D.of(-3, 10), Vector2D.of(-3, 10.1), TEST_PRECISION).getOffsetDirection(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, -1).normalize(),
@@ -228,15 +228,15 @@ public class LineTest {
@Test
public void testGetPrecision() {
// act/assert
- Assert.assertSame(TEST_PRECISION, Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION).getPrecision());
- Assert.assertSame(TEST_PRECISION, Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION).getPrecision());
+ Assert.assertSame(TEST_PRECISION, Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION).getPrecision());
+ Assert.assertSame(TEST_PRECISION, Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION).getPrecision());
Assert.assertSame(TEST_PRECISION, Line.fromPointAndAngle(Vector2D.ZERO, 0, TEST_PRECISION).getPrecision());
}
@Test
public void testCopySelf() {
// arrange
- Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
Assert.assertSame(line, line.copySelf());
@@ -246,7 +246,7 @@ public class LineTest {
public void testReverse() {
// arrange
Vector2D pt = Vector2D.of(0, 1);
- Vector2D dir = Vector2D.PLUS_X;
+ Vector2D dir = Vector2D.Unit.PLUS_X;
Line line = Line.fromPointAndDirection(pt, dir, TEST_PRECISION);
// act
@@ -320,8 +320,8 @@ public class LineTest {
@Test
public void testIntersection() {
// arrange
- Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_Y, TEST_PRECISION);
+ Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_Y, TEST_PRECISION);
Line c = Line.fromPointAndDirection(Vector2D.of(0, 2), Vector2D.of(2, 1), TEST_PRECISION);
Line d = Line.fromPointAndDirection(Vector2D.of(0, -1), Vector2D.of(2, -1), TEST_PRECISION);
@@ -348,8 +348,8 @@ public class LineTest {
@Test
public void testIntersection_parallel() {
// arrange
- Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPointAndDirection(Vector2D.of(0, 1), Vector2D.PLUS_X, TEST_PRECISION);
+ Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPointAndDirection(Vector2D.of(0, 1), Vector2D.Unit.PLUS_X, TEST_PRECISION);
Line c = Line.fromPointAndDirection(Vector2D.of(0, 2), Vector2D.of(2, 1), TEST_PRECISION);
Line d = Line.fromPointAndDirection(Vector2D.of(0, -1), Vector2D.of(2, 1), TEST_PRECISION);
@@ -365,8 +365,8 @@ public class LineTest {
@Test
public void testIntersection_coincident() {
// arrange
- Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
Line c = Line.fromPointAndDirection(Vector2D.of(0, 2), Vector2D.of(2, 1), TEST_PRECISION);
Line d = Line.fromPointAndDirection(Vector2D.of(0, 2), Vector2D.of(2, 1), TEST_PRECISION);
@@ -382,8 +382,8 @@ public class LineTest {
@Test
public void testProject() {
// --- arrange
- Line xAxis = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line yAxis = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_Y, TEST_PRECISION);
+ Line xAxis = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line yAxis = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_Y, TEST_PRECISION);
double diagonalYIntercept = 1;
Vector2D diagonalDir = Vector2D.of(1, 2);
@@ -409,7 +409,7 @@ public class LineTest {
@Test
public void testWholeHyperplane() {
// arrange
- Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act
SubLine result = line.wholeHyperplane();
@@ -422,7 +422,7 @@ public class LineTest {
@Test
public void testWholeSpace() {
// arrange
- Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line line = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act
PolygonsSet result = line.wholeSpace();
@@ -473,8 +473,8 @@ public class LineTest {
@Test
public void testGetOffset_nonParallelLines() {
// arrange
- Line a = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_Y, TEST_PRECISION);
+ Line a = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_Y, TEST_PRECISION);
Line c = Line.fromPoints(Vector2D.of(-1, 0), Vector2D.of(0, 2), TEST_PRECISION);
Line d = Line.fromPoints(Vector2D.of(1, 0), Vector2D.of(0, 4), TEST_PRECISION);
@@ -566,9 +566,9 @@ public class LineTest {
@Test
public void testSameOrientationAs_orthogonal() {
// arrange
- Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPointAndDirection(Vector2D.of(4, 5), Vector2D.PLUS_Y, TEST_PRECISION);
- Line c = Line.fromPointAndDirection(Vector2D.of(-4, -5), Vector2D.MINUS_Y, TEST_PRECISION);
+ Line a = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPointAndDirection(Vector2D.of(4, 5), Vector2D.Unit.PLUS_Y, TEST_PRECISION);
+ Line c = Line.fromPointAndDirection(Vector2D.of(-4, -5), Vector2D.Unit.MINUS_Y, TEST_PRECISION);
// act/assert
Assert.assertTrue(a.sameOrientationAs(b));
@@ -618,8 +618,8 @@ public class LineTest {
@Test
public void testDistance_nonParallelLines() {
// arrange
- Line a = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
- Line b = Line.fromPoints(Vector2D.ZERO, Vector2D.PLUS_Y, TEST_PRECISION);
+ Line a = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line b = Line.fromPoints(Vector2D.ZERO, Vector2D.Unit.PLUS_Y, TEST_PRECISION);
Line c = Line.fromPoints(Vector2D.of(-1, 0), Vector2D.of(0, 2), TEST_PRECISION);
Line d = Line.fromPoints(Vector2D.of(1, 0), Vector2D.of(0, 4), TEST_PRECISION);
@@ -690,7 +690,7 @@ public class LineTest {
Line a = Line.fromPointAndDirection(pt, dir, TEST_PRECISION);
Line b = Line.fromPointAndDirection(Vector2D.of(0, -4), dir, TEST_PRECISION);
Line c = Line.fromPointAndDirection(Vector2D.of(-2, -2), dir.negate(), TEST_PRECISION);
- Line d = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line d = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
Line e = Line.fromPointAndDirection(pt, dir, TEST_PRECISION);
Line f = Line.fromPointAndDirection(pt, dir.negate(), TEST_PRECISION);
@@ -826,7 +826,7 @@ public class LineTest {
Line a = Line.fromPointAndDirection(Vector2D.of(1, 2), dir, TEST_PRECISION);
Line b = Line.fromPointAndDirection(Vector2D.of(0, -4), dir, TEST_PRECISION);
Line c = Line.fromPointAndDirection(Vector2D.of(-2, -2), dir.negate(), TEST_PRECISION);
- Line d = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line d = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
Assert.assertTrue(a.isParallel(a));
@@ -869,31 +869,31 @@ public class LineTest {
Vector2D p1 = Vector2D.of(0, 1);
Vector2D p2 = Vector2D.of(1, 0);
- Line horizontal = Line.fromPointAndDirection(p1, Vector2D.PLUS_X, TEST_PRECISION);
- Line vertical = Line.fromPointAndDirection(p2, Vector2D.PLUS_Y, TEST_PRECISION);
+ Line horizontal = Line.fromPointAndDirection(p1, Vector2D.Unit.PLUS_X, TEST_PRECISION);
+ Line vertical = Line.fromPointAndDirection(p2, Vector2D.Unit.PLUS_Y, TEST_PRECISION);
Line diagonal = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.of(1, 1), TEST_PRECISION);
// act/assert
Assert.assertSame(TEST_PRECISION, horizontal.transform(scale).getPrecision());
- checkLine(horizontal.transform(scale), Vector2D.of(0, 3), Vector2D.PLUS_X);
- checkLine(vertical.transform(scale), Vector2D.of(2, 0), Vector2D.PLUS_Y);
+ checkLine(horizontal.transform(scale), Vector2D.of(0, 3), Vector2D.Unit.PLUS_X);
+ checkLine(vertical.transform(scale), Vector2D.of(2, 0), Vector2D.Unit.PLUS_Y);
checkLine(diagonal.transform(scale), Vector2D.ZERO, Vector2D.of(2, 3).normalize());
- checkLine(horizontal.transform(reflect), p1, Vector2D.MINUS_X);
- checkLine(vertical.transform(reflect), Vector2D.of(-1, 0), Vector2D.PLUS_Y);
+ checkLine(horizontal.transform(reflect), p1, Vector2D.Unit.MINUS_X);
+ checkLine(vertical.transform(reflect), Vector2D.of(-1, 0), Vector2D.Unit.PLUS_Y);
checkLine(diagonal.transform(reflect), Vector2D.ZERO, Vector2D.of(-1, 1).normalize());
- checkLine(horizontal.transform(translate), Vector2D.of(0, 5), Vector2D.PLUS_X);
- checkLine(vertical.transform(translate), Vector2D.of(4, 0), Vector2D.PLUS_Y);
+ checkLine(horizontal.transform(translate), Vector2D.of(0, 5), Vector2D.Unit.PLUS_X);
+ checkLine(vertical.transform(translate), Vector2D.of(4, 0), Vector2D.Unit.PLUS_Y);
checkLine(diagonal.transform(translate), Vector2D.of(-0.5, 0.5), Vector2D.of(1, 1).normalize());
- checkLine(horizontal.transform(rotate), Vector2D.of(-1, 0), Vector2D.PLUS_Y);
- checkLine(vertical.transform(rotate), Vector2D.of(0, 1), Vector2D.MINUS_X);
+ checkLine(horizontal.transform(rotate), Vector2D.of(-1, 0), Vector2D.Unit.PLUS_Y);
+ checkLine(vertical.transform(rotate), Vector2D.of(0, 1), Vector2D.Unit.MINUS_X);
checkLine(diagonal.transform(rotate), Vector2D.ZERO, Vector2D.of(-1, 1).normalize());
- checkLine(horizontal.transform(rotateAroundPt), Vector2D.ZERO, Vector2D.PLUS_Y);
- checkLine(vertical.transform(rotateAroundPt), Vector2D.of(0, 2), Vector2D.MINUS_X);
+ checkLine(horizontal.transform(rotateAroundPt), Vector2D.ZERO, Vector2D.Unit.PLUS_Y);
+ checkLine(vertical.transform(rotateAroundPt), Vector2D.of(0, 2), Vector2D.Unit.MINUS_X);
checkLine(diagonal.transform(rotateAroundPt), Vector2D.of(1, 1), Vector2D.of(-1, 1).normalize());
}
@@ -901,7 +901,7 @@ public class LineTest {
public void testTransform_collapsedPoints() {
// arrange
AffineTransformMatrix2D scaleCollapse = AffineTransformMatrix2D.createScale(0, 1);
- Line line = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line line = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act/assert
GeometryTestUtils.assertThrows(() -> {
@@ -966,7 +966,7 @@ public class LineTest {
@Test
public void testToString() {
// arrange
- Line line = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.PLUS_X, TEST_PRECISION);
+ Line line = Line.fromPointAndDirection(Vector2D.ZERO, Vector2D.Unit.PLUS_X, TEST_PRECISION);
// act
String str = line.toString();
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
index 3ea43c5..53be220 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/PolygonsSetTest.java
@@ -1619,10 +1619,10 @@ public class PolygonsSetTest {
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1.0 / 16);
Hyperplane<Vector2D>[] h2 = new Line[] {
- Line.fromPointAndDirection(pA, Vector2D.MINUS_Y, precision),
- Line.fromPointAndDirection(pB, Vector2D.PLUS_X, precision),
- Line.fromPointAndDirection(pC, Vector2D.PLUS_Y, precision),
- Line.fromPointAndDirection(pD, Vector2D.MINUS_X, precision)
+ Line.fromPointAndDirection(pA, Vector2D.Unit.MINUS_Y, precision),
+ Line.fromPointAndDirection(pB, Vector2D.Unit.PLUS_X, precision),
+ Line.fromPointAndDirection(pC, Vector2D.Unit.PLUS_Y, precision),
+ Line.fromPointAndDirection(pD, Vector2D.Unit.MINUS_X, precision)
};
// act
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
index 3f92960..20c3faf 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Vector2DTest.java
@@ -36,10 +36,10 @@ public class Vector2DTest {
public void testConstants() {
// act/assert
checkVector(Vector2D.ZERO, 0, 0);
- checkVector(Vector2D.PLUS_X, 1, 0);
- checkVector(Vector2D.MINUS_X, -1, 0);
- checkVector(Vector2D.PLUS_Y, 0, 1);
- checkVector(Vector2D.MINUS_Y, 0, -1);
+ checkVector(Vector2D.Unit.PLUS_X, 1, 0);
+ checkVector(Vector2D.Unit.MINUS_X, -1, 0);
+ checkVector(Vector2D.Unit.PLUS_Y, 0, 1);
+ checkVector(Vector2D.Unit.MINUS_Y, 0, -1);
checkVector(Vector2D.NaN, Double.NaN, Double.NaN);
checkVector(Vector2D.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);
checkVector(Vector2D.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
@@ -57,11 +57,11 @@ public class Vector2DTest {
GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.normalize(),
IllegalNormException.class);
- Assert.assertSame(Vector2D.PLUS_X.normalize(), Vector2D.PLUS_X);
- Assert.assertSame(Vector2D.MINUS_X.normalize(), Vector2D.MINUS_X);
+ Assert.assertSame(Vector2D.Unit.PLUS_X.normalize(), Vector2D.Unit.PLUS_X);
+ Assert.assertSame(Vector2D.Unit.MINUS_X.normalize(), Vector2D.Unit.MINUS_X);
- Assert.assertSame(Vector2D.PLUS_Y.normalize(), Vector2D.PLUS_Y);
- Assert.assertSame(Vector2D.MINUS_Y.normalize(), Vector2D.MINUS_Y);
+ Assert.assertSame(Vector2D.Unit.PLUS_Y.normalize(), Vector2D.Unit.PLUS_Y);
+ Assert.assertSame(Vector2D.Unit.MINUS_Y.normalize(), Vector2D.Unit.MINUS_Y);
}
@Test
@@ -207,8 +207,8 @@ public class Vector2DTest {
Vector2D v = Vector2D.of(2.0, -3.0).normalize();
// act/assert
- checkVector(Vector2D.PLUS_X.withNorm(2.5), 2.5, 0.0);
- checkVector(Vector2D.MINUS_Y.withNorm(3.14), 0.0, -3.14);
+ checkVector(Vector2D.Unit.PLUS_X.withNorm(2.5), 2.5, 0.0);
+ checkVector(Vector2D.Unit.MINUS_Y.withNorm(3.14), 0.0, -3.14);
for (int i = -10; i <= 10; i++) {
final double mag = i;
@@ -403,10 +403,10 @@ public class Vector2DTest {
Assert.assertEquals(-1, v1.dot(v3), EPS);
Assert.assertEquals(-1, v3.dot(v1), EPS);
- Assert.assertEquals(1, Vector2D.PLUS_X.dot(Vector2D.PLUS_X), EPS);
- Assert.assertEquals(0, Vector2D.PLUS_X.dot(Vector2D.PLUS_Y), EPS);
- Assert.assertEquals(-1, Vector2D.PLUS_X.dot(Vector2D.MINUS_X), EPS);
- Assert.assertEquals(0, Vector2D.PLUS_X.dot(Vector2D.MINUS_Y), EPS);
+ Assert.assertEquals(1, Vector2D.Unit.PLUS_X.dot(Vector2D.Unit.PLUS_X), EPS);
+ Assert.assertEquals(0, Vector2D.Unit.PLUS_X.dot(Vector2D.Unit.PLUS_Y), EPS);
+ Assert.assertEquals(-1, Vector2D.Unit.PLUS_X.dot(Vector2D.Unit.MINUS_X), EPS);
+ Assert.assertEquals(0, Vector2D.Unit.PLUS_X.dot(Vector2D.Unit.MINUS_Y), EPS);
}
@Test
@@ -415,16 +415,16 @@ public class Vector2DTest {
double invSqrt2 = 1.0 / Math.sqrt(2.0);
// act/assert
- checkVector(Vector2D.PLUS_X.orthogonal(), 0.0, 1.0);
+ checkVector(Vector2D.Unit.PLUS_X.orthogonal(), 0.0, 1.0);
checkVector(Vector2D.of(1.0, 1.0).orthogonal(), -invSqrt2, invSqrt2);
- checkVector(Vector2D.PLUS_Y.orthogonal(), -1.0, 0.0);
+ checkVector(Vector2D.Unit.PLUS_Y.orthogonal(), -1.0, 0.0);
checkVector(Vector2D.of(-1.0, 1.0).orthogonal(), -invSqrt2, -invSqrt2);
- checkVector(Vector2D.MINUS_X.orthogonal(), 0.0, -1.0);
+ checkVector(Vector2D.Unit.MINUS_X.orthogonal(), 0.0, -1.0);
checkVector(Vector2D.of(-1.0, -1.0).orthogonal(), invSqrt2, -invSqrt2);
- checkVector(Vector2D.MINUS_Y.orthogonal(), 1.0, 0.0);
+ checkVector(Vector2D.Unit.MINUS_Y.orthogonal(), 1.0, 0.0);
checkVector(Vector2D.of(1.0, -1.0).orthogonal(), invSqrt2, invSqrt2);
}
@@ -462,8 +462,8 @@ public class Vector2DTest {
double invSqrt2 = 1.0 / Math.sqrt(2.0);
// act/assert
- checkVector(Vector2D.PLUS_X.orthogonal(Vector2D.of(-1.0, 0.1)), 0.0, 1.0);
- checkVector(Vector2D.PLUS_Y.orthogonal(Vector2D.of(2.0, 2.0)), 1.0, 0.0);
+ checkVector(Vector2D.Unit.PLUS_X.orthogonal(Vector2D.of(-1.0, 0.1)), 0.0, 1.0);
+ checkVector(Vector2D.Unit.PLUS_Y.orthogonal(Vector2D.of(2.0, 2.0)), 1.0, 0.0);
checkVector(Vector2D.of(2.9, 2.9).orthogonal(Vector2D.of(1.0, 0.22)), invSqrt2, -invSqrt2);
checkVector(Vector2D.of(2.9, 2.9).orthogonal(Vector2D.of(0.22, 1.0)), -invSqrt2, invSqrt2);
@@ -472,31 +472,31 @@ public class Vector2DTest {
@Test
public void testOrthogonal_givenDirection_illegalNorm() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(Vector2D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.ZERO.orthogonal(Vector2D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(Vector2D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.NaN.orthogonal(Vector2D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.orthogonal(Vector2D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.POSITIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.orthogonal(Vector2D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.NEGATIVE_INFINITY.orthogonal(Vector2D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.ZERO),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.ZERO),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.NaN),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NaN),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.POSITIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.POSITIVE_INFINITY),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.NEGATIVE_INFINITY),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.NEGATIVE_INFINITY),
IllegalNormException.class);
}
@Test
public void testOrthogonal_givenDirection_directionIsCollinear() {
// act/assert
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.PLUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.PLUS_X),
IllegalNormException.class);
- GeometryTestUtils.assertThrows(() -> Vector2D.PLUS_X.orthogonal(Vector2D.MINUS_X),
+ GeometryTestUtils.assertThrows(() -> Vector2D.Unit.PLUS_X.orthogonal(Vector2D.Unit.MINUS_X),
IllegalNormException.class);
GeometryTestUtils.assertThrows(() -> Vector2D.of(1.0, 1.0).orthogonal(Vector2D.of(2.0, 2.0)),
IllegalNormException.class);
@@ -507,11 +507,11 @@ public class Vector2DTest {
@Test
public void testAngle() {
// act/assert
- Assert.assertEquals(0, Vector2D.PLUS_X.angle(Vector2D.PLUS_X), EPS);
+ Assert.assertEquals(0, Vector2D.Unit.PLUS_X.angle(Vector2D.Unit.PLUS_X), EPS);
- Assert.assertEquals(Geometry.PI, Vector2D.PLUS_X.angle(Vector2D.MINUS_X), EPS);
- Assert.assertEquals(Geometry.HALF_PI, Vector2D.PLUS_X.angle(Vector2D.PLUS_Y), EPS);
- Assert.assertEquals(Geometry.HALF_PI, Vector2D.PLUS_X.angle(Vector2D.MINUS_Y), EPS);
+ Assert.assertEquals(Geometry.PI, Vector2D.Unit.PLUS_X.angle(Vector2D.Unit.MINUS_X), EPS);
+ Assert.assertEquals(Geometry.HALF_PI, Vector2D.Unit.PLUS_X.angle(Vector2D.Unit.PLUS_Y), EPS);
+ Assert.assertEquals(Geometry.HALF_PI, Vector2D.Unit.PLUS_X.angle(Vector2D.Unit.MINUS_Y), EPS);
Assert.assertEquals(Geometry.PI / 4, Vector2D.of(1, 1).angle(Vector2D.of(1, 0)), EPS);
Assert.assertEquals(Geometry.PI / 4, Vector2D.of(1, 0).angle(Vector2D.of(1, 1)), EPS);
@@ -550,8 +550,8 @@ public class Vector2DTest {
// arrange
double eps = 1e-10;
- Vector2D a = Vector2D.PLUS_X;
- Vector2D b = Vector2D.PLUS_Y;
+ Vector2D a = Vector2D.Unit.PLUS_X;
+ Vector2D b = Vector2D.Unit.PLUS_Y;
Vector2D c = Vector2D.of(1, 1).withNorm(2.0);
Vector2D d = Vector2D.of(-1, 1).withNorm(3.0);
@@ -574,8 +574,8 @@ public class Vector2DTest {
@Test
public void testSignedArea_collinear() {
// arrange
- Vector2D a = Vector2D.PLUS_X;
- Vector2D b = Vector2D.PLUS_Y;
+ Vector2D a = Vector2D.Unit.PLUS_X;
+ Vector2D b = Vector2D.Unit.PLUS_Y;
Vector2D c = Vector2D.of(-3, 8);
// act/assert
@@ -600,11 +600,11 @@ public class Vector2DTest {
checkVector(v1.project(v1), 3.0, 4.0);
checkVector(v1.project(v1.negate()), 3.0, 4.0);
- checkVector(v1.project(Vector2D.PLUS_X), 3.0, 0.0);
- checkVector(v1.project(Vector2D.MINUS_X), 3.0, 0.0);
+ checkVector(v1.project(Vector2D.Unit.PLUS_X), 3.0, 0.0);
+ checkVector(v1.project(Vector2D.Unit.MINUS_X), 3.0, 0.0);
- checkVector(v1.project(Vector2D.PLUS_Y), 0.0, 4.0);
- checkVector(v1.project(Vector2D.MINUS_Y), 0.0, 4.0);
+ checkVector(v1.project(Vector2D.Unit.PLUS_Y), 0.0, 4.0);
+ checkVector(v1.project(Vector2D.Unit.MINUS_Y), 0.0, 4.0);
checkVector(v2.project(v1), (19.0 / 25.0) * 3.0, (19.0 / 25.0) * 4.0);
}
@@ -637,11 +637,11 @@ public class Vector2DTest {
checkVector(v1.reject(v1), 0.0, 0.0);
checkVector(v1.reject(v1.negate()), 0.0, 0.0);
- checkVector(v1.reject(Vector2D.PLUS_X), 0.0, 4.0);
- checkVector(v1.reject(Vector2D.MINUS_X), 0.0, 4.0);
+ checkVector(v1.reject(Vector2D.Unit.PLUS_X), 0.0, 4.0);
+ checkVector(v1.reject(Vector2D.Unit.MINUS_X), 0.0, 4.0);
- checkVector(v1.reject(Vector2D.PLUS_Y), 3.0, 0.0);
- checkVector(v1.reject(Vector2D.MINUS_Y), 3.0, 0.0);
+ checkVector(v1.reject(Vector2D.Unit.PLUS_Y), 3.0, 0.0);
+ checkVector(v1.reject(Vector2D.Unit.MINUS_Y), 3.0, 0.0);
checkVector(v2.reject(v1), (-32.0 / 25.0), (6.0 / 25.0) * 4.0);
}
@@ -917,7 +917,7 @@ public class Vector2DTest {
checkVector(Vector2D.parse("(NaN, -Infinity)"), Double.NaN, Double.NEGATIVE_INFINITY);
checkVector(Vector2D.parse(Vector2D.ZERO.toString()), 0, 0);
- checkVector(Vector2D.parse(Vector2D.MINUS_X.toString()), -1, 0);
+ checkVector(Vector2D.parse(Vector2D.Unit.MINUS_X.toString()), -1, 0);
}
@Test(expected = IllegalArgumentException.class)
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
index 4579015..ca3bf3f 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/S2Point.java
@@ -29,22 +29,22 @@ import org.apache.commons.geometry.euclidean.threed.Vector3D;
public final class S2Point implements Point<S2Point>, Serializable {
/** +I (coordinates: ( azimuth = 0, polar = pi/2 )). */
- public static final S2Point PLUS_I = new S2Point(0, 0.5 * Math.PI, Vector3D.PLUS_X);
+ public static final S2Point PLUS_I = new S2Point(0, 0.5 * Math.PI, Vector3D.Unit.PLUS_X);
/** +J (coordinates: ( azimuth = pi/2, polar = pi/2 ))). */
- public static final S2Point PLUS_J = new S2Point(0.5 * Math.PI, 0.5 * Math.PI, Vector3D.PLUS_Y);
+ public static final S2Point PLUS_J = new S2Point(0.5 * Math.PI, 0.5 * Math.PI, Vector3D.Unit.PLUS_Y);
/** +K (coordinates: ( azimuth = any angle, polar = 0 )). */
- public static final S2Point PLUS_K = new S2Point(0, 0, Vector3D.PLUS_Z);
+ public static final S2Point PLUS_K = new S2Point(0, 0, Vector3D.Unit.PLUS_Z);
/** -I (coordinates: ( azimuth = pi, polar = pi/2 )). */
- public static final S2Point MINUS_I = new S2Point(Math.PI, 0.5 * Math.PI, Vector3D.MINUS_X);
+ public static final S2Point MINUS_I = new S2Point(Math.PI, 0.5 * Math.PI, Vector3D.Unit.MINUS_X);
/** -J (coordinates: ( azimuth = 3pi/2, polar = pi/2 )). */
- public static final S2Point MINUS_J = new S2Point(1.5 * Math.PI, 0.5 * Math.PI, Vector3D.MINUS_Y);
+ public static final S2Point MINUS_J = new S2Point(1.5 * Math.PI, 0.5 * Math.PI, Vector3D.Unit.MINUS_Y);
/** -K (coordinates: ( azimuth = any angle, polar = pi )). */
- public static final S2Point MINUS_K = new S2Point(0, Math.PI, Vector3D.MINUS_Z);
+ public static final S2Point MINUS_K = new S2Point(0, Math.PI, Vector3D.Unit.MINUS_Z);
// CHECKSTYLE: stop ConstantName
/** A point with all coordinates set to NaN. */
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
index 186692b..b81a44b 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/CircleTest.java
@@ -43,12 +43,12 @@ public class CircleTest {
@Test
public void testEquator() {
Circle circle = new Circle(Vector3D.of(0, 0, 1000), TEST_PRECISION).copySelf();
- Assert.assertEquals(Vector3D.PLUS_Z, circle.getPole());
+ Assert.assertEquals(Vector3D.Unit.PLUS_Z, circle.getPole());
Assert.assertEquals(TEST_PRECISION, circle.getPrecision());
circle.revertSelf();
- Assert.assertEquals(Vector3D.MINUS_Z, circle.getPole());
- Assert.assertEquals(Vector3D.PLUS_Z, circle.getReverse().getPole());
- Assert.assertEquals(Vector3D.MINUS_Z, circle.getPole());
+ Assert.assertEquals(Vector3D.Unit.MINUS_Z, circle.getPole());
+ Assert.assertEquals(Vector3D.Unit.PLUS_Z, circle.getReverse().getPole());
+ Assert.assertEquals(Vector3D.Unit.MINUS_Z, circle.getPole());
}
@Test
@@ -123,13 +123,13 @@ public class CircleTest {
@Test
public void testOffset() {
- Circle circle = new Circle(Vector3D.PLUS_Z, TEST_PRECISION);
- Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.PLUS_X)), TEST_EPS);
- Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.MINUS_X)), TEST_EPS);
- Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.PLUS_Y)), TEST_EPS);
- Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.MINUS_Y)), TEST_EPS);
- Assert.assertEquals(-0.5 * Math.PI, circle.getOffset(S2Point.ofVector(Vector3D.PLUS_Z)), TEST_EPS);
- Assert.assertEquals(0.5 * Math.PI, circle.getOffset(S2Point.ofVector(Vector3D.MINUS_Z)), TEST_EPS);
+ Circle circle = new Circle(Vector3D.Unit.PLUS_Z, TEST_PRECISION);
+ Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.Unit.PLUS_X)), TEST_EPS);
+ Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.Unit.MINUS_X)), TEST_EPS);
+ Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.Unit.PLUS_Y)), TEST_EPS);
+ Assert.assertEquals(0.0, circle.getOffset(S2Point.ofVector(Vector3D.Unit.MINUS_Y)), TEST_EPS);
+ Assert.assertEquals(-0.5 * Math.PI, circle.getOffset(S2Point.ofVector(Vector3D.Unit.PLUS_Z)), TEST_EPS);
+ Assert.assertEquals(0.5 * Math.PI, circle.getOffset(S2Point.ofVector(Vector3D.Unit.MINUS_Z)), TEST_EPS);
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
index dcd72e6..c711051 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SphericalPolygonsSetTest.java
@@ -81,7 +81,7 @@ public class SphericalPolygonsSetTest {
public void testSouthHemisphere() {
double tol = 0.01;
double sinTol = Math.sin(tol);
- SphericalPolygonsSet south = new SphericalPolygonsSet(Vector3D.MINUS_Z, createPrecision(tol));
+ SphericalPolygonsSet south = new SphericalPolygonsSet(Vector3D.Unit.MINUS_Z, createPrecision(tol));
UnitSphereSampler random =
new UnitSphereSampler(3, RandomSource.create(RandomSource.WELL_1024_A,
0x6b9d4a6ad90d7b0bl));
@@ -114,9 +114,9 @@ public class SphericalPolygonsSetTest {
double sinTol = Math.sin(tol);
DoublePrecisionContext precision = createPrecision(tol);
RegionFactory<S2Point> factory = new RegionFactory<>();
- SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_X, precision);
- SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_Y, precision);
- SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_Z, precision);
+ SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.Unit.PLUS_X, precision);
+ SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.Unit.PLUS_Y, precision);
+ SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.Unit.PLUS_Z, precision);
SphericalPolygonsSet octant =
(SphericalPolygonsSet) factory.intersection(factory.intersection(plusX, plusY), plusZ);
UnitSphereSampler random =
@@ -147,13 +147,13 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.PLUS_X) < TEST_EPS;
- yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.PLUS_Y) < TEST_EPS;
- zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.PLUS_Z) < TEST_EPS;
+ xPFound = xPFound || e.getCircle().getPole().distance(Vector3D.Unit.PLUS_X) < TEST_EPS;
+ yPFound = yPFound || e.getCircle().getPole().distance(Vector3D.Unit.PLUS_Y) < TEST_EPS;
+ zPFound = zPFound || e.getCircle().getPole().distance(Vector3D.Unit.PLUS_Z) < TEST_EPS;
Assert.assertEquals(0.5 * Math.PI, e.getLength(), TEST_EPS);
- xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_X) < TEST_EPS;
- yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_Y) < TEST_EPS;
- zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_Z) < TEST_EPS;
+ xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_X) < TEST_EPS;
+ yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Y) < TEST_EPS;
+ zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Z) < TEST_EPS;
}
Assert.assertTrue(xPFound);
Assert.assertTrue(yPFound);
@@ -205,9 +205,9 @@ public class SphericalPolygonsSetTest {
double sinTol = Math.sin(tol);
DoublePrecisionContext precision = createPrecision(tol);
RegionFactory<S2Point> factory = new RegionFactory<>();
- SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.PLUS_X, precision);
- SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.PLUS_Y, precision);
- SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.PLUS_Z, precision);
+ SphericalPolygonsSet plusX = new SphericalPolygonsSet(Vector3D.Unit.PLUS_X, precision);
+ SphericalPolygonsSet plusY = new SphericalPolygonsSet(Vector3D.Unit.PLUS_Y, precision);
+ SphericalPolygonsSet plusZ = new SphericalPolygonsSet(Vector3D.Unit.PLUS_Z, precision);
SphericalPolygonsSet threeOctants =
(SphericalPolygonsSet) factory.difference(plusZ, factory.intersection(plusX, plusY));
@@ -242,20 +242,20 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- if (e.getCircle().getPole().distance(Vector3D.MINUS_X) < TEST_EPS) {
+ if (e.getCircle().getPole().distance(Vector3D.Unit.MINUS_X) < TEST_EPS) {
xPFound = true;
sumPoleX += e.getLength();
- } else if (e.getCircle().getPole().distance(Vector3D.MINUS_Y) < TEST_EPS) {
+ } else if (e.getCircle().getPole().distance(Vector3D.Unit.MINUS_Y) < TEST_EPS) {
yPFound = true;
sumPoleY += e.getLength();
} else {
- Assert.assertEquals(0.0, e.getCircle().getPole().distance(Vector3D.PLUS_Z), TEST_EPS);
+ Assert.assertEquals(0.0, e.getCircle().getPole().distance(Vector3D.Unit.PLUS_Z), TEST_EPS);
zPFound = true;
sumPoleZ += e.getLength();
}
- xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.PLUS_X) < TEST_EPS;
- yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.PLUS_Y) < TEST_EPS;
- zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.PLUS_Z) < TEST_EPS;
+ xVFound = xVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_X) < TEST_EPS;
+ yVFound = yVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Y) < TEST_EPS;
+ zVFound = zVFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Z) < TEST_EPS;
}
Assert.assertTrue(xPFound);
Assert.assertTrue(yPFound);
@@ -276,12 +276,12 @@ public class SphericalPolygonsSetTest {
double tol = 0.01;
DoublePrecisionContext precision = createPrecision(tol);
List<SubHyperplane<S2Point>> boundary = new ArrayList<>();
- boundary.add(create(Vector3D.MINUS_Y, Vector3D.PLUS_X, Vector3D.PLUS_Z, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.MINUS_X, Vector3D.PLUS_Z, Vector3D.PLUS_Y, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.PLUS_Z, Vector3D.PLUS_Y, Vector3D.MINUS_X, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.MINUS_Y, Vector3D.MINUS_X, Vector3D.MINUS_Z, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.MINUS_X, Vector3D.MINUS_Z, Vector3D.MINUS_Y, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.PLUS_Z, Vector3D.MINUS_Y, Vector3D.PLUS_X, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_X, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, Vector3D.Unit.MINUS_X, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_Y, Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_Z, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_Z, Vector3D.Unit.MINUS_Y, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.MINUS_Y, Vector3D.Unit.PLUS_X, precision, 0.0, 0.5 * Math.PI));
SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, precision);
Assert.assertEquals(Location.OUTSIDE, polygon.checkPoint(S2Point.ofVector(Vector3D.of( 1, 1, 1).normalize())));
@@ -310,12 +310,12 @@ public class SphericalPolygonsSetTest {
++count;
Edge e = v.getIncoming();
Assert.assertTrue(v == e.getStart().getOutgoing().getEnd());
- pXFound = pXFound || v.getLocation().getVector().distance(Vector3D.PLUS_X) < TEST_EPS;
- mXFound = mXFound || v.getLocation().getVector().distance(Vector3D.MINUS_X) < TEST_EPS;
- pYFound = pYFound || v.getLocation().getVector().distance(Vector3D.PLUS_Y) < TEST_EPS;
- mYFound = mYFound || v.getLocation().getVector().distance(Vector3D.MINUS_Y) < TEST_EPS;
- pZFound = pZFound || v.getLocation().getVector().distance(Vector3D.PLUS_Z) < TEST_EPS;
- mZFound = mZFound || v.getLocation().getVector().distance(Vector3D.MINUS_Z) < TEST_EPS;
+ pXFound = pXFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_X) < TEST_EPS;
+ mXFound = mXFound || v.getLocation().getVector().distance(Vector3D.Unit.MINUS_X) < TEST_EPS;
+ pYFound = pYFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Y) < TEST_EPS;
+ mYFound = mYFound || v.getLocation().getVector().distance(Vector3D.Unit.MINUS_Y) < TEST_EPS;
+ pZFound = pZFound || v.getLocation().getVector().distance(Vector3D.Unit.PLUS_Z) < TEST_EPS;
+ mZFound = mZFound || v.getLocation().getVector().distance(Vector3D.Unit.MINUS_Z) < TEST_EPS;
Assert.assertEquals(0.5 * Math.PI, e.getLength(), TEST_EPS);
}
Assert.assertTrue(pXFound);
@@ -336,14 +336,14 @@ public class SphericalPolygonsSetTest {
List<SubHyperplane<S2Point>> boundary = new ArrayList<>();
// first part: +X, +Y, +Z octant
- boundary.add(create(Vector3D.PLUS_Y, Vector3D.PLUS_Z, Vector3D.PLUS_X, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.PLUS_X, Vector3D.PLUS_Y, Vector3D.PLUS_Z, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, precision, 0.0, 0.5 * Math.PI));
// first part: -X, -Y, -Z octant
- boundary.add(create(Vector3D.MINUS_Y, Vector3D.MINUS_X, Vector3D.MINUS_Z, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.MINUS_X, Vector3D.MINUS_Z, Vector3D.MINUS_Y, precision, 0.0, 0.5 * Math.PI));
- boundary.add(create(Vector3D.MINUS_Z, Vector3D.MINUS_Y, Vector3D.MINUS_X, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_Y, Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_Z, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_X, Vector3D.Unit.MINUS_Z, Vector3D.Unit.MINUS_Y, precision, 0.0, 0.5 * Math.PI));
+ boundary.add(create(Vector3D.Unit.MINUS_Z, Vector3D.Unit.MINUS_Y, Vector3D.Unit.MINUS_X, precision, 0.0, 0.5 * Math.PI));
SphericalPolygonsSet polygon = new SphericalPolygonsSet(boundary, precision);
@@ -379,7 +379,7 @@ public class SphericalPolygonsSetTest {
double alpha = 0.7;
DoublePrecisionContext precision = createPrecision(tol);
S2Point center = S2Point.ofVector(Vector3D.of(1, 1, 1));
- SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Vector3D.PLUS_Z, alpha, 6, precision);
+ SphericalPolygonsSet hexa = new SphericalPolygonsSet(center.getVector(), Vector3D.Unit.PLUS_Z, alpha, 6, precision);
SphericalPolygonsSet hole = new SphericalPolygonsSet(precision,
S2Point.of(Math.PI / 6, Math.PI / 3),
S2Point.of(Math.PI / 3, Math.PI / 3),
@@ -409,14 +409,14 @@ public class SphericalPolygonsSetTest {
double tol = 0.001;
DoublePrecisionContext precision = createPrecision(tol);
Vector3D center = Vector3D.of(1, 1, 1);
- SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.9, 6, precision);
- SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.8, 6, precision);
- SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.7, 5, precision);
- SphericalPolygonsSet pentaIn = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.6, 5, precision);
- SphericalPolygonsSet quadriOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.5, 4, precision);
- SphericalPolygonsSet quadriIn = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.4, 4, precision);
- SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.25, 3, precision);
- SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Vector3D.PLUS_Z, 0.15, 3, precision);
+ SphericalPolygonsSet hexaOut = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.9, 6, precision);
+ SphericalPolygonsSet hexaIn = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.8, 6, precision);
+ SphericalPolygonsSet pentaOut = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.7, 5, precision);
+ SphericalPolygonsSet pentaIn = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.6, 5, precision);
+ SphericalPolygonsSet quadriOut = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.5, 4, precision);
+ SphericalPolygonsSet quadriIn = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.4, 4, precision);
+ SphericalPolygonsSet triOut = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.25, 3, precision);
+ SphericalPolygonsSet triIn = new SphericalPolygonsSet(center, Vector3D.Unit.PLUS_Z, 0.15, 3, precision);
RegionFactory<S2Point> factory = new RegionFactory<>();
SphericalPolygonsSet hexa = (SphericalPolygonsSet) factory.difference(hexaOut, hexaIn);
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
index 58e2015..b4664a0 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/SubCircleTest.java
@@ -38,7 +38,7 @@ public class SubCircleTest {
@Test
public void testFullCircle() {
- Circle circle = new Circle(Vector3D.PLUS_Z, TEST_PRECISION);
+ Circle circle = new Circle(Vector3D.Unit.PLUS_Z, TEST_PRECISION);
SubCircle set = circle.wholeHyperplane();
Assert.assertEquals(Geometry.TWO_PI, set.getSize(), TEST_EPS);
Assert.assertTrue(circle == set.getHyperplane());
@@ -48,21 +48,21 @@ public class SubCircleTest {
@Test
public void testSide() {
- Circle xzPlane = new Circle(Vector3D.PLUS_Y, TEST_PRECISION);
+ Circle xzPlane = new Circle(Vector3D.Unit.PLUS_Y, TEST_PRECISION);
- SubCircle sc1 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 1.0, 3.0, 5.0, 6.0);
+ SubCircle sc1 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 1.0, 3.0, 5.0, 6.0);
Assert.assertEquals(Side.BOTH, sc1.split(xzPlane).getSide());
- SubCircle sc2 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 1.0, 3.0);
+ SubCircle sc2 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 1.0, 3.0);
Assert.assertEquals(Side.MINUS, sc2.split(xzPlane).getSide());
- SubCircle sc3 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc3 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 5.0, 6.0);
Assert.assertEquals(Side.PLUS, sc3.split(xzPlane).getSide());
- SubCircle sc4 = create(Vector3D.PLUS_Y, Vector3D.PLUS_Z, Vector3D.PLUS_X, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc4 = create(Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, TEST_PRECISION, 5.0, 6.0);
Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide());
- SubCircle sc5 = create(Vector3D.MINUS_Y, Vector3D.PLUS_X, Vector3D.PLUS_Z, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc5 = create(Vector3D.Unit.MINUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, TEST_PRECISION, 5.0, 6.0);
Assert.assertEquals(Side.HYPER, sc5.split(xzPlane).getSide());
}
@@ -70,9 +70,9 @@ public class SubCircleTest {
@Test
public void testSPlit() {
- Circle xzPlane = new Circle(Vector3D.PLUS_Y, TEST_PRECISION);
+ Circle xzPlane = new Circle(Vector3D.Unit.PLUS_Y, TEST_PRECISION);
- SubCircle sc1 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 1.0, 3.0, 5.0, 6.0);
+ SubCircle sc1 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 1.0, 3.0, 5.0, 6.0);
SplitSubHyperplane<S2Point> split1 = sc1.split(xzPlane);
ArcsSet plus1 = (ArcsSet) ((SubCircle) split1.getPlus()).getRemainingRegion();
ArcsSet minus1 = (ArcsSet) ((SubCircle) split1.getMinus()).getRemainingRegion();
@@ -83,7 +83,7 @@ public class SubCircleTest {
Assert.assertEquals(1.0, minus1.asList().get(0).getInf(), TEST_EPS);
Assert.assertEquals(3.0, minus1.asList().get(0).getSup(), TEST_EPS);
- SubCircle sc2 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 1.0, 3.0);
+ SubCircle sc2 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 1.0, 3.0);
SplitSubHyperplane<S2Point> split2 = sc2.split(xzPlane);
Assert.assertNull(split2.getPlus());
ArcsSet minus2 = (ArcsSet) ((SubCircle) split2.getMinus()).getRemainingRegion();
@@ -91,7 +91,7 @@ public class SubCircleTest {
Assert.assertEquals(1.0, minus2.asList().get(0).getInf(), TEST_EPS);
Assert.assertEquals(3.0, minus2.asList().get(0).getSup(), TEST_EPS);
- SubCircle sc3 = create(Vector3D.PLUS_Z, Vector3D.PLUS_X, Vector3D.PLUS_Y, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc3 = create(Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, TEST_PRECISION, 5.0, 6.0);
SplitSubHyperplane<S2Point> split3 = sc3.split(xzPlane);
ArcsSet plus3 = (ArcsSet) ((SubCircle) split3.getPlus()).getRemainingRegion();
Assert.assertEquals(1, plus3.asList().size());
@@ -99,13 +99,13 @@ public class SubCircleTest {
Assert.assertEquals(6.0, plus3.asList().get(0).getSup(), TEST_EPS);
Assert.assertNull(split3.getMinus());
- SubCircle sc4 = create(Vector3D.PLUS_Y, Vector3D.PLUS_Z, Vector3D.PLUS_X, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc4 = create(Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, TEST_PRECISION, 5.0, 6.0);
SplitSubHyperplane<S2Point> split4 = sc4.split(xzPlane);
Assert.assertEquals(Side.HYPER, sc4.split(xzPlane).getSide());
Assert.assertNull(split4.getPlus());
Assert.assertNull(split4.getMinus());
- SubCircle sc5 = create(Vector3D.MINUS_Y, Vector3D.PLUS_X, Vector3D.PLUS_Z, TEST_PRECISION, 5.0, 6.0);
+ SubCircle sc5 = create(Vector3D.Unit.MINUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, TEST_PRECISION, 5.0, 6.0);
SplitSubHyperplane<S2Point> split5 = sc5.split(xzPlane);
Assert.assertEquals(Side.HYPER, sc5.split(xzPlane).getSide());
Assert.assertNull(split5.getPlus());