jumbo.euclid
Class RealRange

java.lang.Object
  |
  +--jumbo.euclid.Status
        |
        +--jumbo.euclid.RealRange

public class RealRange
extends Status

RealRange - maximum and minimum values

Contains two doubles representing the minimum and maximum of an allowed or observed range.

Default is range with low > high; this can be regarded as the uninitialised state. If points are added to a default RealRange it becomes initialised.


Field Summary
protected  double maxval
          maximum of range
protected  double minval
          minimum of range
 
Constructor Summary
RealRange()
          creates invalid range from POSITIVE_INFINITY to NEGATIVE_INFINITY
RealRange(double minv, double maxv)
          initialise with min and max values; if minv > maxv create inValid RealRange
RealRange(IntRange ir)
          from an IntRange
RealRange(RealRange r)
          copy constructor
 
Method Summary
 void add(double x)
          add a value to a range
 boolean contains(double f)
          synonym for includes()
 boolean equals(RealRange r)
          invalid ranges return false
 double getMax()
          get maximum value (NEGATIVE_INFINITY if inValid)
 double getMin()
          get minimum value (POSITIVE_INFINITY if inValid)
 double getRange()
          get range (NaN if invalid)
 boolean includes(double f)
          is a double within a RealRange? If inValid, return false
 boolean includes(RealRange r2)
          does one range include another?
 RealRange intersectionWith(RealRange r2)
          intersect two ranges and take the range common to both; return invalid range if no overlap
 boolean isValid()
          a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges
static void main(java.lang.String[] args)
          tests RealRange routines
 RealRange plus(RealRange r2)
          combine two ranges if both valid; takes greatest limits of both, else returns InValid
 java.lang.String toString()
          output
 
Methods inherited from class jumbo.euclid.Status
NYI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxval

protected double maxval
maximum of range

minval

protected double minval
minimum of range
Constructor Detail

RealRange

public RealRange()
creates invalid range from POSITIVE_INFINITY to NEGATIVE_INFINITY

RealRange

public RealRange(double minv,
                 double maxv)
initialise with min and max values; if minv > maxv create inValid RealRange

RealRange

public RealRange(RealRange r)
copy constructor

RealRange

public RealRange(IntRange ir)
from an IntRange
Method Detail

isValid

public boolean isValid()
a Range is only valid if its maxval is not less than its minval; this tests for uninitialised ranges

equals

public boolean equals(RealRange r)
invalid ranges return false

plus

public RealRange plus(RealRange r2)
combine two ranges if both valid; takes greatest limits of both, else returns InValid

intersectionWith

public RealRange intersectionWith(RealRange r2)
intersect two ranges and take the range common to both; return invalid range if no overlap

getMin

public double getMin()
get minimum value (POSITIVE_INFINITY if inValid)

getMax

public double getMax()
get maximum value (NEGATIVE_INFINITY if inValid)

getRange

public double getRange()
get range (NaN if invalid)

includes

public boolean includes(RealRange r2)
does one range include another?

includes

public boolean includes(double f)
is a double within a RealRange? If inValid, return false

contains

public boolean contains(double f)
synonym for includes()

add

public void add(double x)
add a value to a range

toString

public java.lang.String toString()
output
Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
tests RealRange routines