3 #include <cgv/type/traits/min.h>
4 #include <cgv/type/traits/max.h>
39 interval(
bool) : lb(type::traits::min_fct<T>::get_value()), ub(type::traits::max_fct<T>::get_value()) {}
43 interval(
const T& _lb,
const T& _ub) : lb(std::min(_lb,_ub)), ub(std::max(_lb,_ub)) {}
47 void clear() { ub = 0; lb = 1; }
49 bool contains(
const T& v)
const {
return lb <= v && v <= ub; }
179 return !(*
this == I);
193 template <
typename T>
inline interval<T> operator + (
const T& s,
const interval<T>& I) {
return I+s; }
194 template <
typename T>
inline interval<T> operator - (
const T& s,
const interval<T>& I) {
return -I+s; }
195 template <
typename T>
inline interval<T> operator * (
const T& s,
const interval<T>& I) {
return I*s; }
196 template <
typename T>
inline interval<T> operator / (
const T& s,
const interval<T>& I) {
return interval<T>(s,s)/I; }
198 template <
typename T>
199 std::ostream&
operator << (std::ostream& os,
const interval<T>& I) {
200 return os <<
'[' << I.get_lower_bound() <<
',' << I.get_upper_bound() <<
']';
Definition: interval.h:26
const T & get_upper_bound() const
return the upper bound
Definition: interval.h:57
bool operator!=(const interval< T > &I) const
check for inequality of two intervals
Definition: interval.h:178
interval< T > & operator/=(const T &s)
divide the interval
Definition: interval.h:106
interval< T > & extend(const T &v0, const T &v1, const T &v2, const T &v3)
extend by four values
Definition: interval.h:91
interval< T > & intersect(const interval< T > &I)
set interval to intersection with given interval and return reference to this interval
Definition: interval.h:63
interval< T > operator-() const
unary minus operator reflects interval at zero value
Definition: interval.h:151
bool contains(const T &v) const
check if given value is contained in interval
Definition: interval.h:49
T get_size() const
return the size of the interval
Definition: interval.h:61
interval< T > & operator+=(const T &s)
right shift interval by adding scalar to both bounds
Definition: interval.h:110
interval< T > operator*(const T &s) const
return scaled the interval
Definition: interval.h:104
interval< T > & operator-=(const T &s)
left shift interval by subtracting scalar from both bounds
Definition: interval.h:114
bool operator>(const interval< T > &I) const
only returns true if both intervals are not empty and the operator holds for all values in both inter...
Definition: interval.h:186
interval(const T &_lb, const T &_ub)
contruct interval from bounds, sort bounds if necessary. To construct empty interval call the standar...
Definition: interval.h:43
interval< T > & extension(const T &v)
return extension of interval that it includes the given value
Definition: interval.h:81
bool is_empty() const
check if interval is empty
Definition: interval.h:45
std::ostream & operator<<(std::ostream &out, const diag_mat< T > &m)
output of a diagonal matrix onto an ostream
Definition: diag_mat.h:442
interval< T > & extension(const interval< T > &J)
return extension of interval that it includes the given interval
Definition: interval.h:96
const T & get_lower_bound() const
return the lower bound
Definition: interval.h:55
interval()
construct empty interval
Definition: interval.h:33
interval< T > operator+(const T &s) const
return right shifted interval
Definition: interval.h:112
interval(const interval< T > &I)
copy constructor
Definition: interval.h:41
bool operator<(const interval< T > &I) const
only returns true if both intervals are not empty and the operator holds for all values in both inter...
Definition: interval.h:182
void set_lower_bound(const T &_lb)
set the lower bound
Definition: interval.h:51
interval< T > & operator*=(const T &s)
scale the interval
Definition: interval.h:102
interval< T > intersection(const interval< T > &I) const
return intersection interval
Definition: interval.h:69
bool operator==(const interval< T > &I) const
check for equality of two intervals
Definition: interval.h:173
interval< T > & extend(const interval< T > &I)
extend interval such that it includes the given interval
Definition: interval.h:83
interval< T > & extend(const T &v)
extend interval such that it includes the given value
Definition: interval.h:71
void clear()
set to empty interval
Definition: interval.h:47
the cgv namespace
Definition: vr_calib.cxx:9
interval(bool)
Definition: interval.h:39
interval< T > operator/(const T &s) const
return divided the interval
Definition: interval.h:108
void set_upper_bound(const T &_ub)
set the upper bound
Definition: interval.h:53
T get_center() const
return the center value, which is only valid if the interval is not empty
Definition: interval.h:59