Class Interval1D

java.lang.Object
  extended by Interval1D

public class Interval1D
extends java.lang.Object

This class represents a simple scalar one-dimensional interval, together with a method for aquiring the intersection with another interval.


Field Summary
 float end
          End point of the interval.
 float start
          Start point of the interval.
 
Constructor Summary
Interval1D()
          Creates a new Interval1D spanning the whole real axis.
Interval1D(float start, float end)
          Creates a new Interval1D spanning the specified range.
 
Method Summary
 void intersection(Interval1D other)
          Performs the intersection operation between this interval and the supplied one.
static Interval1D intersection(Interval1D first, Interval1D second)
          Performs the intersection operation between the two supplied Interval1Ds.
 boolean isEmpty()
          Indicates whether this Interval1D is empty.
 boolean isValid()
          Returns whether the Interval1D is valid.
 void makeEmpty()
          Sets this Interval1D to the empty one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

start

public float start
Start point of the interval.


end

public float end
End point of the interval.

Constructor Detail

Interval1D

public Interval1D()
Creates a new Interval1D spanning the whole real axis.


Interval1D

public Interval1D(float start,
                  float end)
Creates a new Interval1D spanning the specified range.

Parameters:
start - the start point of the interval.
end - the end point of the interval.
Method Detail

isEmpty

public boolean isEmpty()
Indicates whether this Interval1D is empty.

Returns:
true if the interval is empty, false otherwise.

makeEmpty

public void makeEmpty()
Sets this Interval1D to the empty one.


isValid

public boolean isValid()
Returns whether the Interval1D is valid. An interval is considered valid if the end point is greater than the start point. An empty interval is also counted as a valid one.

Returns:
true if the interval is valid, false otherwise.

intersection

public void intersection(Interval1D other)
Performs the intersection operation between this interval and the supplied one. This interval is updated accordingly while the supplied one is left unchanged.

Parameters:
other - the interval to intersect this one with.

intersection

public static Interval1D intersection(Interval1D first,
                                      Interval1D second)
Performs the intersection operation between the two supplied Interval1Ds. The result is returned as a new Interval1D.

Parameters:
first - the first interval.
second - the second interval.
Returns:
a new Interval1D as a result of the operation.