42 minBound =
min(minBound, value);
43 maxBound =
max(maxBound, value);
50 minBound =
min(minBound, other.minBound);
51 maxBound =
max(maxBound, other.maxBound);
56 return minBound <= value && value <= maxBound;
62 is.minBound =
max(minBound, other.minBound);
63 is.maxBound =
min(maxBound, other.maxBound);
70 return max(minBound,
min(value, maxBound));
85 return 0.5_f * (minBound + maxBound);
90 return maxBound - minBound;
95 return minBound == other.minBound && maxBound == other.maxBound;
100 return !(*
this == other);
105 return minBound > maxBound;
119 template <
typename T>
121 return T(range.
clamp(v));
128 template <
typename T>
135 const bool zeroDeriv = (v >= range.
upper() && dv > 0._f) || (v <= range.
lower() && dv < 0._f);
136 return {
clamp(v, range), zeroDeriv ? 0._f : dv };
#define SPH_ASSERT(x,...)
#define NOT_IMPLEMENTED
Helper macro marking missing implementation.
Global parameters of the code.
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
INLINE T clamp(const T &v, const Interval &range)
INLINE Pair< Float > clampWithDerivative< Float >(const Float &v, const Float &dv, const Interval &range)
INLINE Pair< T > clampWithDerivative(const T &, const T &, const Interval &)
Returns clamped values and the value of derivative.
constexpr INLINE T max(const T &f1, const T &f2)
NAMESPACE_SPH_BEGIN constexpr INLINE T min(const T &f1, const T &f2)
Minimum & Maximum value.
Additional math routines (with more includes).
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Object representing a 1D interval of real numbers.
INLINE void extend(const Interval &other)
Extends the interval to contain another interval.
INLINE Float lower() const
Returns lower bound of the interval.
INLINE Interval(const Float &lower, const Float &upper)
Constructs the interval given its lower and upper bound.
INLINE bool operator==(const Interval &other) const
Comparison operator; true if and only if both bounds are equal.
INLINE Interval()
Default construction of an empty interval.
INLINE void extend(const Float &value)
Extends the interval to contain given value.
INLINE Float upper() const
Returns upper bound of the interval.
friend std::ostream & operator<<(std::ostream &stream, const Interval &range)
INLINE bool operator!=(const Interval &other) const
Negation of comparison operator.
static Interval unbounded()
Returns an unbounded (infinite) interval.
INLINE Float center() const
Returns the center of the interval.
INLINE Float size() const
Returns the size of the interval.
INLINE bool contains(const Float &value) const
Checks whether value is inside the interval.
INLINE bool empty() const
Returns true if the interval is empty (default constructed).
INLINE Float clamp(const Float &value) const
Clamps the given value by the interval.
INLINE Interval intersect(const Interval &other) const
Computes the intersection with another interval.
Array with fixed number of allocated elements.