You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2020/05/27 11:29:26 UTC
[commons-geometry] 02/03: GEOMETRY-97: using the term 'centroid' to
refer to geometric center rather than 'barycenter'
This is an automated email from the ASF dual-hosted git repository.
mattjuntunen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-geometry.git
commit a70cea937b5621289a0be2e97b1a5f373b35b732
Author: Matt Juntunen <ma...@apache.org>
AuthorDate: Mon May 25 08:44:50 2020 -0400
GEOMETRY-97: using the term 'centroid' to refer to geometric center rather than 'barycenter'
---
.../org/apache/commons/geometry/core/Region.java | 15 +++-
.../core/partitioning/HyperplaneSubset.java | 17 +++--
.../partitioning/bsp/AbstractRegionBSPTree.java | 22 +++---
.../core/internal/HyperplaneSubsetsTest.java | 2 +-
.../AbstractConvexHyperplaneBoundedRegionTest.java | 2 +-
.../bsp/AbstractRegionBSPTreeTest.java | 6 +-
.../core/partitioning/test/TestLineSegment.java | 2 +-
.../test/TestLineSegmentCollection.java | 2 +-
.../commons/geometry/euclidean/AbstractBounds.java | 6 +-
.../geometry/euclidean/AbstractNSphere.java | 2 +-
.../commons/geometry/euclidean/oned/Interval.java | 2 +-
.../geometry/euclidean/oned/OrientedPoint.java | 2 +-
.../geometry/euclidean/oned/RegionBSPTree1D.java | 24 +++---
.../euclidean/threed/AbstractConvexPolygon3D.java | 24 +++---
.../threed/AbstractEmbeddedRegionPlaneSubset.java | 8 +-
.../geometry/euclidean/threed/ConvexVolume.java | 26 +++----
.../geometry/euclidean/threed/RegionBSPTree3D.java | 40 +++++-----
.../euclidean/threed/SimpleTriangle3D.java | 2 +-
.../threed/line/EmbeddedTreeLineSubset3D.java | 4 +-
.../threed/line/LineSpanningSubset3D.java | 2 +-
.../euclidean/threed/line/LineSubset3D.java | 8 +-
.../geometry/euclidean/threed/line/Ray3D.java | 2 +-
.../euclidean/threed/line/ReverseRay3D.java | 2 +-
.../geometry/euclidean/threed/line/Segment3D.java | 2 +-
.../geometry/euclidean/twod/ConvexArea.java | 4 +-
.../euclidean/twod/EmbeddedTreeLineSubset.java | 8 +-
.../euclidean/twod/LineSpanningSubset.java | 2 +-
.../commons/geometry/euclidean/twod/Ray.java | 2 +-
.../geometry/euclidean/twod/RegionBSPTree2D.java | 8 +-
.../geometry/euclidean/twod/ReverseRay.java | 2 +-
.../commons/geometry/euclidean/twod/Segment.java | 2 +-
.../euclidean/DocumentationExamplesTest.java | 22 +++---
.../geometry/euclidean/oned/IntervalTest.java | 16 ++--
.../geometry/euclidean/oned/OrientedPointTest.java | 2 +-
.../euclidean/oned/RegionBSPTree1DTest.java | 36 ++++-----
.../euclidean/threed/AbstractPlaneSubsetTest.java | 2 +-
.../geometry/euclidean/threed/Bounds3DTest.java | 16 ++--
.../euclidean/threed/ConvexVolumeTest.java | 14 ++--
.../threed/EmbeddedTreePlaneSubsetTest.java | 6 +-
.../geometry/euclidean/threed/PlanesTest.java | 2 +-
.../euclidean/threed/RegionBSPTree3DTest.java | 58 +++++++--------
.../euclidean/threed/SimpleTriangle3DTest.java | 2 +-
.../threed/VertexListConvexPolygon3DTest.java | 8 +-
.../threed/line/EmbeddedTreeLineSubset3DTest.java | 8 +-
.../geometry/euclidean/threed/line/Line3DTest.java | 2 +-
.../geometry/euclidean/threed/line/Ray3DTest.java | 6 +-
.../euclidean/threed/line/ReverseRay3DTest.java | 6 +-
.../euclidean/threed/line/Segment3DTest.java | 12 +--
.../euclidean/threed/shape/ParallelepipedTest.java | 14 ++--
.../euclidean/threed/shape/SphereTest.java | 9 +--
.../geometry/euclidean/twod/Bounds2DTest.java | 16 ++--
.../geometry/euclidean/twod/ConvexAreaTest.java | 60 +++++++--------
.../euclidean/twod/EmbeddedTreeLineSubsetTest.java | 10 +--
.../euclidean/twod/LineSpanningSubsetTest.java | 2 +-
.../geometry/euclidean/twod/LineSubsetTest.java | 2 +-
.../commons/geometry/euclidean/twod/RayTest.java | 6 +-
.../euclidean/twod/RegionBSPTree2DTest.java | 32 ++++----
.../geometry/euclidean/twod/ReverseRayTest.java | 6 +-
.../geometry/euclidean/twod/SegmentTest.java | 12 +--
.../geometry/euclidean/twod/shape/CircleTest.java | 8 +-
.../euclidean/twod/shape/ParallelogramTest.java | 16 ++--
.../geometry/spherical/oned/AngularInterval.java | 4 +-
.../commons/geometry/spherical/oned/CutAngle.java | 2 +-
.../geometry/spherical/oned/RegionBSPTree1S.java | 10 +--
.../geometry/spherical/twod/ConvexArea2S.java | 26 +++----
.../geometry/spherical/twod/GreatCircleSubset.java | 8 +-
.../geometry/spherical/twod/RegionBSPTree2S.java | 10 +--
.../spherical/DocumentationExamplesTest.java | 4 +-
.../spherical/oned/AngularIntervalTest.java | 4 +-
.../geometry/spherical/oned/CutAngleTest.java | 2 +-
.../spherical/oned/RegionBSPTree1STest.java | 24 +++---
.../geometry/spherical/twod/ConvexArea2STest.java | 85 +++++++++++-----------
.../twod/EmbeddedTreeSubGreatCircleTest.java | 8 +-
.../geometry/spherical/twod/GreatArcPathTest.java | 4 +-
.../geometry/spherical/twod/GreatArcTest.java | 4 +-
.../spherical/twod/GreatCircleSubsetTest.java | 2 +-
.../spherical/twod/RegionBSPTree2STest.java | 82 ++++++++++-----------
src/site/xdoc/index.xml | 4 +-
src/site/xdoc/userguide/index.xml | 14 ++--
79 files changed, 487 insertions(+), 473 deletions(-)
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Region.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Region.java
index 308f83f..a649f7b 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Region.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/Region.java
@@ -42,12 +42,19 @@ public interface Region<P extends Point<P>> extends Sized {
*/
double getBoundarySize();
- /** Get the barycenter of the region or null if no barycenter exists or
- * one exists but is not unique. A barycenter will not exist for empty or
+ /** Get the centroid, or geometric center, of the region or null if no centroid
+ * exists or one exists but is not unique. A centroid will not exist for empty or
* infinite regions.
- * @return the barycenter of the region or null if no unique barycenter exists
+ *
+ * <p>The centroid of a geometric object is defined as the mean position of
+ * all points in the object, including interior points, vertices, and other points
+ * lying on the boundary. If a physical object has a uniform density, then its center
+ * of mass is the same as its geometric centroid.
+ * </p>
+ * @return the centroid of the region or null if no unique centroid exists
+ * @see <a href="https://en.wikipedia.org/wiki/Centroid">Centroid</a>
*/
- P getBarycenter();
+ P getCentroid();
/** Classify the given point with respect to the region.
* @param pt the point to classify
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/HyperplaneSubset.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/HyperplaneSubset.java
index 580350c..43ac97f 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/HyperplaneSubset.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/HyperplaneSubset.java
@@ -65,12 +65,19 @@ public interface HyperplaneSubset<P extends Point<P>> extends Splittable<P, Hype
*/
boolean isEmpty();
- /** Get the barycenter of the hyperplane subset or null if no barycenter exists or
- * one exists but is not unique. A barycenter will not exist for empty or
- * infinite hyperplane subsets.
- * @return the barycenter of the hyperplane subset or null if no unique barycenter exists
+ /** Get the centroid, or geometric center, of the hyperplane subset or null
+ * if no centroid exists or one exists but is not unique. A centroid will not
+ * exist for empty or infinite subsets.
+ *
+ * <p>The centroid of a geometric object is defined as the mean position of
+ * all points in the object, including interior points, vertices, and other points
+ * lying on the boundary. If a physical object has a uniform density, then its center
+ * of mass is the same as its geometric centroid.
+ * </p>
+ * @return the centroid of the hyperplane subset or null if no unique centroid exists
+ * @see <a href="https://en.wikipedia.org/wiki/Centroid">Centroid</a>
*/
- P getBarycenter();
+ P getCentroid();
/** Classify a point with respect to the subset region. The point is classified as follows:
* <ul>
diff --git a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
index 1df224b..84c1552 100644
--- a/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
+++ b/commons-geometry-core/src/main/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTree.java
@@ -307,8 +307,8 @@ public abstract class AbstractRegionBSPTree<
/** {@inheritDoc} */
@Override
- public P getBarycenter() {
- return getRegionSizeProperties().getBarycenter();
+ public P getCentroid() {
+ return getRegionSizeProperties().getCentroid();
}
/** Helper method implementing the algorithm for splitting a tree by a hyperplane. Subclasses
@@ -890,16 +890,16 @@ public abstract class AbstractRegionBSPTree<
/** The size of the region. */
private final double size;
- /** The barycenter of the region. */
- private final P barycenter;
+ /** The centroid of the region. */
+ private final P centroid;
/** Simple constructor.
* @param size the region size
- * @param barycenter the region barycenter
+ * @param centroid the region centroid
*/
- public RegionSizeProperties(final double size, final P barycenter) {
+ public RegionSizeProperties(final double size, final P centroid) {
this.size = size;
- this.barycenter = barycenter;
+ this.centroid = centroid;
}
/** Get the size of the region.
@@ -909,11 +909,11 @@ public abstract class AbstractRegionBSPTree<
return size;
}
- /** Get the barycenter of the region.
- * @return the barycenter of the region
+ /** Get the centroid of the region.
+ * @return the centroid of the region
*/
- public P getBarycenter() {
- return barycenter;
+ public P getCentroid() {
+ return centroid;
}
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/HyperplaneSubsetsTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/HyperplaneSubsetsTest.java
index 5eeeca5..e17ebb9 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/HyperplaneSubsetsTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/internal/HyperplaneSubsetsTest.java
@@ -112,7 +112,7 @@ public class HyperplaneSubsetsTest {
}
@Override
- public TestPoint1D getBarycenter() {
+ public TestPoint1D getCentroid() {
throw new UnsupportedOperationException();
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
index 8c5a6bb..3b67d04 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/AbstractConvexHyperplaneBoundedRegionTest.java
@@ -589,7 +589,7 @@ public class AbstractConvexHyperplaneBoundedRegionTest {
}
@Override
- public TestPoint2D getBarycenter() {
+ public TestPoint2D getCentroid() {
throw new UnsupportedOperationException();
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
index 59dd3b0..50e946f 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/bsp/AbstractRegionBSPTreeTest.java
@@ -640,7 +640,7 @@ public class AbstractRegionBSPTreeTest {
Assert.assertNotSame(second, third);
Assert.assertEquals(1234, first.getSize(), PartitionTestUtils.EPS);
- PartitionTestUtils.assertPointsEqual(new TestPoint2D(12, 34), first.getBarycenter());
+ PartitionTestUtils.assertPointsEqual(new TestPoint2D(12, 34), first.getCentroid());
}
@Test
@@ -651,10 +651,10 @@ public class AbstractRegionBSPTreeTest {
}
@Test
- public void testGetBarycenter() {
+ public void testGetCentroid() {
// act/assert
// make sure our stub value is pulled
- PartitionTestUtils.assertPointsEqual(new TestPoint2D(12, 34), tree.getBarycenter());
+ PartitionTestUtils.assertPointsEqual(new TestPoint2D(12, 34), tree.getCentroid());
}
@Test
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java
index ab923b5..7ec2a4e 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegment.java
@@ -141,7 +141,7 @@ public class TestLineSegment implements HyperplaneConvexSubset<TestPoint2D> {
/** {@inheritDoc} */
@Override
- public TestPoint2D getBarycenter() {
+ public TestPoint2D getCentroid() {
return line.toSpace(0.5 * (end - start));
}
diff --git a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java
index 4918fc3..5b05916 100644
--- a/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java
+++ b/commons-geometry-core/src/test/java/org/apache/commons/geometry/core/partitioning/test/TestLineSegmentCollection.java
@@ -110,7 +110,7 @@ public class TestLineSegmentCollection implements HyperplaneSubset<TestPoint2D>
/** {@inheritDoc} */
@Override
- public TestPoint2D getBarycenter() {
+ public TestPoint2D getCentroid() {
throw new UnsupportedOperationException();
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractBounds.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractBounds.java
index 307d98b..e1c7d7f 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractBounds.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractBounds.java
@@ -66,10 +66,10 @@ public abstract class AbstractBounds<
return min.vectorTo(max);
}
- /** Return the center of the bounding box.
- * @return the center of the bounding box
+ /** Get the centroid, or geometric center, of the bounding box.
+ * @return the centroid of the bounding box
*/
- public P getBarycenter() {
+ public P getCentroid() {
return min.lerp(max, 0.5);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
index d7a8abf..d58b948 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/AbstractNSphere.java
@@ -110,7 +110,7 @@ public abstract class AbstractNSphere<V extends EuclideanVector<V>> implements R
* <p>This method is an alias for {@link #getCenter()}.</p>
*/
@Override
- public V getBarycenter() {
+ public V getCentroid() {
return getCenter();
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
index 57a2dd6..020b1bc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/Interval.java
@@ -281,7 +281,7 @@ public final class Interval implements HyperplaneBoundedRegion<Vector1D> {
/** {@inheritDoc} */
@Override
- public Vector1D getBarycenter() {
+ public Vector1D getCentroid() {
if (isInfinite()) {
return null;
}
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 1e641b8..8a70fd6 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
@@ -320,7 +320,7 @@ public final class OrientedPoint extends AbstractHyperplane<Vector1D>
* <p>This method returns the point for the defining hyperplane.</p>
*/
@Override
- public Vector1D getBarycenter() {
+ public Vector1D getCentroid() {
return hyperplane.getPoint();
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
index 28ba778..92224be 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1D.java
@@ -508,26 +508,26 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
/** Total computed size of all inside regions. */
private double size;
- /** Raw sum of the barycenters of each inside interval. */
- private double rawBarycenterSum;
+ /** Raw sum of the centroids of each inside interval. */
+ private double rawCentroidSum;
- /** The sum of the barycenter of each inside interval, scaled by the size of the interval. */
- private double scaledBarycenterSum;
+ /** The sum of the centroids of each inside interval, scaled by the size of the interval. */
+ private double scaledCentroidSum;
/** {@inheritDoc} */
@Override
- public void accept(OrientedPoint min, OrientedPoint max) {
+ public void accept(final OrientedPoint min, final OrientedPoint max) {
++count;
final double minLoc = (min != null) ? min.getLocation() : Double.NEGATIVE_INFINITY;
final double maxLoc = (max != null) ? max.getLocation() : Double.POSITIVE_INFINITY;
final double intervalSize = maxLoc - minLoc;
- final double intervalBarycenter = 0.5 * (maxLoc + minLoc);
+ final double intervalCentroid = 0.5 * (maxLoc + minLoc);
size += intervalSize;
- rawBarycenterSum += intervalBarycenter;
- scaledBarycenterSum += intervalSize * intervalBarycenter;
+ rawCentroidSum += intervalCentroid;
+ scaledCentroidSum += intervalSize * intervalCentroid;
}
/** Get the computed properties for the region. This must only be called after
@@ -535,20 +535,20 @@ public final class RegionBSPTree1D extends AbstractRegionBSPTree<Vector1D, Regio
* @return properties for the region
*/
public RegionSizeProperties<Vector1D> getRegionSizeProperties() {
- Vector1D barycenter = null;
+ Vector1D centroid = null;
if (count > 0 && Double.isFinite(size)) {
if (size > 0.0) {
// use the scaled sum if we have a non-zero size
- barycenter = Vector1D.of(scaledBarycenterSum / size);
+ centroid = Vector1D.of(scaledCentroidSum / size);
} else {
// use the raw sum if we don't have a size; this will be
// the case if the region only contains points with zero size
- barycenter = Vector1D.of(rawBarycenterSum / count);
+ centroid = Vector1D.of(rawCentroidSum / count);
}
}
- return new RegionSizeProperties<>(size, barycenter);
+ return new RegionSizeProperties<>(size, centroid);
}
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java
index 8d69812..c8d0f32 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractConvexPolygon3D.java
@@ -95,13 +95,13 @@ abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements Co
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
final List<Vector3D> vertices = getVertices();
double areaSum = 0.0;
- double scaledBarycenterSumX = 0.0;
- double scaledBarycenterSumY = 0.0;
- double scaledBarycenterSumZ = 0.0;
+ double scaledCentroidSumX = 0.0;
+ double scaledCentroidSumY = 0.0;
+ double scaledCentroidSumZ = 0.0;
Iterator<Vector3D> it = vertices.iterator();
@@ -114,19 +114,19 @@ abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements Co
Vector3D curVec = null;
double triArea;
- Vector3D triBarycenter;
+ Vector3D triCentroid;
while (it.hasNext()) {
curPt = it.next();
curVec = startPt.vectorTo(curPt);
triArea = 0.5 * prevVec.cross(curVec).norm();
- triBarycenter = Vector3D.centroid(startPt, prevPt, curPt);
+ triCentroid = Vector3D.centroid(startPt, prevPt, curPt);
areaSum += triArea;
- scaledBarycenterSumX += triArea * triBarycenter.getX();
- scaledBarycenterSumY += triArea * triBarycenter.getY();
- scaledBarycenterSumZ += triArea * triBarycenter.getZ();
+ scaledCentroidSumX += triArea * triCentroid.getX();
+ scaledCentroidSumY += triArea * triCentroid.getY();
+ scaledCentroidSumZ += triArea * triCentroid.getZ();
prevPt = curPt;
prevVec = curVec;
@@ -135,9 +135,9 @@ abstract class AbstractConvexPolygon3D extends AbstractPlaneSubset implements Co
if (areaSum > 0.0) {
final double scale = 1 / areaSum;
return Vector3D.of(
- scale * scaledBarycenterSumX,
- scale * scaledBarycenterSumY,
- scale * scaledBarycenterSumZ
+ scale * scaledCentroidSumX,
+ scale * scaledCentroidSumY,
+ scale * scaledCentroidSumZ
);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java
index b19f3c4..d535533 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/AbstractEmbeddedRegionPlaneSubset.java
@@ -69,10 +69,10 @@ abstract class AbstractEmbeddedRegionPlaneSubset extends AbstractPlaneSubset imp
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
- final Vector2D subspaceBarycenter = getSubspaceRegion().getBarycenter();
- if (subspaceBarycenter != null) {
- return getPlane().toSpace(subspaceBarycenter);
+ public Vector3D getCentroid() {
+ final Vector2D subspaceCentroid = getSubspaceRegion().getCentroid();
+ if (subspaceCentroid != null) {
+ return getPlane().toSpace(subspaceCentroid);
}
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
index fb9e940..19465ee 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/ConvexVolume.java
@@ -66,9 +66,9 @@ public class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Vector3D
final Plane boundaryPlane = boundary.getPlane();
final double boundaryArea = boundary.getSize();
- final Vector3D boundaryBarycenter = boundary.getBarycenter();
+ final Vector3D boundaryCentroid = boundary.getCentroid();
- volumeSum += boundaryArea * boundaryBarycenter.dot(boundaryPlane.getNormal());
+ volumeSum += boundaryArea * boundaryCentroid.dot(boundaryPlane.getNormal());
}
return volumeSum / 3.0;
@@ -76,7 +76,7 @@ public class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Vector3D
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
double volumeSum = 0.0;
double sumX = 0.0;
@@ -90,15 +90,15 @@ public class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Vector3D
final Plane boundaryPlane = boundary.getPlane();
final double boundaryArea = boundary.getSize();
- final Vector3D boundaryBarycenter = boundary.getBarycenter();
+ final Vector3D boundaryCentroid = boundary.getCentroid();
- final double scaledVolume = boundaryArea * boundaryBarycenter.dot(boundaryPlane.getNormal());
+ final double scaledVolume = boundaryArea * boundaryCentroid.dot(boundaryPlane.getNormal());
volumeSum += scaledVolume;
- sumX += scaledVolume * boundaryBarycenter.getX();
- sumY += scaledVolume * boundaryBarycenter.getY();
- sumZ += scaledVolume * boundaryBarycenter.getZ();
+ sumX += scaledVolume * boundaryCentroid.getX();
+ sumY += scaledVolume * boundaryCentroid.getY();
+ sumZ += scaledVolume * boundaryCentroid.getZ();
}
if (volumeSum > 0) {
@@ -106,12 +106,12 @@ public class ConvexVolume extends AbstractConvexHyperplaneBoundedRegion<Vector3D
// Since the volume we used when adding together the boundary contributions
// was 3x the actual pyramid size, we'll multiply by 1/4 here instead
- // of 3/4 to adjust for the actual barycenter position in each pyramid.
- final double barycenterScale = 1.0 / (4 * size);
+ // of 3/4 to adjust for the actual centroid position in each pyramid.
+ final double centroidScale = 1.0 / (4 * size);
return Vector3D.of(
- sumX * barycenterScale,
- sumY * barycenterScale,
- sumZ * barycenterScale);
+ sumX * centroidScale,
+ sumY * centroidScale,
+ sumZ * centroidScale);
}
return null;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
index 66126fe..b4c1781 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3D.java
@@ -283,13 +283,13 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
* The volume of the region is computed using the equation
* <code>V = (1/3)*Σ<sub>F</sub>[(C<sub>F</sub>⋅N<sub>F</sub>)*area(F)]</code>,
* where <code>F</code> represents each face in the region, <code>C<sub>F</sub></code>
- * represents the barycenter of the face, and <code>N<sub>F</sub></code> represents the
+ * represents the centroid of the face, and <code>N<sub>F</sub></code> represents the
* normal of the face. (More details can be found in the article
* <a href="https://en.wikipedia.org/wiki/Polyhedron#Volume">here</a>.)
* This essentially splits up the region into pyramids with a 2D face forming
- * the base of each pyramid. The barycenter is computed in a similar way. The barycenter
+ * the base of each pyramid. The centroid is computed in a similar way. The centroid
* of each pyramid is calculated using the fact that it is located 3/4 of the way along the
- * line from the apex to the base. The region barycenter then becomes the volume-weighted
+ * line from the apex to the base. The region centroid then becomes the volume-weighted
* average of these pyramid centers.
* @see https://en.wikipedia.org/wiki/Polyhedron#Volume
*/
@@ -298,13 +298,13 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
/** Accumulator for boundary volume contributions. */
private double volumeSum;
- /** Barycenter contribution x coordinate accumulator. */
+ /** Centroid contribution x coordinate accumulator. */
private double sumX;
- /** Barycenter contribution y coordinate accumulator. */
+ /** Centroid contribution y coordinate accumulator. */
private double sumY;
- /** Barycenter contribution z coordinate accumulator. */
+ /** Centroid contribution z coordinate accumulator. */
private double sumZ;
/** {@inheritDoc} */
@@ -324,7 +324,7 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
*/
public RegionSizeProperties<Vector3D> getRegionSizeProperties() {
double size = Double.POSITIVE_INFINITY;
- Vector3D barycenter = null;
+ Vector3D centroid = null;
// we only have a finite size if the volume sum is finite and positive
// (negative indicates a finite outside surrounded by an infinite inside)
@@ -334,15 +334,15 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
// Since the volume we used when adding together the boundary contributions
// was 3x the actual pyramid size, we'll multiply by 1/4 here instead
- // of 3/4 to adjust for the actual barycenter position in each pyramid.
- final double barycenterScale = 1.0 / (4 * size);
- barycenter = Vector3D.of(
- sumX * barycenterScale,
- sumY * barycenterScale,
- sumZ * barycenterScale);
+ // of 3/4 to adjust for the actual centroid position in each pyramid.
+ final double centroidScale = 1.0 / (4 * size);
+ centroid = Vector3D.of(
+ sumX * centroidScale,
+ sumY * centroidScale,
+ sumZ * centroidScale);
}
- return new RegionSizeProperties<>(size, barycenter);
+ return new RegionSizeProperties<>(size, centroid);
}
/** Add the contribution of the given node cut boundary. If {@code reverse} is true,
@@ -355,23 +355,23 @@ public final class RegionBSPTree3D extends AbstractRegionBSPTree<Vector3D, Regio
final Plane boundaryPlane = boundarySubset.getPlane();
final double boundaryArea = boundarySubset.getSize();
- final Vector3D boundaryBarycenter = boundarySubset.getBarycenter();
+ final Vector3D boundaryCentroid = boundarySubset.getCentroid();
if (Double.isInfinite(boundaryArea)) {
volumeSum = Double.POSITIVE_INFINITY;
- } else if (boundaryBarycenter != null) {
+ } else if (boundaryCentroid != null) {
// the volume here is actually 3x the actual pyramid volume; we'll apply
// the final scaling all at once at the end
- double scaledVolume = boundaryArea * boundaryBarycenter.dot(boundaryPlane.getNormal());
+ double scaledVolume = boundaryArea * boundaryCentroid.dot(boundaryPlane.getNormal());
if (reverse) {
scaledVolume = -scaledVolume;
}
volumeSum += scaledVolume;
- sumX += scaledVolume * boundaryBarycenter.getX();
- sumY += scaledVolume * boundaryBarycenter.getY();
- sumZ += scaledVolume * boundaryBarycenter.getZ();
+ sumX += scaledVolume * boundaryCentroid.getX();
+ sumY += scaledVolume * boundaryCentroid.getY();
+ sumZ += scaledVolume * boundaryCentroid.getZ();
}
}
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3D.java
index e5e8b39..f016fbd 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3D.java
@@ -85,7 +85,7 @@ final class SimpleTriangle3D extends AbstractConvexPolygon3D implements Triangle
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
return Vector3D.centroid(p1, p2, p3);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3D.java
index 71e2fa1..95b5d78 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3D.java
@@ -79,8 +79,8 @@ public final class EmbeddedTreeLineSubset3D extends LineSubset3D {
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
- final Vector1D subcenter = region.getBarycenter();
+ public Vector3D getCentroid() {
+ final Vector1D subcenter = region.getCentroid();
return subcenter != null ?
getLine().toSpace(subcenter) :
null;
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSpanningSubset3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSpanningSubset3D.java
index 0c75a9a..48ddfec 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSpanningSubset3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSpanningSubset3D.java
@@ -104,7 +104,7 @@ final class LineSpanningSubset3D extends LineConvexSubset3D {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
return null; // infinite; no center
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSubset3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSubset3D.java
index 0c3c110..2bea44e 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSubset3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/LineSubset3D.java
@@ -56,12 +56,12 @@ public abstract class LineSubset3D implements RegionEmbedding<Vector3D, Vector1D
return line.toSubspace(pt);
}
- /** Get the center of the line subset, or null if the subset is empty of
- * infinite.
- * @return the center of the line subset, or null if the subset is empty of
+ /** Get the centroid, or geometric center, of the line subset or null if
+ * the subset is empty or infinite.
+ * @return the centroid of the line subset, or null if the subset is empty or
* infinite
*/
- public abstract Vector3D getBarycenter();
+ public abstract Vector3D getCentroid();
/** Get the 3D bounding box of the line subset or null if the subset is
* empty or infinite.
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Ray3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Ray3D.java
index 1448efd..42df584 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Ray3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Ray3D.java
@@ -113,7 +113,7 @@ public final class Ray3D extends LineConvexSubset3D {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
return null; // infinite; no center
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3D.java
index 3fb8aa2..6e1e0ef 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3D.java
@@ -114,7 +114,7 @@ public final class ReverseRay3D extends LineConvexSubset3D {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
return null; // infinite; no center
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Segment3D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Segment3D.java
index 62f0a4b..255a73b 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Segment3D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/threed/line/Segment3D.java
@@ -109,7 +109,7 @@ public final class Segment3D extends LineConvexSubset3D {
/** {@inheritDoc} */
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
return getLine().toSpace((0.5 * (end - start)) + start);
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
index 0aecbeb..0a1a4cc 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ConvexArea.java
@@ -143,7 +143,7 @@ public class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vector2D,
/** {@inheritDoc} */
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
final List<LineConvexSubset> boundaries = getBoundaries();
double quadrilateralAreaSum = 0.0;
@@ -156,7 +156,7 @@ public class ConvexArea extends AbstractConvexHyperplaneBoundedRegion<Vector2D,
for (final LineConvexSubset seg : boundaries) {
if (seg.isInfinite()) {
- // infinite => no barycenter
+ // infinite => no centroid
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubset.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubset.java
index 8a56114..4786c2a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubset.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubset.java
@@ -91,10 +91,10 @@ public final class EmbeddedTreeLineSubset extends LineSubset {
/** {@inheritDoc} */
@Override
- public Vector2D getBarycenter() {
- final Vector1D subspaceBarycenter = region.getBarycenter();
- if (subspaceBarycenter != null) {
- return getLine().toSpace(subspaceBarycenter);
+ public Vector2D getCentroid() {
+ final Vector1D subspaceCentroid = region.getCentroid();
+ if (subspaceCentroid != null) {
+ return getLine().toSpace(subspaceCentroid);
}
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubset.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubset.java
index 8c504f5..a1c5d7a 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubset.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubset.java
@@ -77,7 +77,7 @@ final class LineSpanningSubset extends LineConvexSubset {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Ray.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Ray.java
index 304b8a7..e127845 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Ray.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Ray.java
@@ -85,7 +85,7 @@ public final class Ray extends LineConvexSubset {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
index 004b369..fc44228 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2D.java
@@ -232,13 +232,13 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
quadrilateralAreaSum += signedArea;
- // compute scaled coordinate values for the barycenter
+ // compute scaled coordinate values for the centroid
scaledSumX += signedArea * (startPoint.getX() + endPoint.getX());
scaledSumY += signedArea * (startPoint.getY() + endPoint.getY());
}
double size = Double.POSITIVE_INFINITY;
- Vector2D barycenter = null;
+ Vector2D centroid = null;
// The area is finite only if the computed quadrilateral area is finite and non-negative.
// Negative areas indicate that the region is inside-out, with a finite outside surrounded
@@ -247,11 +247,11 @@ public final class RegionBSPTree2D extends AbstractRegionBSPTree<Vector2D, Regio
size = 0.5 * quadrilateralAreaSum;
if (quadrilateralAreaSum > 0.0) {
- barycenter = Vector2D.of(scaledSumX, scaledSumY).multiply(1.0 / (3.0 * quadrilateralAreaSum));
+ centroid = Vector2D.of(scaledSumX, scaledSumY).multiply(1.0 / (3.0 * quadrilateralAreaSum));
}
}
- return new RegionSizeProperties<>(size, barycenter);
+ return new RegionSizeProperties<>(size, centroid);
}
/** {@inheritDoc} */
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ReverseRay.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ReverseRay.java
index 6abec6a..b35e969 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ReverseRay.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/ReverseRay.java
@@ -86,7 +86,7 @@ public final class ReverseRay extends LineConvexSubset {
* <p>This method always returns {@code null}.</p>
*/
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
return null;
}
diff --git a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
index 8fa77b0..e36f878 100644
--- a/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
+++ b/commons-geometry-euclidean/src/main/java/org/apache/commons/geometry/euclidean/twod/Segment.java
@@ -85,7 +85,7 @@ public final class Segment extends LineConvexSubset {
/** {@inheritDoc} */
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
return startPoint.lerp(endPoint, 0.5);
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/DocumentationExamplesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/DocumentationExamplesTest.java
index 0051704..2ba5d8a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/DocumentationExamplesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/DocumentationExamplesTest.java
@@ -67,7 +67,7 @@ public class DocumentationExamplesTest {
// construct a precision context to handle floating-point comparisons
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
- // create a binary space partitioning tree representing the unit cube
+ // create a binary space partitioning (BSP) tree representing the unit cube
// centered on the origin
RegionBSPTree3D region = Parallelepiped.builder(precision)
.setPosition(Vector3D.ZERO)
@@ -84,11 +84,11 @@ public class DocumentationExamplesTest {
// compute some properties of the intersection region
double size = region.getSize(); // 0.8284271247461903
- Vector3D center = region.getBarycenter(); // (0, 0, 0)
+ Vector3D centroid = region.getCentroid(); // (0, 0, 0)
// -----------
Assert.assertEquals(0.8284271247461903, size, TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, center, TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, centroid, TEST_EPS);
}
@Test
@@ -167,13 +167,13 @@ public class DocumentationExamplesTest {
int count = tree.count(); // number of nodes in the tree = 11
int height = tree.height(); // height of the tree = 3
double size = tree.getSize(); // size of the region = 1
- Vector2D barycenter = tree.getBarycenter(); // region barycenter = (0.5, 0.5)
+ Vector2D centroid = tree.getCentroid(); // region centroid = (0.5, 0.5)
// ---------
Assert.assertEquals(1, size, TEST_EPS);
Assert.assertEquals(11, count);
Assert.assertEquals(3, height);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), barycenter, TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), centroid, TEST_EPS);
}
@Test
@@ -195,13 +195,13 @@ public class DocumentationExamplesTest {
int count = tree.count(); // number of nodes in the tree = 9
int height = tree.height(); // height of the tree = 4
double size = tree.getSize(); // size of the region = 1
- Vector2D barycenter = tree.getBarycenter(); // region barycenter = (0.5, 0.5)
+ Vector2D centroid = tree.getCentroid(); // region centroid = (0.5, 0.5)
// ---------
Assert.assertEquals(1, size, TEST_EPS);
Assert.assertEquals(9, count);
Assert.assertEquals(4, height);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), barycenter, TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), centroid, TEST_EPS);
}
@Test
@@ -321,7 +321,7 @@ public class DocumentationExamplesTest {
// compute some properties
double size = tree.getSize(); // 1.75
- Vector2D center = tree.getBarycenter(); // (0.75, 0.75)
+ Vector2D centroid = tree.getCentroid(); // (0.75, 0.75)
// get a line path representing the boundary; a list is returned since trees
// can represent disjoint regions
@@ -329,7 +329,7 @@ public class DocumentationExamplesTest {
// ----------------
Assert.assertEquals(1.75, size, TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.75, 0.75), center, TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.75, 0.75), centroid, TEST_EPS);
Assert.assertEquals(1, boundaries.size());
}
@@ -430,8 +430,8 @@ public class DocumentationExamplesTest {
List<ConvexPolygon3D> faces = Planes.indexedConvexPolygons(vertices, faceIndices, precision);
RegionBSPTree3D tree = RegionBSPTree3D.from(faces);
- // split the region through its barycenter along a diagonal of the base
- Plane cutter = Planes.fromPointAndNormal(tree.getBarycenter(), Vector3D.Unit.from(1, 1, 0), precision);
+ // split the region through its centroid along a diagonal of the base
+ Plane cutter = Planes.fromPointAndNormal(tree.getCentroid(), Vector3D.Unit.from(1, 1, 0), precision);
Split<RegionBSPTree3D> split = tree.split(cutter);
// compute some properties for the minus side of the split and convert back to hyperplane subsets
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
index 151e0fa..2a49706 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/IntervalTest.java
@@ -405,21 +405,21 @@ public class IntervalTest {
}
@Test
- public void testGetBarycenter() {
+ public void testGetCentroid() {
// act/assert
EuclideanTestUtils.assertCoordinatesEqual(Vector1D.ZERO,
- Interval.of(-1, 1, TEST_PRECISION).getBarycenter(), TEST_EPS);
+ Interval.of(-1, 1, TEST_PRECISION).getCentroid(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(10),
- Interval.of(10, 10, TEST_PRECISION).getBarycenter(), TEST_EPS);
+ Interval.of(10, 10, TEST_PRECISION).getCentroid(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(2),
- Interval.of(1, 3, TEST_PRECISION).getBarycenter(), TEST_EPS);
+ Interval.of(1, 3, TEST_PRECISION).getCentroid(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(-1),
- Interval.of(-2, 0, TEST_PRECISION).getBarycenter(), TEST_EPS);
+ Interval.of(-2, 0, TEST_PRECISION).getCentroid(), TEST_EPS);
- Assert.assertNull(Interval.of(1, Double.POSITIVE_INFINITY, TEST_PRECISION).getBarycenter());
- Assert.assertNull(Interval.of(Double.NEGATIVE_INFINITY, 1, TEST_PRECISION).getBarycenter());
- Assert.assertNull(Interval.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION).getBarycenter());
+ Assert.assertNull(Interval.of(1, Double.POSITIVE_INFINITY, TEST_PRECISION).getCentroid());
+ Assert.assertNull(Interval.of(Double.NEGATIVE_INFINITY, 1, TEST_PRECISION).getCentroid());
+ Assert.assertNull(Interval.of(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, TEST_PRECISION).getCentroid());
}
@Test
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 249d89b..1e97c50 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
@@ -434,7 +434,7 @@ public class OrientedPointTest {
Assert.assertFalse(sub.isInfinite());
Assert.assertTrue(sub.isFinite());
Assert.assertEquals(0.0, sub.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(2), sub.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(2), sub.getCentroid(), TEST_EPS);
List<? extends HyperplaneConvexSubset<Vector1D>> list = sub.toConvex();
Assert.assertEquals(1, list.size());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
index f6f1525..b355e57 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/oned/RegionBSPTree1DTest.java
@@ -962,7 +962,7 @@ public class RegionBSPTree1DTest {
}
@Test
- public void testGetBarycenter_infinite() {
+ public void testGetCentroid_infinite() {
// arrange
RegionBSPTree1D full = RegionBSPTree1D.full();
@@ -973,22 +973,22 @@ public class RegionBSPTree1DTest {
negHalfSpace.getRoot().cut(OrientedPoints.createPositiveFacing(3.0, TEST_PRECISION));
// act/assert
- Assert.assertNull(full.getBarycenter());
- Assert.assertNull(posHalfSpace.getBarycenter());
- Assert.assertNull(negHalfSpace.getBarycenter());
+ Assert.assertNull(full.getCentroid());
+ Assert.assertNull(posHalfSpace.getCentroid());
+ Assert.assertNull(negHalfSpace.getCentroid());
}
@Test
- public void testGetBarycenter_empty() {
+ public void testGetCentroid_empty() {
// arrange
RegionBSPTree1D tree = RegionBSPTree1D.empty();
// act/assert
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
- public void testGetBarycenter_exactPoints() {
+ public void testGetCentroid_exactPoints() {
// arrange
RegionBSPTree1D singlePoint = RegionBSPTree1D.empty();
singlePoint.add(Interval.of(1, 1, TEST_PRECISION));
@@ -999,12 +999,12 @@ public class RegionBSPTree1DTest {
multiplePoints.add(Interval.of(6, 6, TEST_PRECISION));
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1), singlePoint.getBarycenter(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(2), multiplePoints.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1), singlePoint.getCentroid(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(2), multiplePoints.getCentroid(), TEST_EPS);
}
@Test
- public void testGetBarycenter_pointsWithinPrecision() {
+ public void testGetCentroid_pointsWithinPrecision() {
// arrange
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-1);
@@ -1017,23 +1017,23 @@ public class RegionBSPTree1DTest {
multiplePoints.add(Interval.of(6, 6.02, precision));
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1.01), singlePoint.getBarycenter(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(6.01 / 3), multiplePoints.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1.01), singlePoint.getCentroid(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(6.01 / 3), multiplePoints.getCentroid(), TEST_EPS);
}
@Test
- public void testGetBarycenter_nonEmptyIntervals() {
+ public void testGetCentroid_nonEmptyIntervals() {
// arrange
RegionBSPTree1D tree = RegionBSPTree1D.empty();
tree.add(Interval.of(1, 2, TEST_PRECISION));
tree.add(Interval.of(3, 5, TEST_PRECISION));
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(9.5 / 3), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(9.5 / 3), tree.getCentroid(), TEST_EPS);
}
@Test
- public void testGetBarycenter_complementedRegion() {
+ public void testGetCentroid_complementedRegion() {
// arrange
RegionBSPTree1D tree = RegionBSPTree1D.empty();
tree.add(Interval.of(Double.NEGATIVE_INFINITY, 2, TEST_PRECISION));
@@ -1042,11 +1042,11 @@ public class RegionBSPTree1DTest {
tree.complement();
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(3), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(3), tree.getCentroid(), TEST_EPS);
}
@Test
- public void testGetBarycenter_intervalWithPoints() {
+ public void testGetCentroid_intervalWithPoints() {
// arrange
RegionBSPTree1D tree = RegionBSPTree1D.empty();
tree.add(Interval.of(1, 2, TEST_PRECISION));
@@ -1054,7 +1054,7 @@ public class RegionBSPTree1DTest {
tree.add(Interval.of(5, 5, TEST_PRECISION));
// act/assert
- EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector1D.of(1.5), tree.getCentroid(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AbstractPlaneSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AbstractPlaneSubsetTest.java
index 846a95e..4527771 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AbstractPlaneSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/AbstractPlaneSubsetTest.java
@@ -314,7 +314,7 @@ public class AbstractPlaneSubsetTest {
}
@Override
- public Vector3D getBarycenter() {
+ public Vector3D getCentroid() {
throw new UnsupportedOperationException();
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
index 7693870..0fb2b0a 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/Bounds3DTest.java
@@ -54,7 +54,7 @@ public class Bounds3DTest {
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(p1, b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(p1, b.getCentroid(), TEST_EPS);
}
@Test
@@ -71,7 +71,7 @@ public class Bounds3DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 5, 7), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(3, 6, 11), b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(3, 1, 4), b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 5.5, 9), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 5.5, 9), b.getCentroid(), TEST_EPS);
}
@Test
@@ -86,7 +86,7 @@ public class Bounds3DTest {
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(p1, b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(p1, b.getCentroid(), TEST_EPS);
}
@Test
@@ -103,7 +103,7 @@ public class Bounds3DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 4, 7), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(3, 6, 9), b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2, 2, 2), b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2, 5, 8), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2, 5, 8), b.getCentroid(), TEST_EPS);
}
@Test
@@ -189,7 +189,7 @@ public class Bounds3DTest {
// act/assert
assertContainsStrict(b, true,
- b.getBarycenter(),
+ b.getCentroid(),
Vector3D.of(0, 4, 8), Vector3D.of(2, 6, 10),
Vector3D.of(1, 5, 9),
Vector3D.of(0, 5, 9), Vector3D.of(2, 5, 9),
@@ -213,7 +213,7 @@ public class Bounds3DTest {
// act/assert
assertContainsWithPrecision(b, true,
- b.getBarycenter(),
+ b.getCentroid(),
Vector3D.of(0, 4, 8), Vector3D.of(2, 6, 10),
Vector3D.of(1, 5, 9),
Vector3D.of(0, 5, 9), Vector3D.of(2, 5, 9),
@@ -374,7 +374,7 @@ public class Bounds3DTest {
// assert
Assert.assertEquals(8, p.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 5, 9), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 5, 9), p.getCentroid(), TEST_EPS);
}
@Test
@@ -496,7 +496,7 @@ public class Bounds3DTest {
// assert
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 6, 11), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(5, 10, 15), b.getMax(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(3, 8, 13), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(3, 8, 13), b.getCentroid(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
index a0a83c1..7d94421 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/ConvexVolumeTest.java
@@ -51,7 +51,7 @@ public class ConvexVolumeTest {
Assert.assertFalse(vol.isEmpty());
GeometryTestUtils.assertPositiveInfinity(vol.getSize());
- Assert.assertNull(vol.getBarycenter());
+ Assert.assertNull(vol.getCentroid());
Assert.assertEquals(0, vol.getBoundaries().size());
Assert.assertEquals(0, vol.getBoundarySize(), TEST_EPS);
@@ -210,7 +210,7 @@ public class ConvexVolumeTest {
// assert
Assert.assertEquals(1, tree.getSize(), TEST_EPS);
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0.5, 0.5), Vector3D.of(2, 0.5, 0.5),
@@ -239,7 +239,7 @@ public class ConvexVolumeTest {
Assert.assertFalse(vol.isEmpty());
GeometryTestUtils.assertPositiveInfinity(vol.getSize());
- Assert.assertNull(vol.getBarycenter());
+ Assert.assertNull(vol.getCentroid());
Assert.assertEquals(1, vol.getBoundaries().size());
GeometryTestUtils.assertPositiveInfinity(vol.getBoundarySize());
@@ -259,7 +259,7 @@ public class ConvexVolumeTest {
Assert.assertFalse(vol.isEmpty());
Assert.assertEquals(8, vol.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 1), vol.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 1), vol.getCentroid(), TEST_EPS);
Assert.assertEquals(6, vol.getBoundaries().size());
Assert.assertEquals(28, vol.getBoundarySize(), TEST_EPS);
@@ -313,11 +313,11 @@ public class ConvexVolumeTest {
ConvexVolume minus = split.getMinus();
Assert.assertEquals(0.5, minus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.25, 0, 0), minus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.25, 0, 0), minus.getCentroid(), TEST_EPS);
ConvexVolume plus = split.getPlus();
Assert.assertEquals(0.5, plus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.25, 0, 0), plus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.25, 0, 0), plus.getCentroid(), TEST_EPS);
}
@Test
@@ -377,7 +377,7 @@ public class ConvexVolumeTest {
Assert.assertEquals(2, transformed.getSize(), TEST_EPS);
Assert.assertEquals(10, transformed.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2, 2, 3), transformed.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2, 2, 3), transformed.getCentroid(), TEST_EPS);
}
private static ConvexVolume rect(Vector3D center, double xDelta, double yDelta, double zDelta) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
index 41dca76..245fd10 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/EmbeddedTreePlaneSubsetTest.java
@@ -593,7 +593,7 @@ public class EmbeddedTreePlaneSubsetTest {
// assert
Assert.assertEquals(4, ps.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 0, 1), ps.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0, 0, 1), ps.getCentroid(), TEST_EPS);
Bounds3D bounds = ps.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, -1, 1), bounds.getMin(), TEST_EPS);
@@ -620,7 +620,7 @@ public class EmbeddedTreePlaneSubsetTest {
// assert
Assert.assertEquals(2, ps.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0.5, 1), ps.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0.5, 1), ps.getCentroid(), TEST_EPS);
Bounds3D bounds = ps.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-2, 0, 1), bounds.getMin(), TEST_EPS);
@@ -647,7 +647,7 @@ public class EmbeddedTreePlaneSubsetTest {
// assert
Assert.assertEquals(2, ps.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.5, -1, 1), ps.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.5, -1, 1), ps.getCentroid(), TEST_EPS);
Bounds3D bounds = ps.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, -2, 1), bounds.getMin(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
index ed8092d..6be9012 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/PlanesTest.java
@@ -231,7 +231,7 @@ public class PlanesTest {
// assert
Assert.assertEquals(0.5, tri.getSize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(5.0 / 3.0, 1, 4.0 / 3.0),
- tri.getBarycenter(), TEST_EPS);
+ tri.getCentroid(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
index f99430f..8ea9999 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/RegionBSPTree3DTest.java
@@ -81,7 +81,7 @@ public class RegionBSPTree3DTest {
Assert.assertFalse(tree.isFull());
Assert.assertTrue(tree.isEmpty());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(0.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -102,7 +102,7 @@ public class RegionBSPTree3DTest {
Assert.assertTrue(tree.isFull());
Assert.assertFalse(tree.isEmpty());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -216,7 +216,7 @@ public class RegionBSPTree3DTest {
// assert
Assert.assertEquals(15.0 / 8.0, result.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.75, 0.75, 0.75), result.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.75, 0.75, 0.75), result.getCentroid(), TEST_EPS);
}
@Test
@@ -264,7 +264,7 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertPositiveInfinity(tree.getSize());
EuclideanTestUtils.assertPositiveInfinity(tree.getBoundarySize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
@@ -316,7 +316,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(1, tree.getSize(), TEST_EPS);
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE, Vector3D.of(0.5, 0.5, 0.5));
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, min, max);
@@ -388,7 +388,7 @@ public class RegionBSPTree3DTest {
// act
RegionBSPTree3D tree = volume.toTree();
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
// assert
Assert.assertTrue(tree.isFull());
@@ -405,7 +405,7 @@ public class RegionBSPTree3DTest {
// assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE, Vector3D.of(0, 0, 1));
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY, Vector3D.ZERO);
@@ -431,7 +431,7 @@ public class RegionBSPTree3DTest {
// assert
Assert.assertEquals(1, tree.getSize(), TEST_EPS);
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0.5, 0.5), Vector3D.of(2, 0.5, 0.5),
@@ -784,7 +784,7 @@ public class RegionBSPTree3DTest {
EuclideanTestUtils.assertPositiveInfinity(tree.getSize());
Assert.assertEquals(6, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.INSIDE,
Vector3D.of(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE),
@@ -806,7 +806,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(1.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(6.0, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
@@ -868,7 +868,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(2.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(12.0, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
@@ -893,7 +893,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(2.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(10.0, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0, 0), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0, 0), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
@@ -921,7 +921,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(2.0, tree.getSize(), eps);
Assert.assertEquals(10.0, tree.getBoundarySize(), eps);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5 + 5.4166e-8, 0, 0), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5 + 5.4166e-8, 0, 0), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
@@ -945,7 +945,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(2.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(12.0, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
@@ -972,7 +972,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(2.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(12.0, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-1, 0, 0),
@@ -1007,7 +1007,7 @@ public class RegionBSPTree3DTest {
// assert
Assert.assertEquals(1.0 / 3.0, tree.getSize(), TEST_EPS);
Assert.assertEquals(2.0 * Math.sqrt(3.0), tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 2.5, 3.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 2.5, 3.5), tree.getCentroid(), TEST_EPS);
double third = 1.0 / 3.0;
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.BOUNDARY,
@@ -1041,7 +1041,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereVolume(radius), tree.getSize(), approximationTolerance);
Assert.assertEquals(sphereSurface(radius), tree.getBoundarySize(), approximationTolerance);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 3), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 3), tree.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(tree, RegionLocation.OUTSIDE,
Vector3D.of(-0.1, 2, 3),
@@ -1154,7 +1154,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereVolume(radius), result.getSize(), tolerance);
Assert.assertEquals(sphereSurface(radius), result.getBoundarySize(), tolerance);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
@@ -1232,7 +1232,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(sphereVolume(radius), result.getSize(), tolerance);
Assert.assertEquals(sphereSurface(radius), result.getBoundarySize(), tolerance);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, result.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
@@ -1346,7 +1346,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(0.0, result.getSize(), TEST_EPS);
Assert.assertEquals(0.0, result.getBoundarySize(), TEST_EPS);
- Assert.assertNull(result.getBarycenter());
+ Assert.assertNull(result.getCentroid());
EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
@@ -1420,7 +1420,7 @@ public class RegionBSPTree3DTest {
Assert.assertEquals(0.0, result.getSize(), TEST_EPS);
Assert.assertEquals(0.0, result.getBoundarySize(), TEST_EPS);
- Assert.assertNull(result.getBarycenter());
+ Assert.assertNull(result.getCentroid());
EuclideanTestUtils.assertRegionLocation(result, RegionLocation.OUTSIDE,
Vector3D.of(-1.1, 0, 0),
@@ -1503,7 +1503,7 @@ public class RegionBSPTree3DTest {
ConvexVolume vol = result.get(0);
Assert.assertEquals(1, vol.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 2.5, 3.5), vol.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.5, 2.5, 3.5), vol.getCentroid(), TEST_EPS);
}
@Test
@@ -1524,10 +1524,10 @@ public class RegionBSPTree3DTest {
ConvexVolume large = smallFirst ? result.get(1) : result.get(0);
Assert.assertEquals(1, small.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(4.5, 5.5, 6.5), small.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(4.5, 5.5, 6.5), small.getCentroid(), TEST_EPS);
Assert.assertEquals(2, large.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0.5, 0.5), large.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0.5, 0.5), large.getCentroid(), TEST_EPS);
}
@Test
@@ -1545,11 +1545,11 @@ public class RegionBSPTree3DTest {
RegionBSPTree3D minus = split.getMinus();
Assert.assertEquals(0.5, minus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.25, 0, 0), minus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.25, 0, 0), minus.getCentroid(), TEST_EPS);
RegionBSPTree3D plus = split.getPlus();
Assert.assertEquals(0.5, plus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.25, 0, 0), plus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.25, 0, 0), plus.getCentroid(), TEST_EPS);
}
@Test
@@ -1560,15 +1560,15 @@ public class RegionBSPTree3DTest {
// act/assert
ConvexVolume rootVol = tree.getRoot().getNodeRegion();
GeometryTestUtils.assertPositiveInfinity(rootVol.getSize());
- Assert.assertNull(rootVol.getBarycenter());
+ Assert.assertNull(rootVol.getCentroid());
ConvexVolume plusVol = tree.getRoot().getPlus().getNodeRegion();
GeometryTestUtils.assertPositiveInfinity(plusVol.getSize());
- Assert.assertNull(plusVol.getBarycenter());
+ Assert.assertNull(plusVol.getCentroid());
ConvexVolume centerVol = tree.findNode(Vector3D.of(0.5, 0.5, 0.5)).getNodeRegion();
Assert.assertEquals(1, centerVol.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), centerVol.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(0.5, 0.5, 0.5), centerVol.getCentroid(), TEST_EPS);
}
// GEOMETRY-59
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
index 2c358ea..4ab80a8 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/SimpleTriangle3DTest.java
@@ -72,7 +72,7 @@ public class SimpleTriangle3DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 3), subspaceVertices.get(2), TEST_EPS);
Assert.assertEquals(0.5, tri.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(5.0 / 3.0, 7.0 / 3.0, 1), tri.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(5.0 / 3.0, 7.0 / 3.0, 1), tri.getCentroid(), TEST_EPS);
Bounds3D bounds = tri.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 1), bounds.getMin(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
index a438c51..0d72e77 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/VertexListConvexPolygon3DTest.java
@@ -59,7 +59,7 @@ public class VertexListConvexPolygon3DTest {
Assert.assertFalse(p.isInfinite());
Assert.assertEquals(0.5, p.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.0 / 3.0, 1.0 / 3.0, 1), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1.0 / 3.0, 1.0 / 3.0, 1), p.getCentroid(), TEST_EPS);
Assert.assertSame(XY_PLANE_Z1, p.getPlane());
@@ -94,9 +94,9 @@ public class VertexListConvexPolygon3DTest {
}
@Test
- public void testGetBarycenter_linearVertices() {
+ public void testGetCentroid_linearVertices() {
// this should not happen with all of the checks in place for constructing these
- // instances; this test is to ensure that the barycenter computation can still handle
+ // instances; this test is to ensure that the centroid computation can still handle
// the situation
// arrange
@@ -104,7 +104,7 @@ public class VertexListConvexPolygon3DTest {
VertexListConvexPolygon3D p = new VertexListConvexPolygon3D(XY_PLANE_Z1, vertices);
// act
- Vector3D center = p.getBarycenter();
+ Vector3D center = p.getCentroid();
// assert
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 0, 0), center, TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3DTest.java
index 2b86fc5..03ad3f3 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/EmbeddedTreeLineSubset3DTest.java
@@ -99,7 +99,7 @@ public class EmbeddedTreeLineSubset3DTest {
Assert.assertFalse(full.isFinite());
GeometryTestUtils.assertPositiveInfinity(full.getSize());
- Assert.assertNull(full.getBarycenter());
+ Assert.assertNull(full.getCentroid());
Assert.assertNull(full.getBounds());
}
@@ -113,7 +113,7 @@ public class EmbeddedTreeLineSubset3DTest {
Assert.assertTrue(empty.isFinite());
Assert.assertEquals(0, empty.getSize(), TEST_EPS);
- Assert.assertNull(empty.getBarycenter());
+ Assert.assertNull(empty.getCentroid());
Assert.assertNull(empty.getBounds());
}
@@ -128,7 +128,7 @@ public class EmbeddedTreeLineSubset3DTest {
Assert.assertFalse(half.isFinite());
GeometryTestUtils.assertPositiveInfinity(half.getSize());
- Assert.assertNull(half.getBarycenter());
+ Assert.assertNull(half.getCentroid());
Assert.assertNull(half.getBounds());
}
@@ -147,7 +147,7 @@ public class EmbeddedTreeLineSubset3DTest {
Assert.assertTrue(sub.isFinite());
Assert.assertEquals(2 * sqrt2, sub.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.5, -0.5, 1), sub.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-0.5, -0.5, 1), sub.getCentroid(), TEST_EPS);
Bounds3D bounds = sub.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-2, -2, 1), bounds.getMin(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
index 0eda275..1c9287b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Line3DTest.java
@@ -360,7 +360,7 @@ public class Line3DTest {
Assert.assertNull(span.getStartPoint());
Assert.assertNull(span.getEndPoint());
- Assert.assertNull(span.getBarycenter());
+ Assert.assertNull(span.getCentroid());
Assert.assertNull(span.getBounds());
GeometryTestUtils.assertNegativeInfinity(span.getSubspaceStart());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
index 33c104e..8d43f6f 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Ray3DTest.java
@@ -56,7 +56,7 @@ public class Ray3DTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
}
@@ -94,7 +94,7 @@ public class Ray3DTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
}
@@ -137,7 +137,7 @@ public class Ray3DTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
index 1165a0e..633f90e 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/ReverseRay3DTest.java
@@ -56,7 +56,7 @@ public class ReverseRay3DTest {
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
@@ -94,7 +94,7 @@ public class ReverseRay3DTest {
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
@@ -137,7 +137,7 @@ public class ReverseRay3DTest {
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
index 07a5600..42c15e8 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/line/Segment3DTest.java
@@ -56,7 +56,7 @@ public class Segment3DTest {
Assert.assertEquals(2, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 2), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 2), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 2), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 3, 2), bounds.getMax(), TEST_EPS);
@@ -101,7 +101,7 @@ public class Segment3DTest {
Assert.assertEquals(4, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 2), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 1, 2), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, -1, 2), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 3, 2), bounds.getMax(), TEST_EPS);
@@ -129,7 +129,7 @@ public class Segment3DTest {
Assert.assertEquals(0, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 0), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 0), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 0), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, 0), bounds.getMax(), TEST_EPS);
@@ -181,7 +181,7 @@ public class Segment3DTest {
Assert.assertEquals(3, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 0.5), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 0.5), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, -1), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 2), bounds.getMax(), TEST_EPS);
@@ -207,7 +207,7 @@ public class Segment3DTest {
Assert.assertEquals(3, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 0.5), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 0.5), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, -1), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 2), bounds.getMax(), TEST_EPS);
@@ -233,7 +233,7 @@ public class Segment3DTest {
Assert.assertEquals(0, seg.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 1), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 1), seg.getCentroid(), TEST_EPS);
Bounds3D bounds = seg.getBounds();
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 1), bounds.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(-1, 0, 1), bounds.getMax(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
index c460019..779fd9c 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/ParallelepipedTest.java
@@ -61,7 +61,7 @@ public class ParallelepipedTest {
// assert
Assert.assertEquals(1, p.getSize(), TEST_EPS);
Assert.assertEquals(6, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getCentroid(), TEST_EPS);
List<PlaneConvexSubset> boundaries = p.getBoundaries();
Assert.assertEquals(6, boundaries.size());
@@ -96,7 +96,7 @@ public class ParallelepipedTest {
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(4 + (4 * Math.sqrt(2.5)), p.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2 * invSqrt2, invSqrt2, 2),
- p.getBarycenter(), TEST_EPS);
+ p.getCentroid(), TEST_EPS);
assertVertices(p,
Vector3D.of(0, invSqrt2, 1.5),
@@ -128,7 +128,7 @@ public class ParallelepipedTest {
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(4 + (4 * Math.sqrt(2.5)), p.getBoundarySize(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2 * invSqrt2, invSqrt2, -2),
- p.getBarycenter(), TEST_EPS);
+ p.getCentroid(), TEST_EPS);
assertVertices(p,
Vector3D.of(0, invSqrt2, -1.5),
@@ -233,7 +233,7 @@ public class ParallelepipedTest {
// assert
Assert.assertEquals(1, p.getSize(), TEST_EPS);
Assert.assertEquals(6, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getCentroid(), TEST_EPS);
List<PlaneConvexSubset> boundaries = p.getBoundaries();
Assert.assertEquals(6, boundaries.size());
@@ -266,7 +266,7 @@ public class ParallelepipedTest {
// assert
Assert.assertEquals(6, p.getSize(), TEST_EPS);
Assert.assertEquals(22, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, -1), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(1, 2, -1), p.getCentroid(), TEST_EPS);
assertVertices(p,
Vector3D.of(0, 1.5, 0.5),
@@ -294,7 +294,7 @@ public class ParallelepipedTest {
// assert
Assert.assertEquals(0.125, p.getSize(), TEST_EPS);
Assert.assertEquals(1.5, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.ZERO, p.getCentroid(), TEST_EPS);
assertVertices(p,
Vector3D.of(-0.25, -0.25, -0.25),
@@ -319,7 +319,7 @@ public class ParallelepipedTest {
// assert
Assert.assertEquals(27, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2.5, 3.5, 4.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector3D.of(2.5, 3.5, 4.5), tree.getCentroid(), TEST_EPS);
}
private static void assertVertices(Parallelepiped p, Vector3D... vertices) {
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
index 9751927..6d810e1 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/threed/shape/SphereTest.java
@@ -56,7 +56,7 @@ public class SphereTest {
Assert.assertFalse(s.isEmpty());
Assert.assertSame(center, s.getCenter());
- Assert.assertSame(center, s.getBarycenter());
+ Assert.assertSame(center, s.getCentroid());
Assert.assertEquals(3, s.getRadius(), 0.0);
@@ -345,7 +345,7 @@ public class SphereTest {
double eps = 0.1;
Assert.assertEquals(s.getSize(), tree.getSize(), eps);
Assert.assertEquals(s.getBoundarySize(), tree.getBoundarySize(), eps);
- EuclideanTestUtils.assertCoordinatesEqual(s.getBarycenter(), tree.getBarycenter(), eps);
+ EuclideanTestUtils.assertCoordinatesEqual(s.getCentroid(), tree.getCentroid(), eps);
}
@Test
@@ -522,8 +522,7 @@ public class SphereTest {
}
}
-
- // sphere must contain barycenter
- EuclideanTestUtils.assertRegionLocation(s, RegionLocation.INSIDE, tree.getBarycenter());
+ // sphere must contain centroid
+ EuclideanTestUtils.assertRegionLocation(s, RegionLocation.INSIDE, tree.getCentroid());
}
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
index ee30794..f03d454 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/Bounds2DTest.java
@@ -54,7 +54,7 @@ public class Bounds2DTest {
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(p1, b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(p1, b.getCentroid(), TEST_EPS);
}
@Test
@@ -71,7 +71,7 @@ public class Bounds2DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0, 5), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(3, 6), b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(3, 1), b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 5.5), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 5.5), b.getCentroid(), TEST_EPS);
}
@Test
@@ -86,7 +86,7 @@ public class Bounds2DTest {
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(p1, b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(p1, b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(p1, b.getCentroid(), TEST_EPS);
}
@Test
@@ -103,7 +103,7 @@ public class Bounds2DTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 4), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(3, 6), b.getMax(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 2), b.getDiagonal(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 5), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 5), b.getCentroid(), TEST_EPS);
}
@Test
@@ -185,7 +185,7 @@ public class Bounds2DTest {
// act/assert
assertContainsStrict(b, true,
- b.getBarycenter(),
+ b.getCentroid(),
Vector2D.of(0, 4), Vector2D.of(2, 6),
Vector2D.of(1, 5),
Vector2D.of(0, 5), Vector2D.of(2, 5),
@@ -207,7 +207,7 @@ public class Bounds2DTest {
// act/assert
assertContainsWithPrecision(b, true,
- b.getBarycenter(),
+ b.getCentroid(),
Vector2D.of(1, 5), Vector2D.of(0, 4), Vector2D.of(2, 6),
Vector2D.of(0, 5), Vector2D.of(2, 5),
Vector2D.of(1, 4), Vector2D.of(1, 6),
@@ -346,7 +346,7 @@ public class Bounds2DTest {
// assert
Assert.assertEquals(4, p.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 5), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 5), p.getCentroid(), TEST_EPS);
}
@Test
@@ -468,7 +468,7 @@ public class Bounds2DTest {
// assert
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 6), b.getMin(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(5, 10), b.getMax(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(3, 8), b.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(3, 8), b.getCentroid(), TEST_EPS);
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
index e5ca116..dc68d0d 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ConvexAreaTest.java
@@ -53,7 +53,7 @@ public class ConvexAreaTest {
Assert.assertEquals(0.0, area.getBoundarySize(), TEST_EPS);
GeometryTestUtils.assertPositiveInfinity(area.getSize());
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
Assert.assertNull(area.getBounds());
}
@@ -104,7 +104,7 @@ public class ConvexAreaTest {
Assert.assertFalse(tree.isEmpty());
Assert.assertEquals(1, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), tree.getCentroid(), TEST_EPS);
}
@Test
@@ -188,11 +188,11 @@ public class ConvexAreaTest {
Assert.assertEquals(2, transformed.getSize(), TEST_EPS);
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 3), transformed.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 3), transformed.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(1, 2), Vector2D.of(2, 2), Vector2D.of(2, 4), Vector2D.of(1, 4));
- EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getCentroid());
}
@Test
@@ -216,11 +216,11 @@ public class ConvexAreaTest {
Assert.assertEquals(2, transformed.getSize(), TEST_EPS);
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, 3), transformed.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, 3), transformed.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(-1, 2), Vector2D.of(-2, 2), Vector2D.of(-2, 4), Vector2D.of(-1, 4));
- EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getCentroid());
}
@Test
@@ -244,11 +244,11 @@ public class ConvexAreaTest {
Assert.assertEquals(2, transformed.getSize(), TEST_EPS);
Assert.assertEquals(6, transformed.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, -3), transformed.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1.5, -3), transformed.getCentroid(), TEST_EPS);
EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.BOUNDARY,
Vector2D.of(-1, -2), Vector2D.of(-2, -2), Vector2D.of(-2, -4), Vector2D.of(-1, -4));
- EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getBarycenter());
+ EuclideanTestUtils.assertRegionLocation(transformed, RegionLocation.INSIDE, transformed.getCentroid());
}
@Test
@@ -459,7 +459,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(minus.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(minus.getSize());
- Assert.assertNull(minus.getBarycenter());
+ Assert.assertNull(minus.getCentroid());
List<LineConvexSubset> minusSegments = minus.getBoundaries();
Assert.assertEquals(1, minusSegments.size());
@@ -471,7 +471,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(plus.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(plus.getSize());
- Assert.assertNull(plus.getBarycenter());
+ Assert.assertNull(plus.getCentroid());
List<LineConvexSubset> plusSegments = plus.getBoundaries();
Assert.assertEquals(1, plusSegments.size());
@@ -496,7 +496,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(minus.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(minus.getSize());
- Assert.assertNull(minus.getBarycenter());
+ Assert.assertNull(minus.getCentroid());
Assert.assertEquals(2, minus.getBoundaries().size());
@@ -506,7 +506,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(plus.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(plus.getSize());
- Assert.assertNull(plus.getBarycenter());
+ Assert.assertNull(plus.getCentroid());
Assert.assertEquals(2, plus.getBoundaries().size());
}
@@ -561,7 +561,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4, minus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(1, minus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), minus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), minus.getCentroid(), TEST_EPS);
Assert.assertEquals(4, minus.getBoundaries().size());
@@ -571,7 +571,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4, plus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(1, plus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2.5, 1.5), plus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2.5, 1.5), plus.getCentroid(), TEST_EPS);
Assert.assertEquals(4, plus.getBoundaries().size());
}
@@ -594,7 +594,7 @@ public class ConvexAreaTest {
Assert.assertEquals(2 + Math.sqrt(2), minus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(0.5, minus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(4.0 / 3.0, 5.0 / 3.0), minus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(4.0 / 3.0, 5.0 / 3.0), minus.getCentroid(), TEST_EPS);
Assert.assertEquals(3, minus.getBoundaries().size());
@@ -604,7 +604,7 @@ public class ConvexAreaTest {
Assert.assertEquals(2 + Math.sqrt(2), plus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(0.5, plus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(5.0 / 3.0, 4.0 / 3.0), plus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(5.0 / 3.0, 4.0 / 3.0), plus.getCentroid(), TEST_EPS);
Assert.assertEquals(3, plus.getBoundaries().size());
}
@@ -627,7 +627,7 @@ public class ConvexAreaTest {
Assert.assertEquals(2 + Math.sqrt(2), minus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(0.5, minus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(5.0 / 3.0, 4.0 / 3.0), minus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(5.0 / 3.0, 4.0 / 3.0), minus.getCentroid(), TEST_EPS);
Assert.assertEquals(3, minus.getBoundaries().size());
@@ -637,7 +637,7 @@ public class ConvexAreaTest {
Assert.assertEquals(2 + Math.sqrt(2), plus.getBoundarySize(), TEST_EPS);
Assert.assertEquals(0.5, plus.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(4.0 / 3.0, 5.0 / 3.0), plus.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(4.0 / 3.0, 5.0 / 3.0), plus.getCentroid(), TEST_EPS);
Assert.assertEquals(3, plus.getBoundaries().size());
}
@@ -838,7 +838,7 @@ public class ConvexAreaTest {
Assert.assertEquals(0.5, area.getSize(), TEST_EPS);
Assert.assertEquals(2 + Math.sqrt(2), area.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.centroid(p0, p1, p2), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.centroid(p0, p1, p2), area.getCentroid(), TEST_EPS);
}
@Test
@@ -857,7 +857,7 @@ public class ConvexAreaTest {
Assert.assertEquals(1, area.getSize(), TEST_EPS);
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
}
@Test
@@ -877,7 +877,7 @@ public class ConvexAreaTest {
Assert.assertEquals(1, area.getSize(), TEST_EPS);
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
}
@Test
@@ -904,7 +904,7 @@ public class ConvexAreaTest {
Assert.assertEquals(1, area.getSize(), eps);
Assert.assertEquals(4, area.getBoundarySize(), eps);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), eps);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), eps);
}
@Test
@@ -924,7 +924,7 @@ public class ConvexAreaTest {
Assert.assertEquals(1, area.getSize(), TEST_EPS);
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
}
@Test
@@ -1021,7 +1021,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(area.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(area.getSize());
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(1, segments.size());
@@ -1047,7 +1047,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(area.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(area.getSize());
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(2, segments.size());
@@ -1075,7 +1075,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4 + (2 * Math.sqrt(2)), area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(2, area.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-2.0 / 3.0, -2.0 / 3.0), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-2.0 / 3.0, -2.0 / 3.0), area.getCentroid(), TEST_EPS);
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(3, segments.size());
@@ -1101,7 +1101,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(1, area.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
@@ -1133,7 +1133,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(1, area.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
@@ -1163,7 +1163,7 @@ public class ConvexAreaTest {
Assert.assertEquals(4, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(1, area.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(4, segments.size());
@@ -1193,7 +1193,7 @@ public class ConvexAreaTest {
GeometryTestUtils.assertPositiveInfinity(area.getBoundarySize());
GeometryTestUtils.assertPositiveInfinity(area.getSize());
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
List<LineConvexSubset> segments = area.getBoundaries();
Assert.assertEquals(1, segments.size());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
index fa7350a..7d25693 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/EmbeddedTreeLineSubsetTest.java
@@ -55,7 +55,7 @@ public class EmbeddedTreeLineSubsetTest {
Assert.assertTrue(sub.isFinite());
Assert.assertEquals(0, sub.getSize(), TEST_EPS);
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
}
@Test
@@ -73,7 +73,7 @@ public class EmbeddedTreeLineSubsetTest {
Assert.assertFalse(sub.isFinite());
GeometryTestUtils.assertPositiveInfinity(sub.getSize());
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
}
@Test
@@ -95,7 +95,7 @@ public class EmbeddedTreeLineSubsetTest {
Assert.assertFalse(sub.isFinite());
GeometryTestUtils.assertPositiveInfinity(sub.getSize());
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
}
@Test
@@ -172,7 +172,7 @@ public class EmbeddedTreeLineSubsetTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(4, 1), segments.get(1).getEndPoint(), TEST_EPS);
Assert.assertEquals(5, subset.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.7, 1), subset.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.7, 1), subset.getCentroid(), TEST_EPS);
}
@Test
@@ -217,7 +217,7 @@ public class EmbeddedTreeLineSubsetTest {
Assert.assertEquals(bTreeCount, bTree.count());
GeometryTestUtils.assertPositiveInfinity(subset.getSize());
- Assert.assertNull(subset.getBarycenter());
+ Assert.assertNull(subset.getCentroid());
}
@Test
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubsetTest.java
index b0bbe36..d99e73b 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSpanningSubsetTest.java
@@ -51,7 +51,7 @@ public class LineSpanningSubsetTest {
Assert.assertFalse(result.isFinite());
GeometryTestUtils.assertPositiveInfinity(result.getSize());
- Assert.assertNull(result.getBarycenter());
+ Assert.assertNull(result.getCentroid());
Assert.assertNull(result.getBounds());
Assert.assertNull(result.getStartPoint());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSubsetTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSubsetTest.java
index bc35628..94157ab 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSubsetTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/LineSubsetTest.java
@@ -308,7 +308,7 @@ public class LineSubsetTest {
}
@Override
- public Vector2D getBarycenter() {
+ public Vector2D getCentroid() {
return null;
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
index e335b4d..e7d9525 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RayTest.java
@@ -56,7 +56,7 @@ public class RayTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSubspaceEnd());
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
EuclideanTestUtils.assertCoordinatesEqual(p0.vectorTo(p1), ray.getDirection(), TEST_EPS);
@@ -99,7 +99,7 @@ public class RayTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSubspaceEnd());
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
EuclideanTestUtils.assertCoordinatesEqual(p0.vectorTo(p1), ray.getDirection(), TEST_EPS);
@@ -150,7 +150,7 @@ public class RayTest {
GeometryTestUtils.assertPositiveInfinity(ray.getSubspaceEnd());
GeometryTestUtils.assertPositiveInfinity(ray.getSize());
- Assert.assertNull(ray.getBarycenter());
+ Assert.assertNull(ray.getCentroid());
Assert.assertNull(ray.getBounds());
EuclideanTestUtils.assertCoordinatesEqual(p0.vectorTo(p1), ray.getDirection(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
index 7c7a524..4db2834 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/RegionBSPTree2DTest.java
@@ -261,7 +261,7 @@ public class RegionBSPTree2DTest {
Assert.assertEquals(7, tree.getSize(), TEST_EPS);
Assert.assertEquals(12, tree.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), tree.getCentroid(), TEST_EPS);
checkClassify(tree, RegionLocation.INSIDE,
Vector2D.of(1, 1), Vector2D.of(1.5, 1.5), Vector2D.of(2, 2));
@@ -353,7 +353,7 @@ public class RegionBSPTree2DTest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(1, area.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), area.getCentroid(), TEST_EPS);
checkClassify(area, RegionLocation.INSIDE, Vector2D.of(0.5, 0.5));
checkClassify(area, RegionLocation.BOUNDARY, Vector2D.ZERO, Vector2D.of(1, 1));
@@ -381,7 +381,7 @@ public class RegionBSPTree2DTest {
// assert
Collections.sort(result, (a, b) ->
- Vector2D.COORDINATE_ASCENDING_ORDER.compare(a.getBarycenter(), b.getBarycenter()));
+ Vector2D.COORDINATE_ASCENDING_ORDER.compare(a.getCentroid(), b.getCentroid()));
Assert.assertEquals(2, result.size());
@@ -390,7 +390,7 @@ public class RegionBSPTree2DTest {
Assert.assertFalse(firstArea.isEmpty());
Assert.assertEquals(0.5, firstArea.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.0 / 3.0, 2.0 / 3.0), firstArea.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.0 / 3.0, 2.0 / 3.0), firstArea.getCentroid(), TEST_EPS);
checkClassify(firstArea, RegionLocation.INSIDE, Vector2D.of(1.0 / 3.0, 2.0 / 3.0));
checkClassify(firstArea, RegionLocation.BOUNDARY, Vector2D.ZERO, Vector2D.of(1, 1), Vector2D.of(0.5, 0.5));
@@ -403,7 +403,7 @@ public class RegionBSPTree2DTest {
Assert.assertFalse(secondArea.isEmpty());
Assert.assertEquals(0.5, secondArea.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2.0 / 3.0, 1.0 / 3.0), secondArea.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2.0 / 3.0, 1.0 / 3.0), secondArea.getCentroid(), TEST_EPS);
checkClassify(secondArea, RegionLocation.INSIDE, Vector2D.of(2.0 / 3.0, 1.0 / 3.0));
checkClassify(secondArea, RegionLocation.BOUNDARY, Vector2D.ZERO, Vector2D.of(1, 1), Vector2D.of(0.5, 0.5));
@@ -574,7 +574,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -589,7 +589,7 @@ public class RegionBSPTree2DTest {
// act/assert
Assert.assertEquals(0, tree.getSize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -605,7 +605,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
@@ -635,7 +635,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
@@ -664,7 +664,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
@@ -711,7 +711,7 @@ public class RegionBSPTree2DTest {
// act/assert
Assert.assertEquals(1, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 0.5), tree.getCentroid(), TEST_EPS);
Assert.assertEquals(4, tree.getBoundarySize(), TEST_EPS);
@@ -741,7 +741,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
GeometryTestUtils.assertPositiveInfinity(tree.getBoundarySize());
@@ -779,7 +779,7 @@ public class RegionBSPTree2DTest {
// act/assert
Assert.assertEquals(0.5, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 1.0 / 3.0), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 1.0 / 3.0), tree.getCentroid(), TEST_EPS);
Assert.assertEquals(1.0 + Math.sqrt(2) + Math.sqrt(5), tree.getBoundarySize(), TEST_EPS);
@@ -810,7 +810,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(1.0 + Math.sqrt(2) + Math.sqrt(5), tree.getBoundarySize(), TEST_EPS);
@@ -841,7 +841,7 @@ public class RegionBSPTree2DTest {
// act/assert
Assert.assertEquals(8, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1.5, 1.5), tree.getCentroid(), TEST_EPS);
Assert.assertEquals(16, tree.getBoundarySize(), TEST_EPS);
@@ -882,7 +882,7 @@ public class RegionBSPTree2DTest {
// act/assert
GeometryTestUtils.assertPositiveInfinity(tree.getSize());
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(16, tree.getBoundarySize(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
index 431a393..4c19a00 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/ReverseRayTest.java
@@ -56,7 +56,7 @@ public class ReverseRayTest {
Assert.assertEquals(1, revRay.getSubspaceEnd(), TEST_EPS);
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
@@ -97,7 +97,7 @@ public class ReverseRayTest {
Assert.assertEquals(3, revRay.getSubspaceEnd(), TEST_EPS);
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
@@ -146,7 +146,7 @@ public class ReverseRayTest {
Assert.assertEquals(-2, revRay.getSubspaceEnd(), TEST_EPS);
GeometryTestUtils.assertPositiveInfinity(revRay.getSize());
- Assert.assertNull(revRay.getBarycenter());
+ Assert.assertNull(revRay.getCentroid());
Assert.assertNull(revRay.getBounds());
}
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
index 7c5af10..08a2440 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/SegmentTest.java
@@ -51,7 +51,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(p1, seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(p2, seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 2), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2, 2), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(1, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(3, seg.getSubspaceEnd(), TEST_EPS);
@@ -94,7 +94,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 3), seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2.5), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2.5), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(2, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(3, seg.getSubspaceEnd(), TEST_EPS);
@@ -120,7 +120,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(2, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(2, seg.getSubspaceEnd(), TEST_EPS);
@@ -170,7 +170,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, -1), seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 2), seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 0.5), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 0.5), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(-1, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(2, seg.getSubspaceEnd(), TEST_EPS);
@@ -194,7 +194,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, -1), seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 2), seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 0.5), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 0.5), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(-1, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(2, seg.getSubspaceEnd(), TEST_EPS);
@@ -218,7 +218,7 @@ public class SegmentTest {
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 1), seg.getStartPoint(), TEST_EPS);
EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 1), seg.getEndPoint(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 1), seg.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-1, 1), seg.getCentroid(), TEST_EPS);
Assert.assertEquals(1, seg.getSubspaceStart(), TEST_EPS);
Assert.assertEquals(1, seg.getSubspaceEnd(), TEST_EPS);
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
index 47d2fcd..0193002 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/CircleTest.java
@@ -63,7 +63,7 @@ public class CircleTest {
Assert.assertFalse(c.isEmpty());
Assert.assertSame(center, c.getCenter());
- Assert.assertSame(center, c.getBarycenter());
+ Assert.assertSame(center, c.getCentroid());
Assert.assertEquals(3, c.getRadius(), 0.0);
@@ -373,7 +373,7 @@ public class CircleTest {
double eps = 5e-3;
Assert.assertEquals(c.getSize(), tree.getSize(), eps);
Assert.assertEquals(c.getBoundarySize(), tree.getBoundarySize(), eps);
- EuclideanTestUtils.assertCoordinatesEqual(c.getBarycenter(), tree.getBarycenter(), eps);
+ EuclideanTestUtils.assertCoordinatesEqual(c.getCentroid(), tree.getCentroid(), eps);
}
@Test
@@ -538,8 +538,8 @@ public class CircleTest {
Assert.assertTrue("Expected vertex to be contained in circle: " + vertex, c.contains(vertex));
}
- // circle must contain barycenter
- EuclideanTestUtils.assertRegionLocation(c, RegionLocation.INSIDE, tree.getBarycenter());
+ // circle must contain centroid
+ EuclideanTestUtils.assertRegionLocation(c, RegionLocation.INSIDE, tree.getCentroid());
// area must be less than the circle
Assert.assertTrue("Expected approximation area to be less than circle", tree.getSize() < c.getSize());
diff --git a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
index 0a3f508..3837edf 100644
--- a/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
+++ b/commons-geometry-euclidean/src/test/java/org/apache/commons/geometry/euclidean/twod/shape/ParallelogramTest.java
@@ -46,7 +46,7 @@ public class ParallelogramTest {
// assert
Assert.assertEquals(1, box.getSize(), TEST_EPS);
Assert.assertEquals(4, box.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, box.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, box.getCentroid(), TEST_EPS);
List<Vector2D> vertices = box.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -72,7 +72,7 @@ public class ParallelogramTest {
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(4 * Math.sqrt(2.5), p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2 * invSqrt2, invSqrt2), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(2 * invSqrt2, invSqrt2), p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -98,7 +98,7 @@ public class ParallelogramTest {
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(4 * Math.sqrt(2.5), p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-2 * invSqrt2, invSqrt2), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(-2 * invSqrt2, invSqrt2), p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -185,7 +185,7 @@ public class ParallelogramTest {
// assert
Assert.assertEquals(1, p.getSize(), TEST_EPS);
Assert.assertEquals(4, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.ZERO, p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -210,7 +210,7 @@ public class ParallelogramTest {
// assert
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(6, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -235,7 +235,7 @@ public class ParallelogramTest {
// assert
Assert.assertEquals(2, p.getSize(), TEST_EPS);
Assert.assertEquals(6, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -260,7 +260,7 @@ public class ParallelogramTest {
// assert
Assert.assertEquals(4, p.getSize(), TEST_EPS);
Assert.assertEquals(8, p.getBoundarySize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(1, 2), p.getCentroid(), TEST_EPS);
List<Vector2D> vertices = p.getVertices();
Assert.assertEquals(4, vertices.size());
@@ -283,7 +283,7 @@ public class ParallelogramTest {
Assert.assertFalse(tree.isEmpty());
Assert.assertEquals(4, tree.getSize(), TEST_EPS);
- EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 2), tree.getBarycenter(), TEST_EPS);
+ EuclideanTestUtils.assertCoordinatesEqual(Vector2D.of(0.5, 2), tree.getCentroid(), TEST_EPS);
}
private static void assertSegment(LineConvexSubset segment, Vector2D start, Vector2D end) {
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
index 43c110f..e00fb56 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/AngularInterval.java
@@ -108,7 +108,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* the full space.
* @return the midpoint of the interval or null if the interval represents
* the full space
- * @see #getBarycenter()
+ * @see #getCentroid()
*/
public Point1S getMidPoint() {
return midpoint;
@@ -152,7 +152,7 @@ public class AngularInterval implements HyperplaneBoundedRegion<Point1S> {
* @see #getMidPoint()
*/
@Override
- public Point1S getBarycenter() {
+ public Point1S getCentroid() {
return getMidPoint();
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
index 534109a..f771e01 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/CutAngle.java
@@ -306,7 +306,7 @@ public final class CutAngle extends AbstractHyperplane<Point1S> {
* <p>This method returns the point for the underlying hyperplane.</p>
*/
@Override
- public Point1S getBarycenter() {
+ public Point1S getCentroid() {
return hyperplane.getPoint();
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
index 2c68838..bfca36d 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1S.java
@@ -343,7 +343,7 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
}
double size = 0;
- Vector2D scaledBarycenterSum = Vector2D.ZERO;
+ Vector2D scaledCentroidSum = Vector2D.ZERO;
double intervalSize;
@@ -351,16 +351,16 @@ public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S, RegionBSPTre
intervalSize = interval.getSize();
size += intervalSize;
- scaledBarycenterSum = scaledBarycenterSum.add(interval.getBarycenter().getVector().withNorm(intervalSize));
+ scaledCentroidSum = scaledCentroidSum.add(interval.getCentroid().getVector().withNorm(intervalSize));
}
final DoublePrecisionContext precision = ((CutAngle) getRoot().getCutHyperplane()).getPrecision();
- final Point1S barycenter = scaledBarycenterSum.eq(Vector2D.ZERO, precision) ?
+ final Point1S centroid = scaledCentroidSum.eq(Vector2D.ZERO, precision) ?
null :
- Point1S.from(scaledBarycenterSum);
+ Point1S.from(scaledCentroidSum);
- return new RegionSizeProperties<>(size, barycenter);
+ return new RegionSizeProperties<>(size, centroid);
}
/** {@inheritDoc} */
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
index 19d88bb..a144a66 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/ConvexArea2S.java
@@ -127,39 +127,39 @@ public final class ConvexArea2S extends AbstractConvexHyperplaneBoundedRegion<Po
/** {@inheritDoc} */
@Override
- public Point2S getBarycenter() {
- final Vector3D weighted = getWeightedBarycenterVector();
+ public Point2S getCentroid() {
+ final Vector3D weighted = getWeightedCentroidVector();
return weighted == null ? null : Point2S.from(weighted);
}
- /** Returns the weighted vector for the barycenter. This vector is computed by scaling the
+ /** Returns the weighted vector for the centroid. This vector is computed by scaling the
* pole vector of the great circle of each boundary arc by the size of the arc and summing
- * the results. By combining the weighted barycenter vectors of multiple areas, a single
- * barycenter can be computed for the whole group.
- * @return weighted barycenter vector.
+ * the results. By combining the weighted centroid vectors of multiple areas, a single
+ * centroid can be computed for the whole group.
+ * @return weighted centroid vector.
* @see <a href="https://archive.org/details/centroidinertiat00broc">
* <em>The Centroid and Inertia Tensor for a Spherical Triangle</em> - John E. Brock</a>
*/
- Vector3D getWeightedBarycenterVector() {
+ Vector3D getWeightedCentroidVector() {
final List<GreatArc> arcs = getBoundaries();
switch (arcs.size()) {
case 0:
- // full space; no barycenter
+ // full space; no centroid
return null;
case 1:
- // hemisphere; barycenter is the pole of the hemisphere
+ // hemisphere; centroid is the pole of the hemisphere
final GreatArc singleArc = arcs.get(0);
return singleArc.getCircle().getPole().withNorm(singleArc.getSize());
default:
// 2 or more sides; use an extension of the approach outlined here:
// https://archive.org/details/centroidinertiat00broc
- // In short, the barycenter is the sum of the pole vectors of each side
+ // In short, the centroid is the sum of the pole vectors of each side
// multiplied by their arc lengths.
- Vector3D barycenter = Vector3D.ZERO;
+ Vector3D centroid = Vector3D.ZERO;
for (final GreatArc arc : getBoundaries()) {
- barycenter = barycenter.add(arc.getCircle().getPole().withNorm(arc.getSize()));
+ centroid = centroid.add(arc.getCircle().getPole().withNorm(arc.getSize()));
}
- return barycenter;
+ return centroid;
}
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubset.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubset.java
index 87ba6c0..1c5800f 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubset.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubset.java
@@ -88,10 +88,10 @@ public abstract class GreatCircleSubset implements HyperplaneSubset<Point2S>, Re
/** {@inheritDoc} */
@Override
- public Point2S getBarycenter() {
- final Point1S subspaceBarycenter = getSubspaceRegion().getBarycenter();
- if (subspaceBarycenter != null) {
- return getCircle().toSpace(subspaceBarycenter);
+ public Point2S getCentroid() {
+ final Point1S subspaceCentroid = getSubspaceRegion().getCentroid();
+ if (subspaceCentroid != null) {
+ return getCircle().toSpace(subspaceCentroid);
}
return null;
}
diff --git a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
index 1c5e38e..ba9210c 100644
--- a/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
+++ b/commons-geometry-spherical/src/main/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2S.java
@@ -171,18 +171,18 @@ public class RegionBSPTree2S extends AbstractRegionBSPTree<Point2S, RegionBSPTre
final DoublePrecisionContext precision = ((GreatArc) getRoot().getCut()).getPrecision();
double sizeSum = 0;
- Vector3D barycenterVector = Vector3D.ZERO;
+ Vector3D centroidVector = Vector3D.ZERO;
for (final ConvexArea2S area : areas) {
sizeSum += area.getSize();
- barycenterVector = barycenterVector.add(area.getWeightedBarycenterVector());
+ centroidVector = centroidVector.add(area.getWeightedCentroidVector());
}
- final Point2S barycenter = barycenterVector.eq(Vector3D.ZERO, precision) ?
+ final Point2S centroid = centroidVector.eq(Vector3D.ZERO, precision) ?
null :
- Point2S.from(barycenterVector);
+ Point2S.from(centroidVector);
- return new RegionSizeProperties<>(sizeSum, barycenter);
+ return new RegionSizeProperties<>(sizeSum, centroid);
}
/** {@inheritDoc} */
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/DocumentationExamplesTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/DocumentationExamplesTest.java
index be7bb39..7a576c9 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/DocumentationExamplesTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/DocumentationExamplesTest.java
@@ -117,8 +117,8 @@ public class DocumentationExamplesTest {
// convert to a region
RegionBSPTree2S tree = path.toTree();
- // split in two through the barycenter
- GreatCircle splitter = GreatCircles.fromPoints(tree.getBarycenter(), Point2S.PLUS_K, precision);
+ // split in two through the centroid
+ GreatCircle splitter = GreatCircles.fromPoints(tree.getCentroid(), Point2S.PLUS_K, precision);
Split<RegionBSPTree2S> split = tree.split(splitter);
// compute some properties for the minus side
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
index 3ab0f11..8f8feb5 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/AngularIntervalTest.java
@@ -848,7 +848,7 @@ public class AngularIntervalTest {
Assert.assertNull(interval.getMaxBoundary());
Assert.assertEquals(PlaneAngleRadians.TWO_PI, interval.getMax(), TEST_EPS);
- Assert.assertNull(interval.getBarycenter());
+ Assert.assertNull(interval.getCentroid());
Assert.assertNull(interval.getMidPoint());
Assert.assertEquals(PlaneAngleRadians.TWO_PI, interval.getSize(), TEST_EPS);
@@ -874,7 +874,7 @@ public class AngularIntervalTest {
Assert.assertEquals(max, interval.getMax(), TEST_EPS);
Assert.assertEquals(0.5 * (max + min), interval.getMidPoint().getAzimuth(), TEST_EPS);
- Assert.assertSame(interval.getMidPoint(), interval.getBarycenter());
+ Assert.assertSame(interval.getMidPoint(), interval.getCentroid());
Assert.assertEquals(0, interval.getBoundarySize(), TEST_EPS);
Assert.assertEquals(max - min, interval.getSize(), TEST_EPS);
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
index 66708f9..901fc87 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/CutAngleTest.java
@@ -402,7 +402,7 @@ public class CutAngleTest {
Assert.assertFalse(sub.isInfinite());
Assert.assertTrue(sub.isFinite());
Assert.assertEquals(0.0, sub.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEqual(Point1S.of(1), sub.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEqual(Point1S.of(1), sub.getCentroid(), TEST_EPS);
List<? extends HyperplaneConvexSubset<Point1S>> list = sub.toConvex();
Assert.assertEquals(1, list.size());
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
index 8a482ba..273c96c 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/oned/RegionBSPTree1STest.java
@@ -51,7 +51,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(0, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -65,7 +65,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(PlaneAngleRadians.TWO_PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -79,7 +79,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(0, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -93,7 +93,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(PlaneAngleRadians.TWO_PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -107,7 +107,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(0, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -150,7 +150,7 @@ public class RegionBSPTree1STest {
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.normalizeBetweenZeroAndTwoPi(theta + (0.25 * PlaneAngleRadians.PI)),
- tree.getBarycenter().getNormalizedAzimuth(), TEST_EPS);
+ tree.getCentroid().getNormalizedAzimuth(), TEST_EPS);
}
}
@@ -676,7 +676,7 @@ public class RegionBSPTree1STest {
// act/assert
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertEquals(0.25 * PlaneAngleRadians.PI, tree.getBarycenter().getAzimuth(), TEST_EPS);
+ Assert.assertEquals(0.25 * PlaneAngleRadians.PI, tree.getCentroid().getAzimuth(), TEST_EPS);
}
@Test
@@ -688,7 +688,7 @@ public class RegionBSPTree1STest {
// act/assert
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertEquals(1.25 * PlaneAngleRadians.PI, tree.getBarycenter().getAzimuth(), TEST_EPS);
+ Assert.assertEquals(1.25 * PlaneAngleRadians.PI, tree.getCentroid().getAzimuth(), TEST_EPS);
}
@Test
@@ -701,7 +701,7 @@ public class RegionBSPTree1STest {
// act/assert
Assert.assertEquals(0.2, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertEquals(0.15, tree.getBarycenter().getAzimuth(), TEST_EPS);
+ Assert.assertEquals(0.15, tree.getCentroid().getAzimuth(), TEST_EPS);
}
@Test
@@ -715,9 +715,9 @@ public class RegionBSPTree1STest {
Assert.assertEquals(0.6, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Vector2D barycenterVector = Point1S.of(0.1).getVector().withNorm(0.2)
+ Vector2D centroidVector = Point1S.of(0.1).getVector().withNorm(0.2)
.add(Point1S.of(0.5).getVector().withNorm(0.4));
- Assert.assertEquals(Point1S.from(barycenterVector).getAzimuth(), tree.getBarycenter().getAzimuth(), TEST_EPS);
+ Assert.assertEquals(Point1S.from(centroidVector).getAzimuth(), tree.getCentroid().getAzimuth(), TEST_EPS);
}
@Test
@@ -730,7 +730,7 @@ public class RegionBSPTree1STest {
// act/assert
Assert.assertEquals(4, tree.getSize(), TEST_EPS);
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter()); // no unique barycenter exists
+ Assert.assertNull(tree.getCentroid()); // no unique centroid exists
}
@Test
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
index 444ff67..ed71e15 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/ConvexArea2STest.java
@@ -52,7 +52,7 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(0, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(4 * PlaneAngleRadians.PI, area.getSize(), TEST_EPS);
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
Assert.assertEquals(0, area.getBoundaries().size());
@@ -72,7 +72,7 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(0, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(4 * PlaneAngleRadians.PI, area.getSize(), TEST_EPS);
- Assert.assertNull(area.getBarycenter());
+ Assert.assertNull(area.getCentroid());
Assert.assertEquals(0, area.getBoundaries().size());
@@ -95,8 +95,8 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(2 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(2 * PlaneAngleRadians.PI, area.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.PLUS_J, area.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(area);
+ SphericalTestUtils.assertPointsEq(Point2S.PLUS_J, area.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(area);
Assert.assertEquals(1, area.getBoundaries().size());
GreatArc arc = area.getBoundaries().get(0);
@@ -127,8 +127,9 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(2 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.of(0.125 * PlaneAngleRadians.PI, PlaneAngleRadians.PI_OVER_TWO), area.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(area);
+ SphericalTestUtils.assertPointsEq(Point2S.of(0.125 * PlaneAngleRadians.PI, PlaneAngleRadians.PI_OVER_TWO),
+ area.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(2, arcs.size());
@@ -162,8 +163,8 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(2 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI, area.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.of(0, 0.25 * PlaneAngleRadians.PI), area.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(area);
+ SphericalTestUtils.assertPointsEq(Point2S.of(0, 0.25 * PlaneAngleRadians.PI), area.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(2, arcs.size());
@@ -201,10 +202,10 @@ public class ConvexArea2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -252,10 +253,10 @@ public class ConvexArea2STest {
double size = PlaneAngleRadians.TWO_PI - a.angle(b) - b.angle(c) - c.angle(a);
Assert.assertEquals(size, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(p1, p2, p3);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(p1, p2, p3);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -299,7 +300,7 @@ public class ConvexArea2STest {
double size = 2 * PlaneAngleRadians.PI - c1.angle(c2) - c2.angle(c3) - c3.angle(c4) - c4.angle(c1);
Assert.assertEquals(size, area.getSize(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(4, arcs.size());
@@ -346,10 +347,10 @@ public class ConvexArea2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.MINUS_I, Point2S.MINUS_K, Point2S.MINUS_J);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.MINUS_I, Point2S.MINUS_K, Point2S.MINUS_J);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -391,8 +392,8 @@ public class ConvexArea2STest {
Assert.assertFalse(area.isEmpty());
Assert.assertEquals(2 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI, area.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.of(0, 0.25 * PlaneAngleRadians.PI), area.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(area);
+ SphericalTestUtils.assertPointsEq(Point2S.of(0, 0.25 * PlaneAngleRadians.PI), area.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(2, arcs.size());
@@ -428,10 +429,10 @@ public class ConvexArea2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -465,8 +466,8 @@ public class ConvexArea2STest {
// assert
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
List<Point2S> vertices = area.getBoundaryPath().getVertices();
Assert.assertEquals(4, vertices.size());
@@ -504,10 +505,10 @@ public class ConvexArea2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.PLUS_I, Point2S.PLUS_J, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -611,10 +612,10 @@ public class ConvexArea2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, area.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, area.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.MINUS_J, Point2S.PLUS_I, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, area.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.MINUS_J, Point2S.PLUS_I, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, area.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(area);
+ checkCentroidConsistency(area);
List<GreatArc> arcs = sortArcs(area.getBoundaries());
Assert.assertEquals(3, arcs.size());
@@ -755,7 +756,7 @@ public class ConvexArea2STest {
Assert.assertFalse(tree.isEmpty());
Assert.assertEquals(area.getSize(), tree.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(area.getBarycenter(), tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(area.getCentroid(), tree.getCentroid(), TEST_EPS);
}
private static List<GreatArc> sortArcs(List<GreatArc> arcs) {
@@ -767,8 +768,8 @@ public class ConvexArea2STest {
return result;
}
- private static Point2S triangleBarycenter(Point2S p1, Point2S p2, Point2S p3) {
- // compute the barycenter as the sum of the cross product of each point pair weighted by
+ private static Point2S triangleCentroid(Point2S p1, Point2S p2, Point2S p3) {
+ // compute the centroid as the sum of the cross product of each point pair weighted by
// the angle between the points
Vector3D v1 = p1.getVector();
Vector3D v2 = p2.getVector();
@@ -801,16 +802,16 @@ public class ConvexArea2STest {
}
}
- private static void checkBarycenterConsistency(ConvexArea2S area) {
- Point2S barycenter = area.getBarycenter();
+ private static void checkCentroidConsistency(ConvexArea2S area) {
+ Point2S centroid = area.getCentroid();
double size = area.getSize();
- SphericalTestUtils.checkClassify(area, RegionLocation.INSIDE, barycenter);
+ SphericalTestUtils.checkClassify(area, RegionLocation.INSIDE, centroid);
- GreatCircle circle = GreatCircles.fromPole(barycenter.getVector(), TEST_PRECISION);
+ GreatCircle circle = GreatCircles.fromPole(centroid.getVector(), TEST_PRECISION);
for (double az = 0; az <= PlaneAngleRadians.TWO_PI; az += 0.2) {
Point2S pt = circle.toSpace(Point1S.of(az));
- GreatCircle splitter = GreatCircles.fromPoints(barycenter, pt, TEST_PRECISION);
+ GreatCircle splitter = GreatCircles.fromPoints(centroid, pt, TEST_PRECISION);
Split<ConvexArea2S> split = area.split(splitter);
@@ -822,11 +823,11 @@ public class ConvexArea2STest {
ConvexArea2S plus = split.getPlus();
double plusSize = plus.getSize();
- Point2S computedBarycenter = Point2S.from(minus.getWeightedBarycenterVector()
- .add(plus.getWeightedBarycenterVector()));
+ Point2S computedCentroid = Point2S.from(minus.getWeightedCentroidVector()
+ .add(plus.getWeightedCentroidVector()));
Assert.assertEquals(size, minusSize + plusSize, TEST_EPS);
- SphericalTestUtils.assertPointsEq(barycenter, computedBarycenter, TEST_EPS);
+ SphericalTestUtils.assertPointsEq(centroid, computedCentroid, TEST_EPS);
}
}
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
index abbf849..cb213b8 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/EmbeddedTreeSubGreatCircleTest.java
@@ -55,7 +55,7 @@ public class EmbeddedTreeSubGreatCircleTest {
Assert.assertFalse(sub.isInfinite());
Assert.assertEquals(0, sub.getSize(), TEST_EPS);
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
for (double az = 0; az <= PlaneAngleRadians.TWO_PI; az += 0.5) {
for (double p = 0; p <= PlaneAngleRadians.PI; p += 0.5) {
@@ -76,7 +76,7 @@ public class EmbeddedTreeSubGreatCircleTest {
Assert.assertFalse(sub.isInfinite());
Assert.assertEquals(PlaneAngleRadians.TWO_PI, sub.getSize(), TEST_EPS);
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
for (double az = 0; az < PlaneAngleRadians.TWO_PI; az += 0.1) {
checkClassify(sub, RegionLocation.INSIDE, Point2S.of(az, PlaneAngleRadians.PI_OVER_TWO));
@@ -99,7 +99,7 @@ public class EmbeddedTreeSubGreatCircleTest {
Assert.assertFalse(sub.isInfinite());
Assert.assertEquals(0, sub.getSize(), TEST_EPS);
- Assert.assertNull(sub.getBarycenter());
+ Assert.assertNull(sub.getCentroid());
for (double az = 0; az <= PlaneAngleRadians.TWO_PI; az += 0.5) {
for (double p = 0; p <= PlaneAngleRadians.PI; p += 0.5) {
@@ -124,7 +124,7 @@ public class EmbeddedTreeSubGreatCircleTest {
Assert.assertEquals(1, sub.getSize(), TEST_EPS);
SphericalTestUtils.assertPointsEq(Point2S.of(1.5, PlaneAngleRadians.PI_OVER_TWO),
- sub.getBarycenter(), TEST_EPS);
+ sub.getCentroid(), TEST_EPS);
checkClassify(sub, RegionLocation.INSIDE, Point2S.of(1.5, PlaneAngleRadians.PI_OVER_TWO));
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
index b59209c..e21186d 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcPathTest.java
@@ -335,7 +335,7 @@ public class GreatArcPathTest {
Assert.assertFalse(tree.isEmpty());
Assert.assertEquals(PlaneAngleRadians.TWO_PI, tree.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.getCentroid(), TEST_EPS);
SphericalTestUtils.checkClassify(tree, RegionLocation.INSIDE, Point2S.PLUS_K);
SphericalTestUtils.checkClassify(tree, RegionLocation.OUTSIDE, Point2S.MINUS_K);
@@ -363,7 +363,7 @@ public class GreatArcPathTest {
.add(Point2S.PLUS_J.getVector())
.add(Point2S.PLUS_K.getVector()));
- SphericalTestUtils.assertPointsEq(bc, tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(bc, tree.getCentroid(), TEST_EPS);
SphericalTestUtils.checkClassify(tree, RegionLocation.INSIDE, Point2S.of(0.5, 0.5));
SphericalTestUtils.checkClassify(tree, RegionLocation.OUTSIDE,
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
index 3a405d2..70bfa52 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatArcTest.java
@@ -55,7 +55,7 @@ public class GreatArcTest {
Assert.assertNull(arc.getEndPoint());
Assert.assertEquals(PlaneAngleRadians.TWO_PI, arc.getSize(), TEST_EPS);
- Assert.assertNull(arc.getBarycenter());
+ Assert.assertNull(arc.getCentroid());
for (double az = 0; az < PlaneAngleRadians.TWO_PI; az += 0.1) {
checkClassify(arc, RegionLocation.INSIDE, Point2S.of(az, PlaneAngleRadians.PI_OVER_TWO));
@@ -373,7 +373,7 @@ public class GreatArcTest {
checkClassify(arc, RegionLocation.OUTSIDE, mid.antipodal());
Assert.assertEquals(start.distance(end), arc.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(mid, arc.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(mid, arc.getCentroid(), TEST_EPS);
}
private static void checkGreatCircle(GreatCircle circle, Vector3D pole, Vector3D x) {
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubsetTest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubsetTest.java
index 9bad029..43de49f 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubsetTest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/GreatCircleSubsetTest.java
@@ -257,7 +257,7 @@ public class GreatCircleSubsetTest {
}
@Override
- public Point2S getBarycenter() {
+ public Point2S getCentroid() {
return null;
}
diff --git a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
index 3b41a70..98b6872 100644
--- a/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
+++ b/commons-geometry-spherical/src/test/java/org/apache/commons/geometry/spherical/twod/RegionBSPTree2STest.java
@@ -39,9 +39,9 @@ public class RegionBSPTree2STest {
private static final double TEST_EPS = 1e-10;
- // alternative epsilon value for checking the barycenters of complex
+ // alternative epsilon value for checking the centroids of complex
// or very small regions
- private static final double BARYCENTER_EPS = 1e-5;
+ private static final double CENTROID_EPS = 1e-5;
private static final DoublePrecisionContext TEST_PRECISION =
new EpsilonDoublePrecisionContext(TEST_EPS);
@@ -360,7 +360,7 @@ public class RegionBSPTree2STest {
SphericalTestUtils.assertPointsEq(Point2S.MINUS_I,
tree.project(Point2S.of(PlaneAngleRadians.PI + 0.5, PlaneAngleRadians.PI_OVER_TWO)), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.project(tree.getBarycenter()), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.project(tree.getCentroid()), TEST_EPS);
}
@Test
@@ -377,7 +377,7 @@ public class RegionBSPTree2STest {
// act/assert
Assert.assertEquals(4 * PlaneAngleRadians.PI, tree.getSize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -392,7 +392,7 @@ public class RegionBSPTree2STest {
// act/assert
Assert.assertEquals(0, tree.getSize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
Assert.assertEquals(0, tree.getBoundarySize(), TEST_EPS);
@@ -409,9 +409,9 @@ public class RegionBSPTree2STest {
// act/assert
Assert.assertEquals(PlaneAngleRadians.TWO_PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.TWO_PI, tree.getBoundarySize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, tree.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ checkCentroidConsistency(tree);
List<GreatArc> arcs = tree.getBoundaries();
Assert.assertEquals(1, arcs.size());
@@ -443,7 +443,7 @@ public class RegionBSPTree2STest {
// assert
Assert.assertEquals(2 * PlaneAngleRadians.PI, tree.getSize(), TEST_EPS);
Assert.assertEquals(4 * PlaneAngleRadians.PI, tree.getBoundarySize(), TEST_EPS);
- Assert.assertNull(tree.getBarycenter());
+ Assert.assertNull(tree.getCentroid());
List<GreatArcPath> paths = tree.getBoundaryPaths();
Assert.assertEquals(2, paths.size());
@@ -475,9 +475,9 @@ public class RegionBSPTree2STest {
Point2S center = Point2S.from(Point2S.MINUS_K.getVector()
.add(Point2S.PLUS_I.getVector())
.add(Point2S.MINUS_J.getVector()));
- SphericalTestUtils.assertPointsEq(center, tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(center, tree.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ checkCentroidConsistency(tree);
List<GreatArcPath> paths = tree.getBoundaryPaths();
Assert.assertEquals(1, paths.size());
@@ -509,9 +509,9 @@ public class RegionBSPTree2STest {
Point2S center = Point2S.from(Point2S.MINUS_K.getVector()
.add(Point2S.PLUS_I.getVector())
.add(Point2S.MINUS_J.getVector()));
- SphericalTestUtils.assertPointsEq(center.antipodal(), tree.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(center.antipodal(), tree.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ checkCentroidConsistency(tree);
List<GreatArcPath> paths = tree.getBoundaryPaths();
Assert.assertEquals(1, paths.size());
@@ -552,8 +552,8 @@ public class RegionBSPTree2STest {
double boundarySize = 4 * (outerSideLength + innerSideLength);
Assert.assertEquals(boundarySize, tree.getBoundarySize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(center, tree.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ SphericalTestUtils.assertPointsEq(center, tree.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(tree);
SphericalTestUtils.checkClassify(tree, RegionLocation.OUTSIDE, center);
}
@@ -594,8 +594,8 @@ public class RegionBSPTree2STest {
double boundarySize = 4 * (outerSideLength + midSideLength + innerSideLength);
Assert.assertEquals(boundarySize, tree.getBoundarySize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(center.antipodal(), tree.getBarycenter(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ SphericalTestUtils.assertPointsEq(center.antipodal(), tree.getCentroid(), TEST_EPS);
+ checkCentroidConsistency(tree);
SphericalTestUtils.checkClassify(tree, RegionLocation.OUTSIDE, center);
}
@@ -620,8 +620,8 @@ public class RegionBSPTree2STest {
double boundarySize = 8 * sphericalHypot(radius, radius);
Assert.assertEquals(boundarySize, tree.getBoundarySize(), TEST_EPS);
- // should be null since no unique barycenter exists
- Assert.assertNull(tree.getBarycenter());
+ // should be null since no unique centroid exists
+ Assert.assertNull(tree.getCentroid());
}
@Test
@@ -716,10 +716,10 @@ public class RegionBSPTree2STest {
Assert.assertEquals(1.5 * PlaneAngleRadians.PI, tree.getBoundarySize(), TEST_EPS);
Assert.assertEquals(PlaneAngleRadians.PI_OVER_TWO, tree.getSize(), TEST_EPS);
- Point2S expectedBarycenter = triangleBarycenter(Point2S.MINUS_J, Point2S.PLUS_I, Point2S.PLUS_K);
- SphericalTestUtils.assertPointsEq(expectedBarycenter, tree.getBarycenter(), TEST_EPS);
+ Point2S expectedCentroid = triangleCentroid(Point2S.MINUS_J, Point2S.PLUS_I, Point2S.PLUS_K);
+ SphericalTestUtils.assertPointsEq(expectedCentroid, tree.getCentroid(), TEST_EPS);
- checkBarycenterConsistency(tree);
+ checkCentroidConsistency(tree);
SphericalTestUtils.checkClassify(tree, RegionLocation.INSIDE,
Point2S.of(-0.25 * PlaneAngleRadians.PI, 0.25 * PlaneAngleRadians.PI));
@@ -745,16 +745,16 @@ public class RegionBSPTree2STest {
// act/assert
ConvexArea2S rootRegion = root.getNodeRegion();
Assert.assertEquals(4 * PlaneAngleRadians.PI, rootRegion.getSize(), TEST_EPS);
- Assert.assertNull(rootRegion.getBarycenter());
+ Assert.assertNull(rootRegion.getCentroid());
ConvexArea2S minusRegion = minus.getNodeRegion();
Assert.assertEquals(2 * PlaneAngleRadians.PI, minusRegion.getSize(), TEST_EPS);
- SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, minusRegion.getBarycenter(), TEST_EPS);
+ SphericalTestUtils.assertPointsEq(Point2S.PLUS_K, minusRegion.getCentroid(), TEST_EPS);
ConvexArea2S minusPlusRegion = minusPlus.getNodeRegion();
Assert.assertEquals(PlaneAngleRadians.PI, minusPlusRegion.getSize(), TEST_EPS);
SphericalTestUtils.assertPointsEq(Point2S.of(1.5 * PlaneAngleRadians.PI, 0.25 * PlaneAngleRadians.PI),
- minusPlusRegion.getBarycenter(), TEST_EPS);
+ minusPlusRegion.getCentroid(), TEST_EPS);
}
@Test
@@ -784,24 +784,24 @@ public class RegionBSPTree2STest {
Assert.assertEquals(0.013964220234478741, france.getSize(), TEST_EPS);
SphericalTestUtils.assertPointsEq(Point2S.of(0.04368552749392928, 0.7590839905197961),
- france.getBarycenter(), BARYCENTER_EPS);
+ france.getCentroid(), CENTROID_EPS);
- checkBarycenterConsistency(france);
+ checkCentroidConsistency(france);
}
@Test
- public void testCircleToPolygonBarycenter() {
+ public void testCircleToPolygonCentroid() {
double radius = 0.0001;
Point2S center = Point2S.of(1.0, 1.0);
int numPts = 200;
// counterclockwise
RegionBSPTree2S ccw = circleToPolygon(center, radius, numPts, false);
- SphericalTestUtils.assertPointsEq(center, ccw.getBarycenter(), BARYCENTER_EPS);
+ SphericalTestUtils.assertPointsEq(center, ccw.getCentroid(), CENTROID_EPS);
- // clockwise; barycenter should just be antipodal for the circle center
+ // clockwise; centroid should just be antipodal for the circle center
RegionBSPTree2S cw = circleToPolygon(center, radius, numPts, true);
- SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getBarycenter(), BARYCENTER_EPS);
+ SphericalTestUtils.assertPointsEq(center.antipodal(), cw.getCentroid(), CENTROID_EPS);
}
@Test
@@ -849,8 +849,8 @@ public class RegionBSPTree2STest {
));
}
- private static Point2S triangleBarycenter(Point2S p1, Point2S p2, Point2S p3) {
- // compute the barycenter using intersection mid point arcs
+ private static Point2S triangleCentroid(Point2S p1, Point2S p2, Point2S p3) {
+ // compute the centroid using intersection mid point arcs
GreatCircle c1 = GreatCircles.fromPoints(p1, p2.slerp(p3, 0.5), TEST_PRECISION);
GreatCircle c2 = GreatCircles.fromPoints(p2, p1.slerp(p3, 0.5), TEST_PRECISION);
@@ -888,14 +888,14 @@ public class RegionBSPTree2STest {
return Point2S.of(Math.toRadians(longitude), Math.toRadians(90.0 - latitude));
}
- private static void checkBarycenterConsistency(RegionBSPTree2S region) {
- Point2S barycenter = region.getBarycenter();
+ private static void checkCentroidConsistency(RegionBSPTree2S region) {
+ Point2S centroid = region.getCentroid();
double size = region.getSize();
- GreatCircle circle = GreatCircles.fromPole(barycenter.getVector(), TEST_PRECISION);
+ GreatCircle circle = GreatCircles.fromPole(centroid.getVector(), TEST_PRECISION);
for (double az = 0; az <= PlaneAngleRadians.TWO_PI; az += 0.2) {
Point2S pt = circle.toSpace(Point1S.of(az));
- GreatCircle splitter = GreatCircles.fromPoints(barycenter, pt, TEST_PRECISION);
+ GreatCircle splitter = GreatCircles.fromPoints(centroid, pt, TEST_PRECISION);
Split<RegionBSPTree2S> split = region.split(splitter);
@@ -907,18 +907,18 @@ public class RegionBSPTree2STest {
RegionBSPTree2S plus = split.getPlus();
double plusSize = plus.getSize();
- Point2S computedBarycenter = Point2S.from(weightedBarycenterVector(minus)
- .add(weightedBarycenterVector(plus)));
+ Point2S computedCentroid = Point2S.from(weightedCentroidVector(minus)
+ .add(weightedCentroidVector(plus)));
Assert.assertEquals(size, minusSize + plusSize, TEST_EPS);
- SphericalTestUtils.assertPointsEq(barycenter, computedBarycenter, TEST_EPS);
+ SphericalTestUtils.assertPointsEq(centroid, computedCentroid, TEST_EPS);
}
}
- private static Vector3D weightedBarycenterVector(RegionBSPTree2S tree) {
+ private static Vector3D weightedCentroidVector(RegionBSPTree2S tree) {
Vector3D sum = Vector3D.ZERO;
for (ConvexArea2S convex : tree.toConvex()) {
- sum = sum.add(convex.getWeightedBarycenterVector());
+ sum = sum.add(convex.getWeightedCentroidVector());
}
return sum;
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 8e1c7a1..2da9596 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -45,7 +45,7 @@
// construct a precision context to handle floating-point comparisons
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
-// create a binary space partitioning tree representing the unit cube
+// create a binary space partitioning (BSP) tree representing the unit cube
// centered on the origin
RegionBSPTree3D region = Parallelepiped.builder(precision)
.setPosition(Vector3D.ZERO)
@@ -62,7 +62,7 @@ region.intersection(copy);
// compute some properties of the intersection region
double size = region.getSize(); // 0.8284271247461903
-Vector3D center = region.getBarycenter(); // (0, 0, 0)
+Vector3D centroid = region.getCentroid(); // (0, 0, 0)
</source>
</section>
diff --git a/src/site/xdoc/userguide/index.xml b/src/site/xdoc/userguide/index.xml
index c33edc5..35f195a 100644
--- a/src/site/xdoc/userguide/index.xml
+++ b/src/site/xdoc/userguide/index.xml
@@ -350,7 +350,7 @@ currentNode.insertCut(Lines.fromPointAndDirection(Vector2D.of(0, 1), Vector2D.Un
int count = tree.count(); // number of nodes in the tree = 11
int height = tree.height(); // height of the tree = 3
double size = tree.getSize(); // size of the region = 1
-Vector2D barycenter = tree.getBarycenter(); // region barycenter = (0.5, 0.5)
+Vector2D centroid = tree.getCentroid(); // region centroid = (0.5, 0.5)
</source>
<h5>Standard BSP Tree Region Creation</h5>
@@ -376,7 +376,7 @@ tree.insert(Arrays.asList(
int count = tree.count(); // number of nodes in the tree = 9
int height = tree.height(); // height of the tree = 4
double size = tree.getSize(); // size of the region = 1
-Vector2D barycenter = tree.getBarycenter(); // region barycenter = (0.5, 0.5)
+Vector2D centroid = tree.getCentroid(); // region centroid = (0.5, 0.5)
</source>
</subsection>
@@ -666,7 +666,7 @@ tree.union(copy);
// compute some properties
double size = tree.getSize(); // 1.75
-Vector2D center = tree.getBarycenter(); // (0.75, 0.75)
+Vector2D centroid = tree.getCentroid(); // (0.75, 0.75)
// get a line path representing the boundary; a list is returned since trees
// can represent disjoint regions
@@ -831,8 +831,8 @@ int[][] faceIndices = {
List<ConvexPolygon3D> faces = Planes.indexedConvexPolygons(vertices, faceIndices, precision);
RegionBSPTree3D tree = RegionBSPTree3D.from(faces);
-// split the region through its barycenter along a diagonal of the base
-Plane cutter = Planes.fromPointAndNormal(tree.getBarycenter(), Vector3D.Unit.from(1, 1, 0), precision);
+// split the region through its centroid along a diagonal of the base
+Plane cutter = Planes.fromPointAndNormal(tree.getCentroid(), Vector3D.Unit.from(1, 1, 0), precision);
Split<RegionBSPTree3D> split = tree.split(cutter);
// compute some properties for the minus side of the split and convert back to hyperplane subsets
@@ -1059,8 +1059,8 @@ GreatArcPath path = GreatArcPath.builder(precision)
// convert to a region
RegionBSPTree2S tree = path.toTree();
-// split in two through the barycenter
-GreatCircle splitter = GreatCircles.fromPoints(tree.getBarycenter(), Point2S.PLUS_K, precision);
+// split in two through the centroid
+GreatCircle splitter = GreatCircles.fromPoints(tree.getCentroid(), Point2S.PLUS_K, precision);
Split<RegionBSPTree2S> split = tree.split(splitter);
// compute some properties for the minus side