Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Interval< Type > Class Template Reference

#include <Interval.h>

List of all members.


Detailed Description

template<class Type>
class Interval< Type >

An interval arithmetic class.

Interval arithmetic is a method for representing ranges of numbers. For example, given a function f(x) = 3x, then we have f(4) = 12. But if we only know the range of numbers as the input of f, then we want to (over) estimate the range of possible results. Hence f([3,5]) = [9,15] which means if f is evaluated on any value between 3 and 5 inclusive, then its result will be something between 9 and 15. We don't know what the answer is, but we know what the answer can not be less than 9 nor greater than 15.

Intervals are represented in this library using the member variables low and high. If DEBUG is def'ed, then intervals are checked that low < high. When setting an interval, only use the constructors or setInterval since these check the order (when DEBUG def'ed).

For more information on interval analysis for graphics, see:

Here's some interesting information about squared() and pow(). Take for example the interval [-10,5]. If you were to multiply [-10,5]*[-10,5], you would use the rule for interval multiplication [a,b]*[c,d] = [min(ac,ad,bc,bd),max(ac,ad,bc,bd)] to get [-50,100]. This is true because in this case we are calculating the product of any value between -10 and 5 and another value between -10 and 5. On the other hand, if we calculate [-10,5]^2 (squared), then we get [0,100]. This is because we are multiplying a value between -10 and 5 by itself. Thus we know that the value can never be negative. A similar argument holds for the pow() function for even power values.

Definition at line 79 of file Interval.h.

Public Member Functions

Constructors @{
 Interval (void)
 Default constructor.

 Interval (Type a)
 Construct an interval using a single number as low and high.

 Interval (Type low, Type high)
 Construct the interval [low,high].

Attribute Access and Assignment @{
Infinite< Type > low (void) const
 Returns smallest value the interval represents.

Infinite< Type > high (void) const
 Returns largest value the interval represents.

 operator Type () const
 Type conversion.

void setInterval (Type low, Type high)
 Sets the interval to [l,h].

Checks @{
virtual void print () const
 Basic print out of the interval.

virtual void error () const
 Error function can be called when low > high.

void check () const
 Checks if low < high.

int thin () const
 Checks if interval is zero width.

Unary Operators @{
Infinite< Type > width () const
 Return width of interval.

Infinite< Type > center () const
 Return center of interval.

Interval< Type > exp () const
 Return e to the interval power.

Interval< Type > squared () const
 Squares the interval. Returns either endpoint or the apex of parabola.

Interval< Type > cubed () const
 Cubes the interval.

Interval< Type > log () const
 Returns the natural log (ln) of the interval.

Interval< Type > pow (Interval< Type > n) const
 Raises an interval to the power of another interval.

Interval< Type > pow (int n) const
 Integer exponents Determines if i is even or odd, and returns a tight interval in either case.

Interval< Type > sqrt () const
 Square root of a non-negative interval.

Interval< Type > fabs () const
 Returns absolute value of interval.

Interval< Type > operator- () const
 Negates the interval (unary negation).

Binary Operators @{
Interval< Type > intersection (Interval< Type > &b)
 Intesection of intervals.

Interval< Type > unionWith (Interval< Type > &b)
 Union of intervals = smallest interval containing both intervals.

Interval< Type > & operator+= (const Interval< Type > &b)
 Add interval to me.

Interval< Type > & operator+= (const Type &b)
 Add a basic Type to me - promotes Type to Interval.

Interval< Type > & operator-= (const Interval< Type > &b)
 Subtract interval from me.

Interval< Type > & operator-= (const Type &b)
 Subtract a base Type from me - promotes Type to Interval.

Interval< Type > & operator *= (const Interval< Type > &b)
 Multiply interval times me.

Interval< Type > & operator *= (const Type &b)
 Multiply a base Type times me - promotes Type to Interval.

Interval< Type > & operator/= (const Interval< Type > &b)
 Divide me by interval.

Interval< Type > & operator/= (const Type &b)
 Divide me by a base Type - promotes base Type to Interval.

Conditions @{
int contains (const Interval< Type > &a) const
 Contains is True if a is a subset of me.

int containsProper (const Interval< Type > &a) const
 ContainsProper is True if a is a proper subset of me.

int overlaps (const Interval< Type > &a) const
 Overlaps is True if a intersects me.

int disjoint (const Interval< Type > &a) const
 Disjoint is True if a does not intersect me.

int isZero () const
 Checks if the interval is pretty much [0,0].

int isPositive () const
 Positive is True only if interval entirely positive.

int isNegative () const
 isNegative is True only if interval entirely negative.

int isNonnegative () const
 isNonnegative is True only if interval entirely positive.

int isNonpositive () const
 isNonpositive is True only if interval entirely negative.

int isMixed () const
 True only if interval has positive and negative elements.


Private Member Functions

void init (Type low, Type high)
 Convenient initialization routine called by the constructors.


Private Attributes

Infinite< Type > _low
 Holds smallest value the interval represents.

Infinite< Type > _high
 Holds largest value the interval represents.


Constructor & Destructor Documentation

template<class Type>
Interval< Type >::Interval void   ) 
 

Default constructor.

Definition at line 82 of file Interval.cpp.

References Interval< Type >::init().

Referenced by Interval< Type >::operator-=(), and Interval< Type >::operator/=().

template<class Type>
Interval< Type >::Interval Type  a  ) 
 

Construct an interval using a single number as low and high.

Definition at line 89 of file Interval.cpp.

References Interval< Type >::init().

template<class Type>
Interval< Type >::Interval Type  low,
Type  high
 

Construct the interval [low,high].

Definition at line 96 of file Interval.cpp.

References Interval< Type >::init().


Member Function Documentation

template<class Type>
Infinite< Type > Interval< Type >::center  )  const
 

Return center of interval.

Definition at line 171 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by Segment::grad(), Interval< Type >::operator Type(), and Segment::proc().

template<class Type>
void Interval< Type >::check  )  const
 

Checks if low < high.

Definition at line 142 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::error().

Referenced by IDinf(), Interval< Type >::init(), Interval< Type >::operator *=(), Interval< Type >::operator+=(), and Interval< Type >::setInterval().

template<class Type>
int Interval< Type >::contains const Interval< Type > &  a  )  const
 

Contains is True if a is a subset of me.

Definition at line 522 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by IDinf(), and Interval< Type >::isZero().

template<class Type>
int Interval< Type >::containsProper const Interval< Type > &  a  )  const
 

