CVR-Lib last update 20 Sep 2009

cvr::point< T > Class Template Reference
[Geometry Data Structures]

Two dimensional point, containing the coordinates x, y. More...

#include <cvrPoint.h>

Inheritance diagram for cvr::point< T >:

Inheritance graph
[legend]

List of all members.

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
distanceSqr (const point< T > &c) const
absSqr () const
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


Detailed Description

template<typename T>
class cvr::point< T >

Two dimensional point, containing the coordinates x, y.

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:


Member Typedef Documentation

template<typename T>
typedef int cvr::point< T >::size_type

Return type of the size() member.

template<typename T>
typedef T cvr::point< T >::value_type

Used for the template-based interface for pixels as vectors.


Constructor & Destructor Documentation

template<typename T>
cvr::point< T >::point ( const T  newx = T(),
const T  newy = T() 
) [explicit]

Default constructor.

template<typename T>
template<typename U >
cvr::point< T >::point ( const point< U > &  p  )  [inline]

Copy constructor.


Member Function Documentation

template<typename T>
T cvr::point< T >::absSqr (  )  const [inline]

Return the square of the magnitude of the point.

template<typename T>
point<T>& cvr::point< T >::add ( const point< T > &  a,
const point< T > &  b 
) [inline]

Add the two other points and leave the result here.

Parameters:
a first point to be added
b second point to be added
Returns:
a reference to this point, which will contain a+b

template<typename T>
point<T>& cvr::point< T >::add ( const point< T > &  p  )  [inline]

Add given point to this point and leave the result here.

Parameters:
p the other point to be added to this one
Returns:
a reference to this point

template<typename T>
template<typename U >
point<T>& cvr::point< T >::castFrom ( const point< U > &  p  )  [inline]

Copy constructor.

template<typename T>
point<T>& cvr::point< T >::copy ( const point< T > &  p  )  [inline]

Copy operator.

template<typename T>
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().

template<typename T>
template<typename U >
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.

template<typename T>
template<typename U >
point<T>& cvr::point< T >::divide ( const U  c  )  [inline]

Divide each component of point<T> with a given factor.

template<typename T>
T cvr::point< T >::dot ( const point< T > &  p  )  const [inline]

Dot product with another point.

Returns:
this->x*p.x + this->y*p.y.

template<typename T>
point<T>& cvr::point< T >::edivide ( const point< T > &  a,
const point< T > &  b 
) [inline]

Elementwise division of each component of the points.

template<typename T>
point<T>& cvr::point< T >::edivide ( const point< T > &  c  )  [inline]

Elementwise division of each component of the points.

template<typename T>
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.

template<typename T>
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.

template<typename T>
void cvr::point< T >::get ( T &  tx,
T &  ty 
) const [inline]

Get the coordinate values.

template<typename T>
template<typename U >
point<T>& cvr::point< T >::multiply ( const point< T > &  other,
const U  c 
) [inline]

Multiply the other point point<T> with a given factor.

template<typename T>
template<typename U >
point<T>& cvr::point< T >::multiply ( const U  c  )  [inline]

Multiply point<T> with a given factor.

template<typename T>
bool cvr::point< T >::operator!= ( const point< T > &  p  )  const [inline]

Operator !=.

template<typename T>
point<T> cvr::point< T >::operator% ( const int  c  )  const [inline]

Modulo c of the integer part of each component of the point.

template<typename T>
point<T> cvr::point< T >::operator* ( const point< T > &  c  )  const [inline]

Multiplies elementwise the components of this and the point c.

template<typename T>
template<typename U >
point<T> cvr::point< T >::operator* ( const U  c  )  const [inline]

Multiply point<T> with a given factor.

template<typename T>
point<T>& cvr::point< T >::operator*= ( const point< T > &  c  )  [inline]

Multiplies elementwise the components of this and the point c.

template<typename T>
template<typename U >
point<T>& cvr::point< T >::operator*= ( const U  c  )  [inline]

Multiply point<T> with a given factor.

template<typename T>
point<T> cvr::point< T >::operator+ ( const point< T > &  p  )  const [inline]

Operator + is simmilar to add, but a new point is returned, i.e.

this point will not change.

template<typename T>
point<T>& cvr::point< T >::operator+= ( const point< T > &  p  )  [inline]

Operator += is an alias for add().

template<typename T>
point<T> cvr::point< T >::operator- (  )  const [inline]

Operator -.

template<typename T>
point<T> cvr::point< T >::operator- ( const point< T > &  p  )  const [inline]

Operator -.

template<typename T>
point<T>& cvr::point< T >::operator-= ( const point< T > &  p  )  [inline]

Operator -=.

template<typename T>
point<T> cvr::point< T >::operator/ ( const point< T > &  c  )  const [inline]

Elementwise division of each component of the points.

template<typename T>
template<typename U >
point<T> cvr::point< T >::operator/ ( const U  c  )  const [inline]

Divide each component of point<T> by a given factor.

template<typename T>
point<T>& cvr::point< T >::operator/= ( const point< T > &  c  )  [inline]

Elementwise division of each component of the points.

template<typename T>
template<typename U >
point<T>& cvr::point< T >::operator/= ( const U  c  )  [inline]

Divide each component of point<T> by a given factor.

template<typename T>
bool cvr::point< T >::operator< ( const point< T > &  p  )  const [inline]

Operator <.

A point is "smaller" than another one if its coordinates produce an earlier display of the point in the monitor. i.e. if it has a smaller y component or (if the y components are the same) if the x component is smaller

template<typename T>
point<T>& cvr::point< T >::operator= ( const point< T > &  p  )  [inline]

Operator =.

template<typename T>
bool cvr::point< T >::operator== ( const point< T > &  p  )  const [inline]

Operator ==.

template<typename T>
bool cvr::point< T >::operator> ( const point< T > &  p  )  const [inline]

Operator >.

A point is "bigger" than another one if its coordinates produce an later display of the point in the monitor. i.e. if it has a bigger y component or (if the y components are the same) if the x component is bigger

template<typename T>
const T& cvr::point< T >::operator[] ( const int  i  )  const [inline]

Used to simulate read-only vector access.

It allows the use of point in templates expecting a vector-like structure.

The correspondence between the elements of the vector and the components will be [0] for x and [1] for y

template<typename T>
T& cvr::point< T >::operator[] ( const int  i  )  [inline]

Used to simulate vector access.

It allows the use of point in templates expecting a vector-like structure.

The correspondence between the elements of the vector and the components will be [0] for x and [1] for y

template<typename T>
point<T>& cvr::point< T >::set ( const T  tx,
const T  ty 
) [inline]

Set the coordinate values and return a reference to this point.

template<typename T>
size_type cvr::point< T >::size (  )  const [inline]

Used to simulate the vector size.

template<typename T>
point<T>& cvr::point< T >::subtract ( const point< T > &  a,
const point< T > &  b 
) [inline]

Subtract the two other points and leave the result here.

Parameters:
a first point
b point to be subtracted from the first one
Returns:
a reference to this point, which will contain a-b

template<typename T>
point<T>& cvr::point< T >::subtract ( const point< T > &  p  )  [inline]

Subtract.

Referenced by cvr::chainCode::chainCode().


Member Data Documentation

template<typename T>
value_type cvr::point< T >::data[2]

Array that shares the same memory with x and y.

template<typename T>
value_type cvr::point< T >::x

Coordinate x.

Referenced by cvr::chainCode::chainCode().

template<typename T>
value_type cvr::point< T >::y

Coordinate y;.

Referenced by cvr::chainCode::chainCode().


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:09:08 2009 for CVR-Lib by Doxygen 1.5.8