DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer > Class Template Reference

Aim: Class that implements a binary point predicate, which is able to compare the position of two given points \( P, Q \) around a pole \( O \). More precisely, it compares the oriented angles lying between the horizontal line passing by \( O \) and the rays \( [OP) \) and \( [OQ) \) (in a counter-clockwise orientation). More...

#include <DGtal/geometry/tools/PolarPointComparatorBy2x2DetComputer.h>

Public Types

typedef TPoint Point
 
typedef Point::Coordinate Coordinate
 
typedef Point Vector
 
typedef TDetComputer DetComputer
 
typedef DetComputer::ResultInteger ResultInteger
 
typedef functors::Thresholder< ResultInteger, false, false > CustomThresholder
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((C2x2DetComputer< DetComputer >))
 
 PolarPointComparatorBy2x2DetComputer ()
 
 PolarPointComparatorBy2x2DetComputer (const Point &aPoint)
 
 PolarPointComparatorBy2x2DetComputer (const PolarPointComparatorBy2x2DetComputer &other)
 
PolarPointComparatorBy2x2DetComputeroperator= (const PolarPointComparatorBy2x2DetComputer &other)
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 
void setPole (const Point &aPole)
 
bool operator() (const Point &aPoint1, const Point &aPoint2) const
 

Private Member Functions

bool isBefore (const Point &aU, const Point &aV) const
 

Private Attributes

Point myPole
 
DetComputer myDetComputer
 
CustomThresholder myThresholder
 

Detailed Description

template<typename TPoint, typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
class DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >

Aim: Class that implements a binary point predicate, which is able to compare the position of two given points \( P, Q \) around a pole \( O \). More precisely, it compares the oriented angles lying between the horizontal line passing by \( O \) and the rays \( [OP) \) and \( [OQ) \) (in a counter-clockwise orientation).

See PolarPointComparatorBy2x2DetComputer::operator() and PolarPointComparatorBy2x2DetComputer::isBefore for more details about the comparison (especially in degenerate cases).

Note
We do not use any approximating function like atan, but only exact computations involving the evaluation of determinants of 2x2 matrices. With the default template parameters, the result is guaranteed to be exact for integral point coordinates lying whithin the range ]-2^30,2^30[.
Template Parameters
TPointtype of points to compare
TDetComputera model of C2x2DetComputer. By default, Simple2x2DetComputer is chosen.
Examples
geometry/tools/exampleConvexHull2D.cpp.

Definition at line 79 of file PolarPointComparatorBy2x2DetComputer.h.

Member Typedef Documentation

◆ Coordinate

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef Point::Coordinate DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::Coordinate

Type of point coordinates

Definition at line 91 of file PolarPointComparatorBy2x2DetComputer.h.

◆ CustomThresholder

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef functors::Thresholder<ResultInteger, false, false> DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::CustomThresholder

Type of the object that returns a bool from the determinant returned by myDetComputer.

Definition at line 113 of file PolarPointComparatorBy2x2DetComputer.h.

◆ DetComputer

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef TDetComputer DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::DetComputer

Type of the object that computes the determinant of 2x2 matrix in order to determine the orientation of three points or compare the norm of two vectors.

Definition at line 101 of file PolarPointComparatorBy2x2DetComputer.h.

◆ Point

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef TPoint DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::Point

Type of 2D points to compare

Definition at line 87 of file PolarPointComparatorBy2x2DetComputer.h.

◆ ResultInteger

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef DetComputer::ResultInteger DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::ResultInteger

Type of integer returned by the determinant computer

Definition at line 107 of file PolarPointComparatorBy2x2DetComputer.h.

◆ Vector

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
typedef Point DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::Vector

Type of 2D vectors

Definition at line 95 of file PolarPointComparatorBy2x2DetComputer.h.

Constructor & Destructor Documentation

◆ PolarPointComparatorBy2x2DetComputer() [1/3]

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::PolarPointComparatorBy2x2DetComputer ( )

Default constructor. myPole is set to (0,0).

◆ PolarPointComparatorBy2x2DetComputer() [2/3]

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::PolarPointComparatorBy2x2DetComputer ( const Point aPoint)

Constructor.

Parameters
aPointpole used for the polar comparison

◆ PolarPointComparatorBy2x2DetComputer() [3/3]

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::PolarPointComparatorBy2x2DetComputer ( const PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer > &  other)

Copy constructor.

Parameters
otherthe object to clone.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::BOOST_CONCEPT_ASSERT ( (C2x2DetComputer< DetComputer >)  )

◆ isBefore()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
bool DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::isBefore ( const Point aU,
const Point aV 
) const
private

Method that compares two given points both belonging to the upward (positive y-coordinates) or downward (negative y-coordinates) half-plane.

The first argument aU lies before the second one aV iff the triple myPole , aU , aV are counter-clockwise oriented.

If myPole , aU , aV are aligned aU lies before aV iff its (L2) norm is shorter.

Note that if aU or aV are equal to myPole, its norm is the shortest possible.

If aU and aV are equal, this methods returns 'false', because no point is strictly located before the other.

Parameters
aUfirst point
aVsecond point
Returns
'true' if aU lies before aV, 'false' otherwise

◆ isValid()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
bool DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

◆ operator()()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
bool DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::operator() ( const Point aPoint1,
const Point aPoint2 
) const

Main operator, which compares two given points aPoint1 and aPoint2.

This method first checks whether the two points are located on the same side of the horizontal line passing by myPole or not. If so, it calls PolarPointComparatorBy2x2DetComputer::isBefore. Otherwise it concludes.

Parameters
aPoint1first point
aPoint2second point
Returns
'true' if aPoint1 lies before aPoint2, 'false' otherwise
See also
PolarPointComparatorBy2x2DetComputer::isBefore

◆ operator=()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
PolarPointComparatorBy2x2DetComputer & DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::operator= ( const PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer > &  other)

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ selfDisplay()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
void DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

◆ setPole()

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
void DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::setPole ( const Point aPole)

Sets the pole.

Parameters
aPolenew pole for the polar comparison.
Examples
geometry/tools/exampleConvexHull2D.cpp.

Referenced by convexHull(), and testSort().

Field Documentation

◆ myDetComputer

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
DetComputer DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::myDetComputer
mutableprivate

Object that computes the determinant of 2x2 matrix in order to determine the orientation of three points or compare the norm of two vectors

Definition at line 222 of file PolarPointComparatorBy2x2DetComputer.h.

◆ myPole

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
Point DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::myPole
private

Point used as the origin for the polar comparison of two given points

Definition at line 216 of file PolarPointComparatorBy2x2DetComputer.h.

◆ myThresholder

template<typename TPoint , typename TDetComputer = Simple2x2DetComputer<typename TPoint::Coordinate, DGtal::int64_t >>
CustomThresholder DGtal::functors::PolarPointComparatorBy2x2DetComputer< TPoint, TDetComputer >::myThresholder
private

Object that returns a bool from the determinant returned by myDetComputer

Definition at line 227 of file PolarPointComparatorBy2x2DetComputer.h.


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