Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgar::GenPoint< T > Class Template Reference
[Points]

#include <qgarlib/primitives.H>

List of all members.


Detailed Description

template<class T>
class qgar::GenPoint< T >

Point with coordinates of type T.

This class is not supposed to be derived: The destructor (as any other function) is not virtual.

Warning:
Most of the functions performing geometrical transformations work with points and primitives having double coordinates only.
Author:
Gérald Masini
Date:
July 4, 2001 14:07
Since:
Qgar 1.0

Definition at line 105 of file _QGAR_GenPoint.H.

Public Types

Types
typedef T value_type
 Type of the coordinates.
typedef value_typereference
 Reference to qgar::GenPoint::value_type.
typedef const value_typeconst_reference
 Constant reference to qgar::GenPoint::value_type.
typedef value_typepointer
 Pointer to qgar::GenPoint::value_type.
typedef const value_typeconst_pointer
 Constant pointer to qgar::GenPoint::value_type.

Public Member Functions

template<>
void project (const GenSegment< double > &aSeg)
template<>
void project (const GenQgarSegment< double > &aQSeg)
Constructors
 GenPoint ()
 Default constructor: Create a point at (0,0).
 GenPoint (const GenPoint< value_type > &aPt)
 Copy constructor.
template<class U>
 GenPoint (const GenPoint< U > &aPt)
 Conversion of a point of a type different from the effective type.
 GenPoint (value_type aX, value_type aY)
 Initialize from coordinates.
Destructor
 ~GenPoint ()
 Non-virtual destructor (see the class header).
Access to coordinates
value_type x () const
 Get X coordinate.
value_type y () const
 Get Y coordinate.
double rho () const
 Get radius (rho) in polar coordinates.
double theta () const
 Get angle (theta) in polar coordinates.
Assign coordinates
void setX (value_type aX)
 Set X coordinate.
void setY (value_type aY)
 Set Y coordinate.
void setXY (value_type aX, value_type aY)
 Set both X and Y coordinates.
Operators
Warning:
Using stand-alone versions of operators (operator+, operator-) is much less efficient then using assignment versions (operator+=, operator-=<b/>). For example, an expression like:
  res = a + b - c;
uses 2 temporary objects, one for each call to operator+ and operator-. These considerations also apply to functional operators (see the corresponding section). To preserve efficiency, the code should be written in this way:
  res = a;
  res += b;  // no temporary needed
  res -= c;  // no temporary needed


GenPoint< value_type > & operator= (const GenPoint< value_type > &aPt)
 Assignment.
const GenPoint< value_typeoperator+ (const GenPoint< value_type > &aPt) const
 Same as function qgar::GenPoint::plus.
GenPoint< value_type > & operator+= (const GenPoint< value_type > &aPt)
 Same as function qgar::GenPoint::plusEqual.
const GenPoint< value_typeoperator- (const GenPoint< value_type > &aPt) const
 Same as function qgar::GenPoint::minus.
GenPoint< value_type > & operator-= (const GenPoint< value_type > &aPt)
 Same as function qgar::GenPoint::minusEqual.
bool operator== (const GenPoint< value_type > &aPt) const
 Same as function qgar::GenPoint::eq.
bool operator!= (const GenPoint< value_type > &aPt) const
 Same as function qgar::GenPoint::notEq.
Functional operators
Warning:
Using stand-alone versions of operators (plus, minus) is much less efficient then using assignment versions (plusEqual, minusEqual). For example, an expression like:
  res = a.plus(b).minus(c);
uses 2 temporary objects, one for each call to plus and minus. These considerations also apply to operators (see the corresponding section). To preserve efficiency, the code should be written in this way:
  res = a;
  res.plusEqual(b);   // no temporary needed
  res.minusEqual(c);  // no temporary needed
Operators implementation uses Scott Meyers' tips from [Meyer, 1996]: item #22, pages 107-110.

const GenPoint< value_typeplus (const GenPoint< value_type > &aPt) const
 Add coordinates of the given point to those of the current point, and return them as a new point.
GenPoint< value_type > & plusEqual (const GenPoint< value_type > &aPt)
 Add coordinates of the given point to those of the current point.
const GenPoint< value_typeminus (const GenPoint< value_type > &aPt) const
 Substract coordinates of the given point to those of the current point, and return them as a new point.