ContainsProper is True if a is a proper subset of me.

Definition at line 529 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
Interval< Type > Interval< Type >::cubed  )  const
 

Cubes the interval.

Definition at line 202 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
int Interval< Type >::disjoint const Interval< Type > &  a  )  const
 

Disjoint is True if a does not intersect me.

Definition at line 543 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
void Interval< Type >::error  )  const [virtual]
 

Error function can be called when low > high.

Definition at line 135 of file Interval.cpp.

Referenced by Interval< Type >::check().

template<class Type>
Interval< Type > Interval< Type >::exp  )  const
 

Return e to the interval power.

Definition at line 181 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by Blinn::kernel(), and Interval< Type >::pow().

template<class Type>
Interval< Type > Interval< Type >::fabs  )  const
 

Returns absolute value of interval.

Definition at line 358 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, and IABS_MAX.

template<class Type>
Infinite< Type > Interval< Type >::high void   )  const
 

Returns largest value the interval represents.

Definition at line 110 of file Interval.cpp.

References Interval< Type >::_high.

Referenced by IDinf(), Interval< Type >::operator/=(), operator>(), operator>=(), and Interval< Type >::pow().

template<class Type>
void Interval< Type >::init Type  low,
Type  high
[private]
 

Convenient initialization routine called by the constructors.

Definition at line 69 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::check(), and findEta().

Referenced by Interval< Type >::Interval().

template<class Type>
Interval< Type > Interval< Type >::intersection Interval< Type > &  b  ) 
 

Intesection of intervals.

Note:
Undefined (low > high) if intervals do not overlap.

Definition at line 368 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
int Interval< Type >::isMixed  )  const
 

True only if interval has positive and negative elements.

Note:
[0,0] is not mixed.

Definition at line 580 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by IDinf(), and Interval< Type >::operator/=().

template<class Type>
int Interval< Type >::isNegative  )  const
 

isNegative is True only if interval entirely negative.

Definition at line 557 of file Interval.cpp.

References Interval< Type >::_high.

Referenced by IDinf(), NewtonDegenerate::NewtonSubdivisionBreak(), Interval< Type >::pow(), and Interval< Type >::squared().

template<class Type>
int Interval< Type >::isNonnegative  )  const
 

isNonnegative is True only if interval entirely positive.

Definition at line 564 of file Interval.cpp.

References Interval< Type >::_low.

