Interval¶
#include <Imath/ImathInterval.h>
The Interval class template represents a scalar interval, with
predefined typedefs for short, int, float, and double.
An Interval is essentially a Box<T> that allows T to be a
scalar.
Example:
#include <Imath/ImathInterval.h>
void
interval_example()
{
Imath::Intervalf v;
assert (v.isEmpty());
assert (!v.hasVolume());
assert (!v.isInfinite());
v.extendBy (1.0f);
assert (!v.isEmpty());
v.extendBy (2.0f);
assert (v.hasVolume());
assert (v.intersects (1.5f));
}
-
template<class
T>
classImath::Interval¶ An Interval has a min and a max and some miscellaneous functions.
It is basically a Box<T> that allows T to be a scalar.
Direct access to bounds
Constructors
-
inline constexpr
Interval() noexcept¶ Initialize to the empty interval.
Comparison
Manipulation
-
inline void
makeEmpty() noexcept¶ Set the interval to be empty.
An interval is empty if the minimum is greater than the maximum.
-
inline void
extendBy(const Interval<T> &interval) noexcept¶ Extend the interval to include the given interval.
-
inline void
makeInfinite() noexcept¶ Make the interval include the entire range of the base type.
Query
-
inline constexpr T
size() const noexcept¶ Return the size of the interval. The size is (max-min). An empty box has a size of 0.
-
inline constexpr T
center() const noexcept¶ Return the center of the interval.
The center is defined as (max+min)/2. The center of an empty interval is undefined.
-
inline constexpr bool
intersects(const T &point) const noexcept¶ Return true if the given point is inside the interval, false otherwise.
-
inline constexpr bool
intersects(const Interval<T> &interval) const noexcept¶ Return true if the given interval is inside the interval, false otherwise.
-
inline constexpr bool
isEmpty() const noexcept¶ Return true if the interval is empty, false otherwise.
An empty interval’s minimum is greater than its maximum.
-
inline constexpr bool
hasVolume() const noexcept¶ Return true if the interval is larger than a single point, false otherwise.
-
inline constexpr bool
isInfinite() const noexcept¶ Return true if the interval contains all points, false otherwise.
An infinite box has a mimimum of
numeric_limits<T>::lowest()and a maximum ofnumeric_limits<T>::max()
-
inline constexpr