GenPoint< value_type > & minusEqual (const GenPoint< value_type > &aPt)
 Substract coordinates of the given point to those of the current point.
bool eq (const GenPoint< value_type > &aPt) const
 Equality.
bool notEq (const GenPoint< value_type > &aPt) const
 Inequality.
Geometry: projection
void project (const GenSegment< value_type > &aSeg)
 Orthogonal projection of the current point onto the line supporting the given segment.
void project (const GenQgarSegment< value_type > &aQSeg)
 Orthogonal projection of the current point onto the line supporting the given Qgar segment.
Geometry: translation
void translate (value_type aTransX, value_type aTransY)
 Translate current point along X and Y axis.

Protected Attributes

Representation of a point
Apply a central symmetry to the current point, using the origin of the coordinates system as the symmetry center. Apply a central symmetry to the current point, using the given point as the symmetry center. Apply a mirror symmetry to the current point, using the line supporting the given segment for the symmetry.

value_type _x
 X coordinate.
value_type _y
 Y coordinate.


Member Typedef Documentation

template<class T>
typedef const value_type* qgar::GenPoint< T >::const_pointer
 

Constant pointer to qgar::GenPoint::value_type.

Definition at line 140 of file _QGAR_GenPoint.H.

template<class T>
typedef const value_type& qgar::GenPoint< T >::const_reference
 

Constant reference to qgar::GenPoint::value_type.

Definition at line 130 of file _QGAR_GenPoint.H.

template<class T>
typedef value_type* qgar::GenPoint< T >::pointer
 

Pointer to qgar::GenPoint::value_type.

Definition at line 135 of file _QGAR_GenPoint.H.

template<class T>
typedef value_type& qgar::GenPoint< T >::reference
 

Reference to qgar::GenPoint::value_type.

Definition at line 125 of file _QGAR_GenPoint.H.

template<class T>
typedef T qgar::GenPoint< T >::value_type
 

Type of the coordinates.

Definition at line 120 of file _QGAR_GenPoint.H.


Constructor & Destructor Documentation

template<class T>
qgar::GenPoint< T >::GenPoint  ) 
 

Default constructor: Create a point at (0,0).

Definition at line 71 of file _QGAR_GenPoint.TCC.

template<class T>
qgar::GenPoint< T >::GenPoint const GenPoint< value_type > &  aPt  ) 
 

Copy constructor.

template<class T>
template<class U>
qgar::GenPoint< T >::GenPoint const GenPoint< U > &  aPt  )  [explicit]
 

Conversion of a point of a type different from the effective type.

Parameters:
aPt a point
Warning:
This kind of conversion must be explicitely specified by the client.

Definition at line 84 of file _QGAR_GenPoint.TCC.

template<class T>
qgar::GenPoint< T >::GenPoint value_type  aX,
value_type  aY
 

Initialize from coordinates.

Definition at line 111 of file _QGAR_GenPoint.TCC.

template<class T>
qgar::GenPoint< T >::~GenPoint  ) 
 

Non-virtual destructor (see the class header).

Definition at line 129 of file _QGAR_GenPoint.TCC.


Member Function Documentation

template<class T>
bool qgar::GenPoint< T >::eq const GenPoint< value_type > &  aPt  )  const
 

Equality.

Return true if the current point and the given point have the same coordinates.

Parameters:
aPt a point

template<class T>
const GenPoint<value_type> qgar::GenPoint< T >::minus const GenPoint< value_type > &  aPt  )  const
 

Substract coordinates of the given point to those of the current point, and return them as a new point.

Parameters:
aPt a point

template<class T>
GenPoint<value_type>& qgar::GenPoint< T >::minusEqual const GenPoint< value_type > &  aPt  ) 
 

Substract coordinates of the given point to those of the current point.

The current point is modified.

Parameters:
aPt a point

template<class T>
bool qgar::GenPoint< T >::notEq const GenPoint< value_type > &  aPt  )  const
 

Inequality.

Return true if the coordinates of the current point and of the given point are different.

Parameters:
aPt a point

template<class T>
bool qgar::GenPoint< T >::operator!= const GenPoint< value_type > &  aPt  )  const [inline]
 

Same as function qgar::GenPoint::notEq.

template<class T>
const GenPoint<value_type> qgar::GenPoint< T >::operator+ const GenPoint< value_type > &  aPt  )  const [inline]
 