Referenced by Interval< Type >::pow(), Interval< Type >::sqrt(), and Interval< Type >::squared().

template<class Type>
int Interval< Type >::isNonpositive  )  const
 

isNonpositive is True only if interval entirely negative.

Definition at line 571 of file Interval.cpp.

References Interval< Type >::_high.

template<class Type>
int Interval< Type >::isPositive  )  const
 

Positive is True only if interval entirely positive.

Definition at line 550 of file Interval.cpp.

References Interval< Type >::_low.

Referenced by IDinf(), and NewtonDegenerate::NewtonSubdivisionBreak().

template<class Type>
int Interval< Type >::isZero  )  const
 

Checks if the interval is pretty much [0,0].

Definition at line 157 of file Interval.cpp.

References Interval< Type >::contains(), and Interval< Type >::thin().

Referenced by Sphere::grad(), and Sphere::hess().

template<class Type>
Interval< Type > Interval< Type >::log  )  const
 

Returns the natural log (ln) of the interval.

Definition at line 214 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, ROUNDDOWN, ROUNDUP, and Interval< Type >::setInterval().

Referenced by Interval< Type >::pow().

template<class Type>
Infinite< Type > Interval< Type >::low void   )  const
 

Returns smallest value the interval represents.

Definition at line 103 of file Interval.cpp.

References Interval< Type >::_low.

Referenced by IDinf(), Interval< Type >::operator/=(), operator==(), operator>(), operator>=(), and Interval< Type >::pow().

template<class Type>
Interval< Type > & Interval< Type >::operator *= const Type &  b  ) 
 

Multiply a base Type times me - promotes Type to Interval.

Definition at line 494 of file Interval.cpp.

template<class Type>
Interval< Type > & Interval< Type >::operator *= const Interval< Type > &  b  ) 
 

Multiply interval times me.

Definition at line 415 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check().

template<class Type>
Interval< Type >::operator Type  )  const [inline]
 

Type conversion.

Definition at line 97 of file Interval.h.

References Interval< Type >::center().

template<class Type>
Interval< Type > & Interval< Type >::operator+= const Type &  b  ) 
 

Add a basic Type to me - promotes Type to Interval.

Definition at line 394 of file Interval.cpp.

template<class Type>
Interval< Type > & Interval< Type >::operator+= const Interval< Type > &  b  ) 
 

Add interval to me.

Definition at line 382 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check().

template<class Type>
Interval< Type > Interval< Type >::operator-  )  const
 

Negates the interval (unary negation).

Definition at line 349 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
Interval< Type > & Interval< Type >::operator-= const Type &  b  ) 
 

Subtract a base Type from me - promotes Type to Interval.

Definition at line 408 of file Interval.cpp.

References Interval< Type >::Interval().

template<class Type>
Interval< Type > & Interval< Type >::operator-= const Interval< Type > &  b  ) 
 

Subtract interval from me.

Definition at line 401 of file Interval.cpp.

template<class Type>
Interval< Type > & Interval< Type >::operator/= const Type &  b  ) 
 

Divide me by a base Type - promotes base Type to Interval.

Definition at line 515 of file Interval.cpp.

References Interval< Type >::Interval().

template<class Type>
Interval< Type > & Interval< Type >::operator/= const Interval< Type > &  b  ) 
 

Divide me by interval.

Bombs out if b.low() or b.high() NearZero, use IDinf instead.

Definition at line 503 of file Interval.cpp.

References Interval< Type >::high(), Interval< Type >::isMixed(), and Interval< Type >::low().

template<class Type>
int Interval< Type >::overlaps const Interval< Type > &  a  )  const
 

Overlaps is True if a intersects me.

Definition at line 536 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by AUnion::indomain(), and operator==().

template<class Type>
Interval< Type > Interval< Type >::pow int  n  )  const
 

Integer exponents Determines if i is even or odd, and returns a tight interval in either case.

Note:
Use this whenever possible instead of multiplying intervals times themselves.

Definition at line 287 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNegative(), and Interval< Type >::isNonnegative().

template<class Type>
Interval< Type > Interval< Type >::pow Interval< Type >  n  )  const
 

Raises an interval to the power of another interval.

Definition at line 237 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::exp(), Interval< Type >::high(), Interval< Type >::log(), Interval< Type >::low(), Infinite< Type >::max(), and Interval< Type >::setInterval().

Referenced by RFunction::h(), Sphere::hess(), RFunction::hf(), RFunction::hff(), RFunction::hfg(), RFunction::hg(), and RFunction::hgg().

