last update 20 Sep 2009 |
#include <cvrInterval.h>
Public Types | |
typedef T | value_type |
typedef int | size_type |
Public Member Functions | |
interval (const T newx=T(), const T newy=T()) | |
template<typename U > | |
interval (const interval< U > &p) | |
template<typename U > | |
interval< T > & | castFrom (const interval< U > &p) |
interval< T > & | set (const T tx, const T ty) |
void | get (T &tx, T &ty) const |
template<typename U > | |
interval< T > & | multiply (const U c) |
template<typename U > | |
interval< T > | operator* (const U c) const |
template<typename U > | |
interval< T > & | multiply (const interval< T > &other, const U c) |
template<typename U > | |
interval< T > & | operator*= (const U c) |
interval< T > & | emultiply (const interval< T > &c) |
interval< T > & | emultiply (const interval< T > &a, const interval< T > &b) |
template<typename U > | |
interval< T > & | divide (const U c) |
template<typename U > | |
interval< T > & | divide (const interval< T > &other, const U c) |
template<typename U > | |
interval< T > | operator/ (const U c) const |
template<typename U > | |
interval< T > & | operator/= (const U c) |
interval< T > & | edivide (const interval< T > &c) |
interval< T > & | edivide (const interval< T > &a, const interval< T > &b) |
interval< T > | operator% (const int c) const |
interval< T > & | join (const interval< T > &p) |
interval< T > & | join (const interval< T > &a, const interval< T > &b) |
interval< T > & | subtract (const interval< T > &p) |
interval< T > & | subtract (const interval< T > &a, const interval< T > &b) |
interval< T > | operator- (const interval< T > &p) const |
interval< T > & | operator-= (const interval< T > &p) |
interval< T > & | copy (const interval< T > &p) |
interval< T > & | operator= (const interval< T > &p) |
bool | operator== (const interval< T > &p) const |
bool | operator!= (const interval< T > &p) const |
T | length () const |
bool | contains (const T val) const |
bool | contains (const interval< T > &val) const |
T | closest (const T val) const |
Access as vector | |
T & | operator[] (const int i) |
const T & | operator[] (const int i) const |
size_type | size () const |
Public Attributes | |
union { | |
value_type data [2] | |
}; | |
value_type | from |
value_type | to |
The template type T will be the one used for each limit value. For example interval<float> uses float for from and to.
This data structure simplifies the manipulation of one dimensional intervals providing simple interfaces for adding, substracting, distance (L2), and more.
There are some alias to shorten the notation:
An inteval with a from
value greater than the to
value is considered as invalid. So, methods which return such configuration can be interpreted as empty intervals.
typedef int cvr::interval< T >::size_type |
Return type of the size() member.
typedef T cvr::interval< T >::value_type |
Used for the template-based interface for pixels as vectors.
cvr::interval< T >::interval | ( | const T | newx = T() , |
|
const T | newy = T() | |||
) | [explicit] |
Default constructor.
cvr::interval< T >::interval | ( | const interval< U > & | p | ) | [inline] |
Copy constructor.
interval<T>& cvr::interval< T >::castFrom | ( | const interval< U > & | p | ) | [inline] |
Copy constructor.
T cvr::interval< T >::closest | ( | const T | val | ) | const [inline] |
bool cvr::interval< T >::contains | ( | const interval< T > & | val | ) | const [inline] |
bool cvr::interval< T >::contains | ( | const T | val | ) | const [inline] |
interval<T>& cvr::interval< T >::copy | ( | const interval< T > & | p | ) | [inline] |
Copy operator.
interval<T>& cvr::interval< T >::divide | ( | const interval< T > & | other, | |
const U | c | |||
) | [inline] |
Divide each component of other other interval<T> with a given factor.
interval<T>& cvr::interval< T >::divide | ( | const U | c | ) | [inline] |
Divide each component of interval<T> with a given factor.
interval<T>& cvr::interval< T >::edivide | ( | const interval< T > & | a, | |
const interval< T > & | b | |||
) | [inline] |
Elementwise division of each component of the intervals.
interval<T>& cvr::interval< T >::edivide | ( | const interval< T > & | c | ) | [inline] |
Elementwise division of each component of the intervals.
interval<T>& cvr::interval< T >::emultiply | ( | const interval< T > & | a, | |
const interval< T > & | b | |||
) | [inline] |
Multiplies elementwise the components of a and b and leave the result here.
interval<T>& cvr::interval< T >::emultiply | ( | const interval< T > & | c | ) | [inline] |
Multiplies elementwise the components of this and the interval c, and leave the result here.
void cvr::interval< T >::get | ( | T & | tx, | |
T & | ty | |||
) | const [inline] |
Get the limit values.
interval<T>& cvr::interval< T >::join | ( | const interval< T > & | a, | |
const interval< T > & | b | |||
) | [inline] |
interval<T>& cvr::interval< T >::join | ( | const interval< T > & | p | ) | [inline] |
T cvr::interval< T >::length | ( | ) | const [inline] |
Length of the interval.
For this method, the intervals are considered closed. This is specially important for integer types, which will return from-to+1, while for floating-point types it just return from-to.
interval<T>& cvr::interval< T >::multiply | ( | const interval< T > & | other, | |
const U | c | |||
) | [inline] |
Multiply the other interval interval<T> with a given scale factor.
The type U has to be compatible with the type T in the sense that they can be multiplied and casted to T. This applies to most build in type like int, float, etc.
interval<T>& cvr::interval< T >::multiply | ( | const U | c | ) | [inline] |
Scale an interval, multiplying each limit by the given scalar.
The type U has to be compatible with the type T in the sense that they can be multiplied and casted to T. This applies to most build in type like int, float, etc.
bool cvr::interval< T >::operator!= | ( | const interval< T > & | p | ) | const [inline] |
Operator !=.
interval<T> cvr::interval< T >::operator% | ( | const int | c | ) | const [inline] |
Modulo c of the integer part of each component of the interval.
interval<T> cvr::interval< T >::operator* | ( | const U | c | ) | const [inline] |
Scale an interval, multiplying each limit by the given scalar.
The type U has to be compatible with the type T in the sense that they can be multiplied and casted to T. This applies to most build in type like int, float, etc.
interval<T>& cvr::interval< T >::operator*= | ( | const U | c | ) | [inline] |
Multiply interval<T> with a given factor.
The type U has to be compatible with the type T in the sense that they can be multiplied and casted to T. This applies to most build in type like int, float, etc.
interval<T> cvr::interval< T >::operator- | ( | const interval< T > & | p | ) | const [inline] |
Operator -.
interval<T>& cvr::interval< T >::operator-= | ( | const interval< T > & | p | ) | [inline] |
Operator -=.
interval<T> cvr::interval< T >::operator/ | ( | const U | c | ) | const [inline] |
Divide each component of interval<T> by a given factor.
interval<T>& cvr::interval< T >::operator/= | ( | const U | c | ) | [inline] |
Divide each component of interval<T> by a given factor.
interval<T>& cvr::interval< T >::operator= | ( | const interval< T > & | p | ) | [inline] |
Operator =.
bool cvr::interval< T >::operator== | ( | const interval< T > & | p | ) | const [inline] |
Operator ==.
const T& cvr::interval< T >::operator[] | ( | const int | i | ) | const [inline] |
T& cvr::interval< T >::operator[] | ( | const int | i | ) | [inline] |
interval<T>& cvr::interval< T >::set | ( | const T | tx, | |
const T | ty | |||
) | [inline] |
Set the coordinate values and return a reference to this interval.
size_type cvr::interval< T >::size | ( | ) | const [inline] |
Used to simulate the vector size.
interval<T>& cvr::interval< T >::subtract | ( | const interval< T > & | a, | |
const interval< T > & | b | |||
) | [inline] |
interval<T>& cvr::interval< T >::subtract | ( | const interval< T > & | p | ) | [inline] |
union { ... } |
Anonymous union to allow the fastes access to the elements as semantic tokes (x and y) and as array as well.
value_type cvr::interval< T >::data[2] |
Array that shares the same memory with from and to.
value_type cvr::interval< T >::from |
From value.
value_type cvr::interval< T >::to |
To value.