commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r1405711 - in /commons/proper/math/trunk/src: changes/ main/java/org/apache/commons/math3/geometry/euclidean/oned/ main/java/org/apache/commons/math3/geometry/euclidean/threed/ main/java/org/apache/commons/math3/geometry/euclidean/twod/ tes...
Date Mon, 05 Nov 2012 08:43:39 GMT
Author: luc
Date: Mon Nov  5 08:43:38 2012
New Revision: 1405711

URL: http://svn.apache.org/viewvc?rev=1405711&view=rev
Log:
Fixed naming inconsistencies between Interval and IntervalsSet classes.

JIRA: MATH-890

Modified:
    commons/proper/math/trunk/src/changes/changes.xml
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/Interval.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSet.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSetTest.java
    commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSetTest.java

Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Mon Nov  5 08:43:38 2012
@@ -52,6 +52,9 @@ If the output is not quite correct, chec
   <body>
     <release version="3.1" date="TBD" description="
 ">
+      <action dev="luc" type="fix" issue="MATH-890">
+        Fixed naming inconsistencies between Interval and IntervalsSet classes.
+      </action>
       <action dev="luc" type="add" issue="MATH-889">
         Added a method to check points in the Interval class, with a tolerance for boundary.
       </action>

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/Interval.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/Interval.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/Interval.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/Interval.java
Mon Nov  5 08:43:38 2012
@@ -43,30 +43,70 @@ public class Interval {
 
     /** Get the lower bound of the interval.
      * @return lower bound of the interval
+     * @since 3.1
      */
-    public double getLower() {
+    public double getInf() {
         return lower;
     }
 
+    /** Get the lower bound of the interval.
+     * @return lower bound of the interval
+     * @deprecated as of 3.1, replaced by {@link #getInf()}
+     */
+    @Deprecated
+    public double getLower() {
+        return getInf();
+    }
+
     /** Get the upper bound of the interval.
      * @return upper bound of the interval
+     * @since 3.1
      */
-    public double getUpper() {
+    public double getSup() {
         return upper;
     }
 
+    /** Get the upper bound of the interval.
+     * @return upper bound of the interval
+     * @deprecated as of 3.1, replaced by {@link #getSup()}
+     */
+    @Deprecated
+    public double getUpper() {
+        return getSup();
+    }
+
+    /** Get the size of the interval.
+     * @return size of the interval
+     * @since 3.1
+     */
+    public double getSize() {
+        return upper - lower;
+    }
+
     /** Get the length of the interval.
      * @return length of the interval
+     * @deprecated as of 3.1, replaced by {@link #getSize()}
      */
+    @Deprecated
     public double getLength() {
-        return upper - lower;
+        return getSize();
+    }
+
+    /** Get the barycenter of the interval.
+     * @return barycenter of the interval
+     * @since 3.1
+     */
+    public double getBarycenter() {
+        return 0.5 * (lower + upper);
     }
 
     /** Get the midpoint of the interval.
      * @return midpoint of the interval
+     * @deprecated as of 3.1, replaced by {@link #getBarycenter()}
      */
+    @Deprecated
     public double getMidPoint() {
-        return 0.5 * (lower + upper);
+        return getBarycenter();
     }
 
     /** Check a point with respect to the interval.

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSet.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSet.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSet.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSet.java
Mon Nov  5 08:43:38 2012
@@ -143,8 +143,8 @@ public class IntervalsSet extends Abstra
             double size = 0.0;
             double sum = 0.0;
             for (final Interval interval : asList()) {
-                size += interval.getLength();
-                sum  += interval.getLength() * interval.getMidPoint();
+                size += interval.getSize();
+                sum  += interval.getSize() * interval.getBarycenter();
             }
             setSize(size);
             if (Double.isInfinite(size)) {
@@ -241,7 +241,7 @@ public class IntervalsSet extends Abstra
             if ((checkPoint(low,  loc) == Location.INSIDE) &&
                 (checkPoint(high, loc) == Location.INSIDE)) {
                 // merge the last interval added and the first one of the high sub-tree
-                x = list.remove(list.size() - 1).getLower();
+                x = list.remove(list.size() - 1).getInf();
             }
             recurseList(high, list, x, upper);
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java
Mon Nov  5 08:43:38 2012
@@ -84,8 +84,8 @@ public class SubLine {
         final List<Segment> segments = new ArrayList<Segment>();
 
         for (final Interval interval : list) {
-            final Vector3D start = line.toSpace(new Vector1D(interval.getLower()));
-            final Vector3D end   = line.toSpace(new Vector1D(interval.getUpper()));
+            final Vector3D start = line.toSpace(new Vector1D(interval.getInf()));
+            final Vector3D end   = line.toSpace(new Vector1D(interval.getSup()));
             segments.add(new Segment(start, end, line));
         }
 

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java
Mon Nov  5 08:43:38 2012
@@ -840,10 +840,10 @@ public class PolygonsSet extends Abstrac
             final Line line      = (Line) sub.getHyperplane();
             final List<Interval> intervals = ((IntervalsSet) absSub.getRemainingRegion()).asList();
             for (final Interval i : intervals) {
-                final Vector2D start = Double.isInfinite(i.getLower()) ?
-                                      null : (Vector2D) line.toSpace(new Vector1D(i.getLower()));
-                final Vector2D end   = Double.isInfinite(i.getUpper()) ?
-                                      null : (Vector2D) line.toSpace(new Vector1D(i.getUpper()));
+                final Vector2D start = Double.isInfinite(i.getInf()) ?
+                                      null : (Vector2D) line.toSpace(new Vector1D(i.getInf()));
+                final Vector2D end   = Double.isInfinite(i.getSup()) ?
+                                      null : (Vector2D) line.toSpace(new Vector1D(i.getSup()));
                 if (reversed) {
                     sorted.insert(new ComparableSegment(end, start, line.getReverse()));
                 } else {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java
Mon Nov  5 08:43:38 2012
@@ -84,8 +84,8 @@ public class SubLine extends AbstractSub
         final List<Segment> segments = new ArrayList<Segment>();
 
         for (final Interval interval : list) {
-            final Vector2D start = line.toSpace(new Vector1D(interval.getLower()));
-            final Vector2D end   = line.toSpace(new Vector1D(interval.getUpper()));
+            final Vector2D start = line.toSpace(new Vector1D(interval.getInf()));
+            final Vector2D end   = line.toSpace(new Vector1D(interval.getSup()));
             segments.add(new Segment(start, end, line));
         }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalTest.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalTest.java
Mon Nov  5 08:43:38 2012
@@ -27,15 +27,15 @@ public class IntervalTest {
     @Test
     public void testInterval() {
         Interval interval = new Interval(2.3, 5.7);
-        Assert.assertEquals(3.4, interval.getLength(), 1.0e-10);
-        Assert.assertEquals(4.0, interval.getMidPoint(), 1.0e-10);
+        Assert.assertEquals(3.4, interval.getSize(), 1.0e-10);
+        Assert.assertEquals(4.0, interval.getBarycenter(), 1.0e-10);
         Assert.assertEquals(Region.Location.BOUNDARY, interval.checkPoint(2.3, 1.0e-10));
         Assert.assertEquals(Region.Location.BOUNDARY, interval.checkPoint(5.7, 1.0e-10));
         Assert.assertEquals(Region.Location.OUTSIDE,  interval.checkPoint(1.2, 1.0e-10));
         Assert.assertEquals(Region.Location.OUTSIDE,  interval.checkPoint(8.7, 1.0e-10));
         Assert.assertEquals(Region.Location.INSIDE,   interval.checkPoint(3.0, 1.0e-10));
-        Assert.assertEquals(2.3, interval.getLower(), 1.0e-10);
-        Assert.assertEquals(5.7, interval.getUpper(), 1.0e-10);
+        Assert.assertEquals(2.3, interval.getInf(), 1.0e-10);
+        Assert.assertEquals(5.7, interval.getSup(), 1.0e-10);
     }
 
     @Test
@@ -58,17 +58,17 @@ public class IntervalTest {
             Assert.assertEquals(Region.Location.INSIDE,
                                 interval.checkPoint(FastMath.pow(10.0, e), 1.0e-10));
         }
-        Assert.assertTrue(Double.isInfinite(interval.getLength()));
-        Assert.assertEquals(9.0, interval.getLower(), 1.0e-10);
-        Assert.assertTrue(Double.isInfinite(interval.getUpper()));
+        Assert.assertTrue(Double.isInfinite(interval.getSize()));
+        Assert.assertEquals(9.0, interval.getInf(), 1.0e-10);
+        Assert.assertTrue(Double.isInfinite(interval.getSup()));
 
     }
 
     @Test
     public void testSinglePoint() {
         Interval interval = new Interval(1.0, 1.0);
-        Assert.assertEquals(0.0, interval.getLength(), Precision.SAFE_MIN);
-        Assert.assertEquals(1.0, interval.getMidPoint(), Precision.EPSILON);
+        Assert.assertEquals(0.0, interval.getSize(), Precision.SAFE_MIN);
+        Assert.assertEquals(1.0, interval.getBarycenter(), Precision.EPSILON);
     }
 
 }

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSetTest.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSetTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/oned/IntervalsSetTest.java
Mon Nov  5 08:43:38 2012
@@ -87,12 +87,12 @@ public class IntervalsSetTest {
 
         List<Interval> list = set.asList();
         Assert.assertEquals(3, list.size());
-        Assert.assertEquals( 1.0, list.get(0).getLower(), 1.0e-10);
-        Assert.assertEquals( 3.0, list.get(0).getUpper(), 1.0e-10);
-        Assert.assertEquals( 5.0, list.get(1).getLower(), 1.0e-10);
-        Assert.assertEquals( 6.0, list.get(1).getUpper(), 1.0e-10);
-        Assert.assertEquals( 9.0, list.get(2).getLower(), 1.0e-10);
-        Assert.assertEquals(11.0, list.get(2).getUpper(), 1.0e-10);
+        Assert.assertEquals( 1.0, list.get(0).getInf(), 1.0e-10);
+        Assert.assertEquals( 3.0, list.get(0).getSup(), 1.0e-10);
+        Assert.assertEquals( 5.0, list.get(1).getInf(), 1.0e-10);
+        Assert.assertEquals( 6.0, list.get(1).getSup(), 1.0e-10);
+        Assert.assertEquals( 9.0, list.get(2).getInf(), 1.0e-10);
+        Assert.assertEquals(11.0, list.get(2).getSup(), 1.0e-10);
 
     }
 

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSetTest.java?rev=1405711&r1=1405710&r2=1405711&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSetTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSetTest.java
Mon Nov  5 08:43:38 2012
@@ -231,17 +231,17 @@ public class PolygonsSetTest {
         List<Interval> i1 = ((IntervalsSet) s1.getRemainingRegion()).asList();
         Assert.assertEquals(2, i1.size());
         Interval v10 = i1.get(0);
-        Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getLower()));
+        Vector2D p10Lower = l1.toSpace(new Vector1D(v10.getInf()));
         Assert.assertEquals(0.0, p10Lower.getX(), 1.0e-10);
         Assert.assertEquals(1.5, p10Lower.getY(), 1.0e-10);
-        Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getUpper()));
+        Vector2D p10Upper = l1.toSpace(new Vector1D(v10.getSup()));
         Assert.assertEquals(0.5, p10Upper.getX(), 1.0e-10);
         Assert.assertEquals(2.0, p10Upper.getY(), 1.0e-10);
         Interval v11 = i1.get(1);
-        Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getLower()));
+        Vector2D p11Lower = l1.toSpace(new Vector1D(v11.getInf()));
         Assert.assertEquals(1.0, p11Lower.getX(), 1.0e-10);
         Assert.assertEquals(2.5, p11Lower.getY(), 1.0e-10);
-        Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getUpper()));
+        Vector2D p11Upper = l1.toSpace(new Vector1D(v11.getSup()));
         Assert.assertEquals(1.5, p11Upper.getX(), 1.0e-10);
         Assert.assertEquals(3.0, p11Upper.getY(), 1.0e-10);
 
@@ -250,10 +250,10 @@ public class PolygonsSetTest {
         List<Interval> i2 = ((IntervalsSet) s2.getRemainingRegion()).asList();
         Assert.assertEquals(1, i2.size());
         Interval v20 = i2.get(0);
-        Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getLower()));
+        Vector2D p20Lower = l2.toSpace(new Vector1D(v20.getInf()));
         Assert.assertEquals(1.0, p20Lower.getX(), 1.0e-10);
         Assert.assertEquals(2.0, p20Lower.getY(), 1.0e-10);
-        Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getUpper()));
+        Vector2D p20Upper = l2.toSpace(new Vector1D(v20.getSup()));
         Assert.assertEquals(3.0, p20Upper.getX(), 1.0e-10);
         Assert.assertEquals(2.0, p20Upper.getY(), 1.0e-10);
 



Mime
View raw message