template<class Type>
void Interval< Type >::print  )  const [virtual]
 

Basic print out of the interval.

Definition at line 128 of file Interval.cpp.

template<class Type>
void Interval< Type >::setInterval Type  low,
Type  high
 

Sets the interval to [l,h].

Definition at line 117 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, and Interval< Type >::check().

Referenced by Interval< Type >::log(), Interval< Type >::pow(), and Interval< Type >::sqrt().

template<class Type>
Interval< Type > Interval< Type >::sqrt  )  const
 

Square root of a non-negative interval.

Note:
If the interval in question is NOT non-negative, the square root should really return something like an imaginary number, but since we don't deal with that, it simply returns a "default" interval and print out an error message.

Definition at line 333 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNonnegative(), and Interval< Type >::setInterval().

Referenced by Sphere::grad(), Sphere::hess(), Box< Float >::length(), and Segment::proc().

template<class Type>
Interval< Type > Interval< Type >::squared  )  const
 

Squares the interval. Returns either endpoint or the apex of parabola.

Definition at line 188 of file Interval.cpp.

References Interval< Type >::_high, Interval< Type >::_low, Interval< Type >::isNegative(), and Interval< Type >::isNonnegative().

Referenced by RFunction::h(), ASubtraction::h(), AIntersection::h(), RFunction::hf(), ASubtraction::hf(), AIntersection::hf(), RFunction::hff(), ASubtraction::hff(), AIntersection::hff(), RFunction::hfg(), RFunction::hg(), ASubtraction::hg(), AIntersection::hg(), RFunction::hgg(), ASubtraction::hgg(), and AIntersection::hgg().

template<class Type>
int Interval< Type >::thin  )  const
 

Checks if interval is zero width.

Definition at line 150 of file Interval.cpp.

References Interval< Type >::width().

Referenced by Interval< Type >::isZero(), and operator==().

template<class Type>
Interval< Type > Interval< Type >::unionWith Interval< Type > &  b  ) 
 

Union of intervals = smallest interval containing both intervals.

Definition at line 375 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

template<class Type>
Infinite< Type > Interval< Type >::width  )  const
 

Return width of interval.

Definition at line 164 of file Interval.cpp.

References Interval< Type >::_high, and Interval< Type >::_low.

Referenced by Interval< Type >::thin().


Member Data Documentation

template<class Type>
Infinite<Type> Interval< Type >::_high [private]
 

Holds largest value the interval represents.

Definition at line 83 of file Interval.h.

Referenced by Interval< Type >::center(), Interval< Type >::check(), Interval< Type >::contains(), Interval< Type >::containsProper(), Interval< Type >::cubed(), Interval< Type >::disjoint(), Interval< Type >::exp(), Interval< Type >::fabs(), Interval< Type >::high(), Interval< Type >::init(), Interval< Type >::intersection(), Interval< Type >::isMixed(), Interval< Type >::isNegative(), Interval< Type >::isNonpositive(), Interval< Type >::log(), Interval< Type >::operator *=(), Interval< Type >::operator+=(), Interval< Type >::operator-(), Interval< Type >::overlaps(), Interval< Type >::pow(), Interval< Type >::setInterval(), Interval< Type >::sqrt(), Interval< Type >::squared(), Interval< Type >::unionWith(), and Interval< Type >::width().

template<class Type>
Infinite<Type> Interval< Type >::_low [private]
 

Holds smallest value the interval represents.

Definition at line 82 of file Interval.h.

Referenced by Interval< Type >::center(), Interval< Type >::check(), Interval< Type >::contains(), Interval< Type >::containsProper(), Interval< Type >::cubed(), Interval< Type >::disjoint(), Interval< Type >::exp(), Interval< Type >::fabs(), Interval< Type >::init(), Interval< Type >::intersection(), Interval< Type >::isMixed(), Interval< Type >::isNonnegative(), Interval< Type >::isPositive(), Interval< Type >::log(), Interval< Type >::low(), Interval< Type >::operator *=(), Interval< Type >::operator+=(), Interval< Type >::operator-(), Interval< Type >::overlaps(), Interval< Type >::pow(), Interval< Type >::setInterval(), Interval< Type >::sqrt(), Interval< Type >::squared(), Interval< Type >::unionWith(), and Interval< Type >::width().


The documentation for this class was generated from the following files:
Generated on Mon Jun 28 15:02:24 2004 for Advanced Surface Library by doxygen 1.3.4