commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1557514 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java
Date Sun, 12 Jan 2014 11:13:05 GMT
Author: luc
Date: Sun Jan 12 11:13:05 2014
New Revision: 1557514

URL: http://svn.apache.org/r1557514
Log:
Fixed missing last iteration in a loop.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java?rev=1557514&r1=1557513&r2=1557514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.java
Sun Jan 12 11:13:05 2014
@@ -628,7 +628,7 @@ public class SphericalPolygonsSet extend
                 double sum = 0;
                 Vector3D sumP = Vector3D.ZERO;
                 for (Edge edge = startVertex.getOutgoing();
-                     edge.getEnd() != startVertex;
+                     n == 0 || edge.getStart() != startVertex;
                      edge = edge.getEnd().getOutgoing()) {
                     final Vector3D middle = edge.getPointAt(0.5 * edge.getLength());
                     sumP = new Vector3D(1, sumP, edge.getLength(), middle);

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java?rev=1557514&r1=1557513&r2=1557514&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSetTest.java
Sun Jan 12 11:13:05 2014
@@ -16,9 +16,12 @@
  */
 package org.apache.commons.math3.geometry.spherical.twod;
 
+import java.util.List;
+
 import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
 import org.apache.commons.math3.geometry.partitioning.Region.Location;
 import org.apache.commons.math3.geometry.partitioning.RegionFactory;
+import org.apache.commons.math3.geometry.spherical.twod.SphericalPolygonsSet.Vertex;
 import org.apache.commons.math3.random.UnitSphereRandomVectorGenerator;
 import org.apache.commons.math3.random.Well1024a;
 import org.apache.commons.math3.util.FastMath;
@@ -81,6 +84,35 @@ public class SphericalPolygonsSetTest {
                 Assert.assertEquals(Location.BOUNDARY, octant.checkPoint(new S2Point(v)));
             }
         }
+
+        List<SphericalPolygonsSet.Vertex> loops = octant.getBoundaryLoops();
+        Assert.assertEquals(1, loops.size());
+        boolean xFound = false;
+        boolean yFound = false;
+        boolean zFound = false;
+        Vertex first = loops.get(0);
+        xFound = first.getLocation().getVector().distance(Vector3D.PLUS_I) < 1.0e-10;
+        yFound = first.getLocation().getVector().distance(Vector3D.PLUS_J) < 1.0e-10;
+        zFound = first.getLocation().getVector().distance(Vector3D.PLUS_K) < 1.0e-10;
+        int count = 1;
+        for (Vertex v = first.getOutgoing().getEnd(); v != first; v = v.getOutgoing().getEnd())
{
+            ++count;
+            Assert.assertTrue(v == v.getIncoming().getStart().getOutgoing().getEnd());
+            Assert.assertEquals(0.5 * FastMath.PI, v.getIncoming().getLength(), 1.0e-10);
+            xFound = xFound || v.getLocation().getVector().distance(Vector3D.PLUS_I) <
1.0e-10;
+            yFound = yFound || v.getLocation().getVector().distance(Vector3D.PLUS_J) <
1.0e-10;
+            zFound = zFound || v.getLocation().getVector().distance(Vector3D.PLUS_K) <
1.0e-10;
+        }
+        Assert.assertTrue(xFound);
+        Assert.assertTrue(yFound);
+        Assert.assertTrue(zFound);
+        Assert.assertEquals(3, count);
+
+        Assert.assertEquals(0.0,
+                            new Vector3D(1, 1, 1).normalize().distance(((S2Point) octant.getBarycenter()).getVector()),
+                            1.0e-10);
+        Assert.assertEquals(0.5 * FastMath.PI, octant.getSize(), 1.0e-10);
+
     }
 
     @Test



Mime
View raw message