last update 20 Sep 2009 |
#include <cvrPoint.h>
Public Types | |
typedef T | value_type |
typedef int | size_type |
Public Member Functions | |
point (const T newx=T(), const T newy=T()) | |
template<typename U > | |
point (const point< U > &p) | |
template<typename U > | |
point< T > & | castFrom (const point< U > &p) |
point< T > & | set (const T tx, const T ty) |
void | get (T &tx, T &ty) const |
T | distanceSqr (const point< T > &c) const |
T | absSqr () const |
T | dot (const point< T > &p) const |
template<typename U > | |
point< T > & | multiply (const U c) |
template<typename U > | |
point< T > | operator* (const U c) const |
template<typename U > | |
point< T > & | multiply (const point< T > &other, const U c) |
template<typename U > | |
point< T > & | operator*= (const U c) |
point< T > | operator* (const point< T > &c) const |
point< T > & | operator*= (const point< T > &c) |
point< T > & | emultiply (const point< T > &c) |
point< T > & | emultiply (const point< T > &a, const point< T > &b) |
template<typename U > | |
point< T > & | divide (const U c) |
template<typename U > | |
point< T > & | divide (const point< T > &other, const U c) |
template<typename U > | |
point< T > | operator/ (const U c) const |
template<typename U > | |
point< T > & | operator/= (const U c) |
point< T > | operator/ (const point< T > &c) const |
point< T > & | operator/= (const point< T > &c) |
point< T > & | edivide (const point< T > &c) |
point< T > & | edivide (const point< T > &a, const point< T > &b) |
point< T > | operator% (const int c) const |
point< T > & | add (const point< T > &p) |
point< T > & | add (const point< T > &a, const point< T > &b) |
point< T > | operator+ (const point< T > &p) const |
point< T > & | operator+= (const point< T > &p) |
point< T > & | subtract (const point< T > &p) |
point< T > & | subtract (const point< T > &a, const point< T > &b) |
point< T > | operator- (const point< T > &p) const |
point< T > | operator- () const |
point< T > & | operator-= (const point< T > &p) |
point< T > & | copy (const point< T > &p) |
point< T > & | operator= (const point< T > &p) |
bool | operator== (const point< T > &p) const |
bool | operator!= (const point< T > &p) const |
bool | operator< (const point< T > &p) const |
bool | operator> (const point< T > &p) const |
Access as vector | |
T & | operator[] (const int i) |
const T & | operator[] (const int i) const |
size_type | size () const |
The template type T will be the one used for each coordinate. For example point<float> uses float for x and y.
This data structure simplifies the manipulation of 2D points providing simple interfaces for adding, substracting, distance (L2), and more.
There are some alias to shorten the notation:
typedef int cvr::point< T >::size_type |
Return type of the size() member.
typedef T cvr::point< T >::value_type |
Used for the template-based interface for pixels as vectors.
cvr::point< T >::point | ( | const T | newx = T() , |
|
const T | newy = T() | |||
) | [explicit] |
Default constructor.
Copy constructor.
T cvr::point< T >::absSqr | ( | ) | const [inline] |
Return the square of the magnitude of the point.
point<T>& cvr::point< T >::add | ( | const point< T > & | a, | |
const point< T > & | b | |||
) | [inline] |
point<T>& cvr::point< T >::add | ( | const point< T > & | p | ) | [inline] |
point<T>& cvr::point< T >::castFrom | ( | const point< U > & | p | ) | [inline] |
Copy constructor.
point<T>& cvr::point< T >::copy | ( | const point< T > & | p | ) | [inline] |
Copy operator.
T cvr::point< T >::distanceSqr | ( | const point< T > & | c | ) | const [inline] |
Calculate square of distance to the point c.
If you need the Euclidean distance just call sqrt(distanceSqr).
Referenced by cvr::euclideanDistance(), and cvr::euclideanDistanceSqr().
point<T>& cvr::point< T >::divide | ( | const point< T > & | other, | |
const U | c | |||
) | [inline] |
Divide each component of other other point<T> with a given factor.
Divide each component of point<T> with a given factor.
T cvr::point< T >::dot | ( | const point< T > & | p | ) | const [inline] |
point<T>& cvr::point< T >::edivide | ( | const point< T > & | a, | |
const point< T > & | b | |||
) | [inline] |
Elementwise division of each component of the points.
point<T>& cvr::point< T >::edivide | ( | const point< T > & | c | ) | [inline] |
Elementwise division of each component of the points.
point<T>& cvr::point< T >::emultiply | ( | const point< T > & | a, | |
const point< T > & | b | |||
) | [inline] |
Multiplies elementwise the components of a and b and leave the result here.
point<T>& cvr::point< T >::emultiply | ( | const point< T > & | c | ) | [inline] |
Multiplies elementwise the components of this and the point c, and leave the result here.
void cvr::point< T >::get | ( | T & | tx, | |
T & | ty | |||
) | const [inline] |
Get the coordinate values.
point<T>& cvr::point< T >::multiply | ( | const point< T > & | other, | |
const U | c | |||
) | [inline] |
Multiply the other point point<T> with a given factor.
point<T>& cvr::point< T >::multiply | ( | const U | c | ) | [inline] |
Multiply point<T> with a given factor.
bool cvr::point< T >::operator!= | ( | const point< T > & | p | ) | const [inline] |
Operator !=.
point<T> cvr::point< T >::operator% | ( | const int | c | ) | const [inline] |
Modulo c of the integer part of each component of the point.
point<T> cvr::point< T >::operator* | ( | const point< T > & | c | ) | const [inline] |
Multiplies elementwise the components of this and the point c.
point<T> cvr::point< T >::operator* | ( | const U | c | ) | const [inline] |
Multiply point<T> with a given factor.
point<T>& cvr::point< T >::operator*= | ( | const point< T > & | c | ) | [inline] |
Multiplies elementwise the components of this and the point c.
point<T>& cvr::point< T >::operator*= | ( | const U | c | ) | [inline] |
Multiply point<T> with a given factor.
point<T> cvr::point< T >::operator+ | ( | const point< T > & | p | ) | const [inline] |
point<T>& cvr::point< T >::operator+= | ( | const point< T > & | p | ) | [inline] |
Operator += is an alias for add().
point<T> cvr::point< T >::operator- | ( | ) | const [inline] |
Operator -.
point<T> cvr::point< T >::operator- | ( | const point< T > & | p | ) | const [inline] |
Operator -.
point<T>& cvr::point< T >::operator-= | ( | const point< T > & | p | ) | [inline] |
Operator -=.
point<T> cvr::point< T >::operator/ | ( | const point< T > & | c | ) | const [inline] |
Elementwise division of each component of the points.
point<T> cvr::point< T >::operator/ | ( | const U | c | ) | const [inline] |
Divide each component of point<T> by a given factor.
point<T>& cvr::point< T >::operator/= | ( | const point< T > & | c | ) | [inline] |
Elementwise division of each component of the points.
point<T>& cvr::point< T >::operator/= | ( | const U | c | ) | [inline] |
Divide each component of point<T> by a given factor.
bool cvr::point< T >::operator< | ( | const point< T > & | p | ) | const [inline] |
point<T>& cvr::point< T >::operator= | ( | const point< T > & | p | ) | [inline] |
Operator =.
bool cvr::point< T >::operator== | ( | const point< T > & | p | ) | const [inline] |
Operator ==.
bool cvr::point< T >::operator> | ( | const point< T > & | p | ) | const [inline] |
const T& cvr::point< T >::operator[] | ( | const int | i | ) | const [inline] |
T& cvr::point< T >::operator[] | ( | const int | i | ) | [inline] |
point<T>& cvr::point< T >::set | ( | const T | tx, | |
const T | ty | |||
) | [inline] |
Set the coordinate values and return a reference to this point.
size_type cvr::point< T >::size | ( | ) | const [inline] |
Used to simulate the vector size.
point<T>& cvr::point< T >::subtract | ( | const point< T > & | a, | |
const point< T > & | b | |||
) | [inline] |
point<T>& cvr::point< T >::subtract | ( | const point< T > & | p | ) | [inline] |
value_type cvr::point< T >::data[2] |
Array that shares the same memory with x and y.
value_type cvr::point< T >::x |
value_type cvr::point< T >::y |