DGtal 1.4.0
Loading...
Searching...
No Matches
geometry/tools/determinant/exampleInHalfPlane.cpp

Example of geometric predicates.

See also
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;
advice();
return 0;
}
// //
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Class that provides a way of computing the sign of the determinant of a 2x2 matrix from its four...
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
void init(const Point &aPoint1, const Point &aPoint2)
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
void advice()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
int main()
Definition testBits.cpp:56
MyPointD Point
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
bool basicUsage()
Domain domain
HyperRectDomain< Space > Domain