SPH
|
Object representing a 1D interval of real numbers. More...
#include <Interval.h>
Public Member Functions | |
INLINE | Interval () |
Default construction of an empty interval. More... | |
INLINE | Interval (const Float &lower, const Float &upper) |
Constructs the interval given its lower and upper bound. More... | |
INLINE void | extend (const Float &value) |
Extends the interval to contain given value. More... | |
INLINE void | extend (const Interval &other) |
Extends the interval to contain another interval. More... | |
INLINE bool | contains (const Float &value) const |
Checks whether value is inside the interval. More... | |
INLINE Interval | intersect (const Interval &other) const |
Computes the intersection with another interval. More... | |
INLINE Float | clamp (const Float &value) const |
Clamps the given value by the interval. More... | |
INLINE Float | lower () const |
Returns lower bound of the interval. More... | |
INLINE Float | upper () const |
Returns upper bound of the interval. More... | |
INLINE Float | center () const |
Returns the center of the interval. More... | |
INLINE Float | size () const |
Returns the size of the interval. More... | |
INLINE bool | operator== (const Interval &other) const |
Comparison operator; true if and only if both bounds are equal. More... | |
INLINE bool | operator!= (const Interval &other) const |
Negation of comparison operator. More... | |
INLINE bool | empty () const |
Returns true if the interval is empty (default constructed). More... | |
Static Public Member Functions | |
static Interval | unbounded () |
Returns an unbounded (infinite) interval. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &stream, const Interval &range) |
Object representing a 1D interval of real numbers.
Can also represent one sided [x, infty] or [-infty, x], or even unbounded [-infty, infty] intervals.
Definition at line 17 of file Interval.h.
|
inline |
Default construction of an empty interval.
Any contains() call will return false, extending the interval will result in zero-size interval containing the inserted value.
Definition at line 27 of file Interval.h.
Constructs the interval given its lower and upper bound.
You can use INFTY and -INFTY to create one-sided or unbounded intervals.
Definition at line 34 of file Interval.h.
Returns the center of the interval.
Definition at line 84 of file Interval.h.
Clamps the given value by the interval.
Definition at line 68 of file Interval.h.
Checks whether value is inside the interval.
Definition at line 55 of file Interval.h.
|
inline |
Returns true if the interval is empty (default constructed).
Definition at line 104 of file Interval.h.
Extends the interval to contain given value.
If the value is already inside the interval, nothing changes.
Definition at line 41 of file Interval.h.
Extends the interval to contain another interval.
If the other interval is already inside this interval, nothing changes.
Definition at line 49 of file Interval.h.
Computes the intersection with another interval.
Definition at line 60 of file Interval.h.
Returns lower bound of the interval.
Definition at line 74 of file Interval.h.
Negation of comparison operator.
Definition at line 99 of file Interval.h.
Comparison operator; true if and only if both bounds are equal.
Definition at line 94 of file Interval.h.
Returns the size of the interval.
Definition at line 89 of file Interval.h.
|
inlinestatic |
Returns an unbounded (infinite) interval.
Definition at line 109 of file Interval.h.
Returns upper bound of the interval.
Definition at line 79 of file Interval.h.
|
friend |
Definition at line 23 of file Interval.cpp.