Fixed naming inconsistencies between Interval and IntervalsSet classes.
JIRA: MATH-890 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1405711 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2a41e40c15
commit
c61b08e546
|
@ -52,6 +52,9 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||
<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>
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -143,8 +143,8 @@ public class IntervalsSet extends AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
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 AbstractRegion<Euclidean1D, Euclidean1D> {
|
|||
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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -840,10 +840,10 @@ public class PolygonsSet extends AbstractRegion<Euclidean2D, Euclidean1D> {
|
|||
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 {
|
||||
|
|
|
@ -84,8 +84,8 @@ public class SubLine extends AbstractSubHyperplane<Euclidean2D, Euclidean1D> {
|
|||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue