Home

SPAinterval Class Reference
[Geometric Atoms]

Records an interval on the real line. More...

#include <interval.hxx>

Inheritance diagram for SPAinterval:

Inheritance graph
[legend]
Collaboration diagram for SPAinterval:

Collaboration graph
[legend]

List of all members.

Public Member Functions

logical bounded () const
 Determines if this interval is bounded above and below.
logical bounded_above () const
 Determines if this interval is bounded above, regardless of whether it is bounded below or not.
logical bounded_below () const
 Determines if this interval is bounded below, regardless of whether it is bounded above or not.
void debug (FILE *fp=debug_file_ptr) const
 Outputs the details of an interval to the specified file.
void debug_str (char *str1) const
 Concatenates the details of this interval to the given string.
logical empty () const
 Determines if this interval is empty.
double end_pt () const
 Returns the end point of this interval.
logical finite () const
 Determines if this interval is finite; that is, bounded on both ends.
logical finite_above () const
 Determines if this interval is finite above; that is, bounded at the higher parameter only.
logical finite_below () const
 Determines if this interval is finite below; that is, bounded at the lower parameter only.
logical infinite () const
 Determines if this interval is infinite; that is, unbounded on both ends.
double interpolate (double d) const
 Interpolates within this interval.
double length () const
 Returns the difference between the high and low ends of the interval.
double mid_pt () const
 Returns the middle point of this interval.
SPAintervalnegate ()
 Negates this interval in place.
SPAintervaloperator &= (SPAinterval const &i)
 Updates this interval to be the overlap of itself and the given interval.
SPAintervaloperator*= (double d)
 Multiplies this interval by a scalar.
SPAintervaloperator+= (double d)
 Adds a scalar value to both ends of this interval, shifting this interval by the value.
SPAintervaloperator+= (SPAinterval const &inter)
 Adds an interval to this interval.
SPAintervaloperator-= (double d)
 Subtracts a scalar value from both ends of this interval, shifting this interval by the value.
SPAintervaloperator-= (SPAinterval const &inter)
 Subtracts an interval from this interval.
SPAintervaloperator/= (double d)
 Divides this interval by a scalar.
logical operator<< (SPAinterval const &i) const
 Determines whether this interval is entirely enclosed within the given interval.
logical operator>> (SPAinterval const &inter) const
 Determines whether the given interval is entirely enclosed within this interval.
logical operator>> (double d) const
 Determines whether a parameter value lies within this interval.
SPAintervaloperator|= (SPAinterval const &i)
 Updates this interval to include the given interval.
logical scalar () const
 Determines if this interval is a scalar; that is, if it consists of a single point.
 SPAinterval (interval_type type, double const &d1=*(double *) NULL_REF, double const &d2=*(double *) NULL_REF)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAinterval (double d1, double d2)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAinterval (double d)
 C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.
 SPAinterval ()
 C++ allocation constructor requests memory for this object and constructs an empty SPAinterval.
double start_pt () const
 Returns the start point of this interval.
interval_type type () const
 Returns the type of this interval.
logical unbounded () const
 Determines if this interval is unbounded; that is, it is either infinite or semi-infinite.
logical unbounded_above () const
 Determines if this interval is unbounded above, regardless of whether it is bounded below or not.
logical unbounded_below () const
 Determines if this interval is unbounded below, regardless of whether it is bounded above or not.

Friends

SPAinterval operator & (SPAinterval const &i1, SPAinterval const &i2)
 Finds the interval of overlap.
logical operator && (SPAinterval const &i1, SPAinterval const &i2)
 Determines whether two intervals overlap.
logical operator!= (SPAinterval const &i1, SPAinterval const &i2)
 Inequality operator for determining whether two intervals are not identical.
SPAinterval operator* (double d, SPAinterval const &i)
 Multiplies a scalar by an interval.
SPAinterval operator* (SPAinterval const &i, double d)
 Multiplies an interval by a scalar.
SPAinterval operator+ (double d, SPAinterval const &i)
 Adds a double and an interval.
SPAinterval operator+ (SPAinterval const &i, double d)
 Adds an interval and a double.
SPAinterval operator+ (SPAinterval const &i1, SPAinterval const &i2)
 Adds two intervals together.
SPAinterval operator- (double d, SPAinterval const &i)
 Subtracts an interval from a double.
SPAinterval operator- (SPAinterval const &i, double d)
 Subtracts a double from an interval.
SPAinterval operator- (SPAinterval const &i1, SPAinterval const &i2)
 Subtracts two intervals.
SPAinterval operator- (SPAinterval const &i)
 Negates an interval.
SPAinterval operator/ (SPAinterval const &i, double d)
 Divides an interval by a scalar.
logical operator< (SPAinterval const &i1, SPAinterval const &i2)
 Arithmetic comparison.
logical operator< (double d, SPAinterval const &i)
 Arithmetic comparison.
logical operator< (SPAinterval const &i, double d)
 Arithmetic comparison.
logical operator<< (double r, SPAinterval const &i)
 Determines whether the given parameter value lies within the given interval.
logical operator<= (SPAinterval const &i1, SPAinterval const &i2)
 Arithmetic comparison.
logical operator<= (double d, SPAinterval const &i)
 Arithmetic comparison.
logical operator<= (SPAinterval const &i, double d)
 Arithmetic comparison.
logical operator== (SPAinterval const &i1, SPAinterval const &i2)
 Equality operator for determining whether two intervals are identical.
logical operator> (SPAinterval const &i1, SPAinterval const &i2)
 Arithmetic comparison.
logical operator> (double d, SPAinterval const &i)
 Arithmetic comparison.
logical operator> (SPAinterval const &i, double d)
 Arithmetic comparison.
logical operator>= (SPAinterval const &i1, SPAinterval const &i2)
 Arithmetic comparison.
logical operator>= (double d, SPAinterval const &i)
 Arithmetic comparison.
logical operator>= (SPAinterval const &i, double d)
 Arithmetic comparison.
SPAinterval operator| (SPAinterval const &i1, SPAinterval const &i2)
 Constructs an interval containing two intervals.


Detailed Description

Records an interval on the real line.

Role: This class records an interval on the real line, i.e., a one dimensional region. It is implemented as an ordered pair of reals, together with a flag, an interval_type, that indicates whether each end is bounded or not. This allows the representation and manipulation of finite, infinite, semi-infinite, and empty intervals. The boundary value at an unbounded end is irrelevant.

Empty intervals are represented by a SPAinterval with a type of interval_finite and a low parameter of 1 and a high parameter of 0. Infinite intervals are represented by a SPAinterval with a type of interval_infinite and a low parameter of 1 and a high parameter of 0. Semi-infinite intervals are represented by a SPAinterval with a type of either interval_finite_below or interval_finite_above; the parameter value at the unbounded end is undefined, although often it will have the same value as the bounded end.

Intervals are typically used to record the parameter range of a variable, which is often the domain of a curve. Two intervals may be combined in a SPApar_box, which may be used to record the parameter range of a surface. Three intervals may be combined in a SPAbox, which may be used to record the three-dimensional bounding box of a topological entity.

See also:
SPApar_box, SPAbox

Constructor & Destructor Documentation

SPAinterval::SPAinterval (  )  [inline]

C++ allocation constructor requests memory for this object and constructs an empty SPAinterval.

SPAinterval::SPAinterval ( double  d  )  [inline]

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.

Role: Constructs a zero-length interval from one parameter value.

Parameters:
d given parameter value.

SPAinterval::SPAinterval ( double  d1,
double  d2 
)

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.

Role: Constructs a finite interval from two values. The arguments do not need to be in ascending sequence. The constructor checks and adjusts the argument sequence.

Parameters:
d1 first parameter value.
d2 second parameter value.

SPAinterval::SPAinterval ( interval_type  type,
double const &  d1 = *(double *) NULL_REF,
double const &  d2 = *(double *) NULL_REF 
)

C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.

Role: Constructs a bounded or unbounded interval from a descripter and up to two values. If the given interval_type is interval_unknown, the type is derived from the presence or absence of the real arguments ("absence" means unbounded at the appropriate end). Otherwise, the type is as given. Any required bound is taken from the arguments. If there are two real arguments, they are low/high. If there is only one real argument, it is used for both ends.

Parameters:
type given interval type.
d1 lower parameter value.
d2 higher parameter value.


Member Function Documentation

logical SPAinterval::bounded (  )  const [inline]

Determines if this interval is bounded above and below.

logical SPAinterval::bounded_above (  )  const [inline]

Determines if this interval is bounded above, regardless of whether it is bounded below or not.

logical SPAinterval::bounded_below (  )  const [inline]

Determines if this interval is bounded below, regardless of whether it is bounded above or not.

void SPAinterval::debug ( FILE *  fp = debug_file_ptr  )  const

Outputs the details of an interval to the specified file.

Parameters:
fp file pointer.

void SPAinterval::debug_str ( char *  str1  )  const

Concatenates the details of this interval to the given string.

Parameters:
str1 given string.

logical SPAinterval::empty (  )  const [inline]

Determines if this interval is empty.

double SPAinterval::end_pt (  )  const [inline]

Returns the end point of this interval.

Role: This method is meaningful only if the upper end is bounded. If the upper end is not bounded, there is no error.

logical SPAinterval::finite (  )  const [inline]

Determines if this interval is finite; that is, bounded on both ends.

logical SPAinterval::finite_above (  )  const [inline]

Determines if this interval is finite above; that is, bounded at the higher parameter only.

logical SPAinterval::finite_below (  )  const [inline]

Determines if this interval is finite below; that is, bounded at the lower parameter only.

logical SPAinterval::infinite (  )  const [inline]

Determines if this interval is infinite; that is, unbounded on both ends.

double SPAinterval::interpolate ( double  d  )  const

Interpolates within this interval.

Role: This method returns:

(1 - parameter) * low-end + parameter * high-end

for the given parameter. This method is meaningful only if both ends are bounded. If the ends are not bounded, there is no error.

Parameters:
d given parameter value.

double SPAinterval::length (  )  const

Returns the difference between the high and low ends of the interval.

Role: By historical convention, both empty and infinite intervals return negative values (since formerly an infinite parameter range returned an empty interval), so this is retained. For convenient distinction, an empty interval returns exactly -1.0, and an infinite (or semi-infinite) interval returns exactly -2.0.

double SPAinterval::mid_pt (  )  const

Returns the middle point of this interval.

Role: This method is only meaningful if both ends are bounded. If the relevant ends are not bounded, there is no error.

SPAinterval& SPAinterval::negate (  ) 

Negates this interval in place.

SPAinterval& SPAinterval::operator &= ( SPAinterval const &  i  ) 

Updates this interval to be the overlap of itself and the given interval.

Parameters:
i given interval

SPAinterval& SPAinterval::operator*= ( double  d  ) 

Multiplies this interval by a scalar.

Parameters:
d the given scalar value.

SPAinterval& SPAinterval::operator+= ( double  d  )  [inline]

Adds a scalar value to both ends of this interval, shifting this interval by the value.

Parameters:
d shift value.

SPAinterval& SPAinterval::operator+= ( SPAinterval const &  inter  ) 

Adds an interval to this interval.

Parameters:
inter other interval.

SPAinterval& SPAinterval::operator-= ( double  d  )  [inline]

Subtracts a scalar value from both ends of this interval, shifting this interval by the value.

Parameters:
d shift value.

SPAinterval& SPAinterval::operator-= ( SPAinterval const &  inter  ) 

Subtracts an interval from this interval.

Parameters:
inter other interval.

SPAinterval& SPAinterval::operator/= ( double  d  ) 

Divides this interval by a scalar.

Parameters:
d the given scalar value.

logical SPAinterval::operator<< ( SPAinterval const &  i  )  const [inline]

Determines whether this interval is entirely enclosed within the given interval.

Role: The given method returns FALSE if this interval is NULL, TRUE if the given interval is NULL; otherwise, it returns TRUE if low end of this interval exceeds low end of the given interval (less SPAresabs) and high end of this interval is less than high end of the given interval (plus SPAresabs).

Parameters:
i given interval.

logical SPAinterval::operator>> ( SPAinterval const &  inter  )  const

Determines whether the given interval is entirely enclosed within this interval.

Role: This method returns TRUE if this interval is NULL, FALSE if the given interval is NULL; otherwise, it returns TRUE if low end of given interval exceeds low end of this interval (less SPAresabs) and high end of the given interval is less than high end of this interval (plus SPAresabs).

Parameters:
inter given interval.

logical SPAinterval::operator>> ( double  d  )  const

Determines whether a parameter value lies within this interval.

Role: This method returns TRUE if this interval is NULL or if the given parameter value lies within this interval (expanded by SPAresabs at each end).

Parameters:
d given parameter value.

SPAinterval& SPAinterval::operator|= ( SPAinterval const &  i  ) 

Updates this interval to include the given interval.

Parameters:
i given interval

logical SPAinterval::scalar (  )  const [inline]

Determines if this interval is a scalar; that is, if it consists of a single point.

double SPAinterval::start_pt (  )  const [inline]

Returns the start point of this interval.

Role: This method is meaningful only if the lower end is bounded. If the lower end is not bounded, there is no error.

interval_type SPAinterval::type (  )  const [inline]

Returns the type of this interval.

logical SPAinterval::unbounded (  )  const [inline]

Determines if this interval is unbounded; that is, it is either infinite or semi-infinite.

logical SPAinterval::unbounded_above (  )  const [inline]

Determines if this interval is unbounded above, regardless of whether it is bounded below or not.

logical SPAinterval::unbounded_below (  )  const [inline]

Determines if this interval is unbounded below, regardless of whether it is bounded above or not.


Friends And Related Function Documentation

SPAinterval operator & ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Finds the interval of overlap.

Parameters:
i1 first interval.
i2 second interval.

logical operator && ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Determines whether two intervals overlap.

Parameters:
i1 first interval.
i2 second interval.

logical operator!= ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Inequality operator for determining whether two intervals are not identical.

Role: The criteria are strict, so this operator should not be used when arithmetic inequality is intended.

Parameters:
i1 first interval.
i2 second interval.

SPAinterval operator* ( double  d,
SPAinterval const &  i 
) [friend]

Multiplies a scalar by an interval.

Parameters:
d given scalar value.
i given interval.

SPAinterval operator* ( SPAinterval const &  i,
double  d 
) [friend]

Multiplies an interval by a scalar.

Parameters:
i given interval.
d given scalar value.

SPAinterval operator+ ( double  d,
SPAinterval const &  i 
) [friend]

Adds a double and an interval.

Parameters:
d given double.
i given interval.

SPAinterval operator+ ( SPAinterval const &  i,
double  d 
) [friend]

Adds an interval and a double.

Parameters:
i given interval.
d given double.

SPAinterval operator+ ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Adds two intervals together.

Parameters:
inter1 first interval.
inter2 second interval.

SPAinterval operator- ( double  d,
SPAinterval const &  i 
) [friend]

Subtracts an interval from a double.

Parameters:
d given double.
i given interval.

SPAinterval operator- ( SPAinterval const &  i,
double  d 
) [friend]

Subtracts a double from an interval.

Parameters:
i given interval.
d given double.

SPAinterval operator- ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Subtracts two intervals.

Parameters:
i1 first interval.
i2 second interval.

SPAinterval operator- ( SPAinterval const &  i  )  [friend]

Negates an interval.

Parameters:
inter given interval.

SPAinterval operator/ ( SPAinterval const &  i,
double  d 
) [friend]

Divides an interval by a scalar.

Parameters:
i given interval.
d given scalar value.

logical operator< ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i1 first interval.
i2 second interval.

logical operator< ( double  d,
SPAinterval const &  i 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
d given double.
i given interval.

logical operator< ( SPAinterval const &  i,
double  d 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i given interval.
d given double.

logical operator<< ( double  r,
SPAinterval const &  i 
) [friend]

Determines whether the given parameter value lies within the given interval.

Parameters:
r given double.
i given interval.

logical operator<= ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i1 first interval.
i2 second interval.

logical operator<= ( double  d,
SPAinterval const &  i 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
d given double.
i given interval.

logical operator<= ( SPAinterval const &  i,
double  d 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (less than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i given interval.
d given double.

logical operator== ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Equality operator for determining whether two intervals are identical.

Role: The criteria are strict, so this operator should not be used when arithmetic equality is intended.

Parameters:
i1 first interval.
i2 second interval.

logical operator> ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i1 first interval.
i2 second interval.

logical operator> ( double  d,
SPAinterval const &  i 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
d given double.
i given interval.

logical operator> ( SPAinterval const &  i,
double  d 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i given interval.
d given double.

logical operator>= ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i1 first interval.
i2 second interval.

logical operator>= ( double  d,
SPAinterval const &  i 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
d given double.
i given interval.

logical operator>= ( SPAinterval const &  i,
double  d 
) [friend]

Arithmetic comparison.

Role: The meaning in each case is that every number in the first interval bears the given relationship (greater than or equal to) with every number in the second, where a double is treated as an interval containing just that number.

Parameters:
i given interval.
d given double.

SPAinterval operator| ( SPAinterval const &  i1,
SPAinterval const &  i2 
) [friend]

Constructs an interval containing two intervals.

Parameters:
i1 first interval.
i2 second interval.