Same as function qgar::GenPoint::plus.

template<class T>
GenPoint<value_type>& qgar::GenPoint< T >::operator+= const GenPoint< value_type > &  aPt  )  [inline]
 

Same as function qgar::GenPoint::plusEqual.

template<class T>
const GenPoint<value_type> qgar::GenPoint< T >::operator- const GenPoint< value_type > &  aPt  )  const [inline]
 

Same as function qgar::GenPoint::minus.

template<class T>
GenPoint<value_type>& qgar::GenPoint< T >::operator-= const GenPoint< value_type > &  aPt  )  [inline]
 

Same as function qgar::GenPoint::minusEqual.

template<class T>
GenPoint<value_type>& qgar::GenPoint< T >::operator= const GenPoint< value_type > &  aPt  )  [inline]
 

Assignment.

template<class T>
bool qgar::GenPoint< T >::operator== const GenPoint< value_type > &  aPt  )  const [inline]
 

Same as function qgar::GenPoint::eq.

template<class T>
const GenPoint<value_type> qgar::GenPoint< T >::plus const GenPoint< value_type > &  aPt  )  const
 

Add coordinates of the given point to those of the current point, and return them as a new point.

Parameters:
aPt a point

template<class T>
GenPoint<value_type>& qgar::GenPoint< T >::plusEqual const GenPoint< value_type > &  aPt  ) 
 

Add coordinates of the given point to those of the current point.

The current point is modified.

Parameters:
aPt a point

template<>
void qgar::GenPoint< double >::project const GenQgarSegment< double > &  aQSeg  )  [inline]
 

Definition at line 261 of file _QGAR_GenPoint.TCC.

References qgar::qgProject().

template<>
void qgar::GenPoint< double >::project const GenSegment< double > &  aSeg  )  [inline]
 

Definition at line 251 of file _QGAR_GenPoint.TCC.

References qgar::qgProject().

template<class T>
void qgar::GenPoint< T >::project const GenQgarSegment< value_type > &  aQSeg  )  [inline]
 

Orthogonal projection of the current point onto the line supporting the given Qgar segment.

Parameters:
aQSeg a Qgar segment
Warning:
This function applies only to points and Qgar segments having coordinates of type double.

Definition at line 240 of file _QGAR_GenPoint.TCC.

template<class T>
void qgar::GenPoint< T >::project const GenSegment< value_type > &  aSeg  )  [inline]
 

Orthogonal projection of the current point onto the line supporting the given segment.

Parameters:
aSeg a segment
Warning:
This function applies only to points and segments having coordinates of type double.

template<class T>
double qgar::GenPoint< T >::rho  )  const [inline]
 

Get radius (rho) in polar coordinates.

Definition at line 164 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x, and qgar::GenPoint< T >::_y.

template<class T>
void qgar::GenPoint< T >::setX value_type  aX  )  [inline]
 

Set X coordinate.

Parameters:
aX new X coordinate

Definition at line 190 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x.

Referenced by qgar::DxfFile::retrievePQgarSegment().

template<class T>
void qgar::GenPoint< T >::setXY value_type  aX,
value_type  aY
[inline]
 

Set both X and Y coordinates.

Parameters:
aX new X coordinate
aY new Y coordinate

Definition at line 210 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x, and qgar::GenPoint< T >::_y.

Referenced by qgar::HysteresisBinaryImage::HysteresisBinaryImage(), qgar::FreemanChain::reverse(), RWARCVECTOR_bestAttributes(), RWARCVECTOR_thirdPoint(), qgar::BoundingBox::setCorners(), qgar::AbstractGenPrimitive< T >::setSource(), qgar::AbstractGenPrimitive< T >::setSourceTarget(), qgar::AbstractGenPrimitive< T >::setTarget(), qgar::GenPolyline< T >::updateSource(), and qgar::GenPolygon< T >::updateSource().

template<class T>
void qgar::GenPoint< T >::setY value_type  aY  )  [inline]
 

Set Y coordinate.

Parameters:
aY new Y coordinate

Definition at line 200 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_y.

Referenced by qgar::DxfFile::retrievePQgarSegment().

template<class T>
double qgar::GenPoint< T >::theta  )  const [inline]
 

Get angle (theta) in polar coordinates.

Definition at line 174 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x, and qgar::GenPoint< T >::_y.

