DGtal  1.3.beta
geometry/tools/determinant/exampleInHalfPlane.cpp

Example of geometric predicates.

Implementation of geometric predicates
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
#include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
#include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
using namespace std;
using namespace DGtal;
bool
{
//domain definition
typedef SpaceND< 2, DGtal::int16_t > DigitalSpace;
typedef Domain::Point Point;
Domain domain( Point(-32767,-32767), Point(32767,32767) );
Point P, Q, R;
P = Point(0,0);
Q = Point(5,2);
R = Point(2,1);
//problem: are P, Q, R counter-clockwise oriented ?
//orientation functor
OrientationFunctor orientationFunctor;
//geometric predicate
pointPredicate( orientationFunctor );
//initialization
pointPredicate.init( P, Q );
//which is equivalent to
//orientationFunctor.init( P, Q );
//because the predicate stores a pointer to the functor
bool isCCW;
//decision
isCCW = pointPredicate( R );
//which is equivalent to the following shortcut:
//isCCW = pointPredicate( P, Q, R );
return isCCW;
}
void
{
{
//for coordinates of 30 (not zero) bits
Functor *a = new Functor();
BOOST_VERIFY(a);
delete a;
}
{
//for coordinates of 52 (not zero) bits
typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
Functor *a = new Functor();
BOOST_VERIFY(a);
delete a;
//NB. using double as coordinate type is slightly faster than using DGtal::int64_t
//typedef PointVector<2, double> Point;
}
{
//for coordinates of 62 (not zero) bits
Functor *a= new Functor();
BOOST_VERIFY( a);
delete a;
}
{
//for coordinates of 62 (not zero) bits
//if long double is implemented as the 80-bit extended precision type
typedef Filtered2x2DetComputer<DetComputer> FDetComputer;
Functor *a = new Functor();
BOOST_VERIFY(a == a);
delete a;
}
#ifdef WITH_BIGINTEGER
{
//for arbitrary coordinates
Functor *a= new Functor();
BOOST_VERIFY( a);
delete a;
}
#endif
}
int main( int argc, char** argv )
{
trace.beginBlock ( "Example exampleInHalfPlane" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
return 0;
}
// //
DGtal::Simple2x2DetComputer
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
Definition: Simple2x2DetComputer.h:92
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition: HyperRectDomain.h:99
DGtal::Trace::endBlock
double endBlock()
DGtal::Filtered2x2DetComputer
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Definition: Filtered2x2DetComputer.h:83
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
Functor
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Definition: testConvexHull2DReverse.cpp:51
basicUsage
bool basicUsage()
Definition: testOwningOrAliasingPtr.cpp:180
DGtal::SpaceND
Definition: SpaceND.h:95
DGtal::Trace::info
std::ostream & info()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Domain
HyperRectDomain< Space > Domain
Definition: testSimpleRandomAccessRangeFromPoint.cpp:44
DGtal::InHalfPlaneBy2x2DetComputer
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition: InHalfPlaneBy2x2DetComputer.h:92
Definition: exampleInHalfPlane.cpp:112
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition: InHalfPlaneBySimple3x3Matrix.h:91
DGtal::AvnaimEtAl2x2DetSignComputer
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Definition: AvnaimEtAl2x2DetSignComputer.h:144
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::PredicateFromOrientationFunctor2
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
Definition: PredicateFromOrientationFunctor2.h:81
DGtal::PredicateFromOrientationFunctor2::init
void init(const Point &aPoint1, const Point &aPoint2)
Point
MyPointD Point
Definition: testClone2.cpp:383