public final class Interval extends Object implements HyperplaneBoundedRegion<Vector1D>
Instances of this class are guaranteed to be immutable.
Modifier and Type | Method and Description |
---|---|
RegionLocation |
classify(double location)
Classify a point with respect to the interval.
|
RegionLocation |
classify(Vector1D pt) |
boolean |
contains(double x)
Return true if the given point location is on the inside or boundary
of the region.
|
static Interval |
full()
Return an interval representing the entire real number line.
|
double |
getBoundarySize() |
Vector1D |
getCentroid() |
double |
getMax()
Get the maximum value for the interval or
Double.POSITIVE_INFINITY
if no maximum value exists. |
OrientedPoint |
getMaxBoundary()
Get the
OrientedPoint forming the maximum bounding hyperplane
of the interval, or null if none exists. |
double |
getMin()
Get the minimum value for the interval or
Double.NEGATIVE_INFINITY
if no minimum value exists. |
OrientedPoint |
getMinBoundary()
Get the
OrientedPoint forming the minimum bounding hyperplane
of the interval, or null if none exists. |
double |
getSize() |
boolean |
hasMaxBoundary()
Return true if the interval has a maximum (upper) boundary.
|
boolean |
hasMinBoundary()
Return true if the interval has a minimum (lower) boundary.
|
boolean |
isEmpty() |
boolean |
isFinite()
True if the region is finite, meaning that both the minimum and maximum
boundaries exist and the region size is finite.
|
boolean |
isFull() |
boolean |
isInfinite()
True if the region is infinite, meaning that at least one of the boundaries
does not exist.
|
static Interval |
max(double max,
Precision.DoubleEquivalence precision)
Return an interval with the given max value and no min.
|
static Interval |
min(double min,
Precision.DoubleEquivalence precision)
Return an interval with the given min value and no max.
|
static Interval |
of(double a,
double b,
Precision.DoubleEquivalence precision)
Create a new interval from the given point locations.
|
static Interval |
of(OrientedPoint a,
OrientedPoint b)
Create a new interval from the given hyperplanes.
|
static Interval |
of(Vector1D a,
Vector1D b,
Precision.DoubleEquivalence precision)
Create a new interval from the given points.
|
static Interval |
point(double location,
Precision.DoubleEquivalence precision)
Return an interval representing a single point at the given location.
|
Vector1D |
project(Vector1D pt) |
Split<Interval> |
split(Hyperplane<Vector1D> splitter) |
String |
toString() |
RegionBSPTree1D |
toTree()
Return a
RegionBSPTree1D representing the same region as this instance. |
Interval |
transform(Transform<Vector1D> transform)
Return a new instance transformed by the argument.
|
public double getMin()
Double.NEGATIVE_INFINITY
if no minimum value exists.Double.NEGATIVE_INFINITY
if no minimum value exists.public double getMax()
Double.POSITIVE_INFINITY
if no maximum value exists.Double.POSITIVE_INFINITY
if no maximum value exists.public OrientedPoint getMinBoundary()
OrientedPoint
forming the minimum bounding hyperplane
of the interval, or null if none exists. If present, This hyperplane
is oriented to point in the negative direction.public OrientedPoint getMaxBoundary()
OrientedPoint
forming the maximum bounding hyperplane
of the interval, or null if none exists. If present, this hyperplane
is oriented to point in the positive direction.public boolean hasMinBoundary()
public boolean hasMaxBoundary()
public boolean isInfinite()
isInfinite
in interface Sized
public boolean isFinite()
public RegionLocation classify(Vector1D pt)
public RegionLocation classify(double location)
location
- the location to classifyclassify(Vector1D)
public boolean contains(double x)
x
- the location to testRegion.contains(org.apache.commons.geometry.core.Point)
public Vector1D project(Vector1D pt)
The point is projected onto the nearest interval boundary. When a point is on the inside of the interval and is equidistant from both boundaries, then the minimum boundary is selected. when a point is on the outside of the interval and is equidistant from both boundaries (as is the case for intervals representing a single point), then the boundary facing the point is returned, ensuring that the returned offset is positive.
public Interval transform(Transform<Vector1D> transform)
transform
- transform to applypublic boolean isEmpty()
This method always returns false since there is always at least one point that can be classified as not being on the outside of the region.
public double getBoundarySize()
This method simply returns 0 because boundaries in one dimension do not have any size.
getBoundarySize
in interface Region<Vector1D>
public Vector1D getCentroid()
getCentroid
in interface Region<Vector1D>
public Split<Interval> split(Hyperplane<Vector1D> splitter)
split
in interface Splittable<Vector1D,HyperplaneBoundedRegion<Vector1D>>
public RegionBSPTree1D toTree()
RegionBSPTree1D
representing the same region as this instance.RegionBSPTree1D.from(Interval, Interval...)
public static Interval of(double a, double b, Precision.DoubleEquivalence precision)
a
- first point locationb
- second point locationprecision
- precision context used to compare floating point numbersIllegalArgumentException
- if either number is NaN
or the numbers
are both infinite and have the same signpublic static Interval of(Vector1D a, Vector1D b, Precision.DoubleEquivalence precision)
a
- first pointb
- second pointprecision
- precision context used to compare floating point numbersIllegalArgumentException
- if either point is NaN
or the points
are both infinite
and have the same signpublic static Interval of(OrientedPoint a, OrientedPoint b)
a
- first hyperplane; may be nullb
- second hyperplane; may be nullIllegalArgumentException
- if the hyperplanes have the same orientation or
do not form an interval (for example, if the positive-facing hyperplane is below
the negative-facing hyperplane)public static Interval min(double min, Precision.DoubleEquivalence precision)
min
- min value for the intervalprecision
- precision context used to compare floating point numberspublic static Interval max(double max, Precision.DoubleEquivalence precision)
max
- max value for the intervalprecision
- precision context used to compare floating point numberspublic static Interval point(double location, Precision.DoubleEquivalence precision)
location
- the location of the intervalprecision
- precision context used to compare floating point numbersCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.