template<class T>
void qgar::GenPoint< T >::translate value_type  aTransX,
value_type  aTransY
[inline]
 

Translate current point along X and Y axis.

Parameters:
aTransX X translation factor
aTransY Y translation factor

Definition at line 276 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x, and qgar::GenPoint< T >::_y.

Referenced by qgar::LinkedChainList::LinkedChainList(), qgar::WDSegment::set(), and qgar::WDSegment::WDSegment().

template<class T>
T qgar::GenPoint< T >::x  )  const [inline]
 

Get X coordinate.

Definition at line 144 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_x.

Referenced by qgar::LinkedChainList::aChain(), qgar::BoundingBox::contains(), qgar::GenSegment< T >::contains(), qgar::GenImage< T, CheckPolicy >::draw(), qgar::AbstractGenPrimitive< T >::dx(), qgar::HysteresisBinaryImage::HysteresisBinaryImage(), qgar::BoundingBox::intersection(), qgar::BoundingBox::intersects(), qgar::LinkedChainList::LinkedChainList(), qgar::LINKEDCHAINLIST_areNeigh(), qgar::WDSegmentList::PRIVATEperform(), qgar::FreemanChain::push_back(), qgar::FreemanChain::push_front(), qgar::FreemanChain::reverse(), RWARCVECTOR_bestAttributes(), RWARCVECTOR_thirdPoint(), qgar::DxfFile::saveChain(), qgar::BoundingBox::setCorners(), qgar::GenArc< T >::translate(), qgar::WDSegment::translateTarget(), qgar::BoundingBox::width(), qgar::TgifFile::write(), qgar::BoundingBox::xBottomRight(), qgar::GenArc< T >::xCenter(), qgar::AbstractGenPrimitive< T >::xSource(), qgar::AbstractGenPrimitive< T >::xTarget(), and qgar::BoundingBox::xTopLeft().

template<class T>
T qgar::GenPoint< T >::y  )  const [inline]
 

Get Y coordinate.

Definition at line 154 of file _QGAR_GenPoint.TCC.

References qgar::GenPoint< T >::_y.

Referenced by qgar::LinkedChainList::aChain(), qgar::BoundingBox::contains(), qgar::GenSegment< T >::contains(), qgar::GenImage< T, CheckPolicy >::draw(), qgar::AbstractGenPrimitive< T >::dy(), qgar::BoundingBox::height(), qgar::HysteresisBinaryImage::HysteresisBinaryImage(), qgar::BoundingBox::intersection(), qgar::BoundingBox::intersects(), qgar::LinkedChainList::LinkedChainList(), qgar::LINKEDCHAINLIST_areNeigh(), qgar::WDSegmentList::PRIVATEperform(), qgar::FreemanChain::push_back(), qgar::FreemanChain::push_front(), qgar::FreemanChain::reverse(), RWARCVECTOR_bestAttributes(), RWARCVECTOR_thirdPoint(), qgar::DxfFile::saveChain(), qgar::BoundingBox::setCorners(), qgar::GenArc< T >::translate(), qgar::WDSegment::translateTarget(), qgar::GenPolygon< T >::updateSource(), qgar::GenPolygon< T >::updateTarget(), qgar::TgifFile::write(), qgar::BoundingBox::yBottomRight(), qgar::AbstractGenPrimitive< T >::ySource(), qgar::AbstractGenPrimitive< T >::yTarget(), and qgar::BoundingBox::yTopLeft().


Member Data Documentation

template<class T>
value_type qgar::GenPoint< T >::_x [protected]
 

X coordinate.

Definition at line 608 of file _QGAR_GenPoint.H.

Referenced by qgar::GenPoint< T >::rho(), qgar::GenPoint< T >::setX(), qgar::GenPoint< T >::setXY(), qgar::GenPoint< T >::theta(), qgar::GenPoint< T >::translate(), and qgar::GenPoint< T >::x().

template<class T>
value_type qgar::GenPoint< T >::_y [protected]
 

Y coordinate.

Definition at line 613 of file _QGAR_GenPoint.H.

Referenced by qgar::GenPoint< T >::rho(), qgar::GenPoint< T >::setXY(), qgar::GenPoint< T >::setY(), qgar::GenPoint< T >::theta(), qgar::GenPoint< T >::translate(), and qgar::GenPoint< T >::y().


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