public class Interval
extends java.lang.Object
implements java.io.Serializable
Represents an interval on the real line. Intervals are identified by their end points, which may or may not be included depending upon whether the interval is open or closed. Nonetheless, we consider the left end the minimum value and the right end point the maximum value and refer to them as such.
Issues concerning boundary points are delegated to the derived classes.
Constructor and Description |
---|
Interval()
Default constructor - creates a new instance of Interval with one point,
the origin.
|
Interval(double min,
double max)
Initializing constructor - create an interval with specified endpoints
|
Interval(Interval I)
Copy constructor - create a new open interval initialized to the argument.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsAE(Interval I) |
Interval |
convexHull(Interval I)
Compute and return the smallest interval containing both this interval
and the argument interval (i.e., the union of they are intersected).
|
static Interval |
createFromEndpoints(double dblMin,
double dblMax)
Creates a new interval object according to the given endpoints.
|
static Interval |
createFromMidpoint(double dblMidpt,
double dblLng)
Creates an interval object given the midpoint (centroid) of the interval
and the length of the interval (which is the Lebesgue measure).
|
boolean |
equals(Interval I)
Are intervals equal
|
double |
getMax()
Get maximum value of interval.
|
double |
getMin()
Get minimum value of interval.
|
Interval |
intersection(Interval I)
Compute and return the largest interval contained in this interval
and the argument interval (i.e., the intersection).
|
boolean |
intersects(Interval I)
Inspects for non-empty intersection with the given interval.
|
boolean |
isBoundary(double x)
Is point a boundary element?
|
double |
measure()
Compute the interval length.
|
boolean |
membership(double x)
Is point a member of this interval I ⊂ R.
|
double |
midpoint()
Compute the interval midpoint.
|
void |
print(java.io.PrintWriter os)
Print out contents on an output stream
|
void |
println(java.io.PrintWriter os)
Print out contents on an output stream, terminate in newline character
|
void |
setMax(double max)
Set the right end point
|
void |
setMin(double min)
Set the left end point
|
java.lang.String |
toString()
Return the contents of the interval as a
String . |
double[] |
vertexCoordinates(double x)
Compute the local "vertex coordinates" of the argument x with
respect to this interval I ⊂ R.
|
public Interval()
public Interval(double min, double max) throws MathException
min
- left endpointmax
- right endpointMathException
- max is smaller than minpublic Interval(Interval I) throws MathException
I
- interval to copyMathException
- malformed interval to copypublic static Interval createFromMidpoint(double dblMidpt, double dblLng)
dblMidpt
- the center location of the intervaldblLng
- the length of the intervalpublic static Interval createFromEndpoints(double dblMin, double dblMax)
null
value in this case.dblMin
- the left-hand endpointdblMax
- the right-hand endpointpublic void setMin(double min)
min
- interval left-hand sidepublic void setMax(double max)
max
- interval right-hand sidepublic double getMin()
public double getMax()
public double measure()
public double midpoint()
public boolean membership(double x)
x
- point to be tested as a member of this intervalpublic boolean equals(Interval I)
I
- interval object to be checked for equalitypublic boolean intersects(Interval I)
I
- interval to inspect.public boolean isBoundary(double x)
x
- point to be tested as boundary elementpublic boolean containsAE(Interval I)
Checks whether or not the given interval is a proper subset of this interval, modulo the endpoints. Specifically, I must be contained within this interval modulo the endpoints. We ignore the endpoints and, thus, the condition of whether or not either interval is closed or open.
I
- interval to be testedtrue
if I ⊂ this
,
false
otherwisepublic double[] vertexCoordinates(double x) throws MathException
Compute the local "vertex coordinates" of the argument x with
respect to this interval I ⊂ R.
These "local coordinates"
{λ1,λ2}
of a point x ∈ I
can computed by solving the following linear equation
for the {λi} :
|
|
|
| |
⌈ | x | ⌉ | ||
⌊ | 1 | ⌋ |
x
- point in IMathException
- argument is not a member of this setpublic Interval convexHull(Interval I) throws MathException
I
- right-hand-side argumentthis
and I
MathException
- empty intersectionpublic Interval intersection(Interval I)
null
value is returned. Since the empty is a
valid result of intersection, this value should be considered in
any robust implementation.I
- interval to be intersected with this
intervalthis
and I
,
or null
if the empty set {}public java.lang.String toString()
String
.
return string representation of intervaltoString
in class java.lang.Object
Object.toString()
public void print(java.io.PrintWriter os)
os
- output stream receiving content dumppublic void println(java.io.PrintWriter os)
os
- output stream receiving content dump