DGtal
1.5.beta
exampleInHalfPlane.cpp
Go to the documentation of this file.
1
39
#include <iostream>
40
#include "DGtal/base/Common.h"
41
42
#include "DGtal/kernel/SpaceND.h"
43
#include "DGtal/kernel/domains/HyperRectDomain.h"
44
45
#include "DGtal/geometry/tools/determinant/Simple2x2DetComputer.h"
46
#include "DGtal/geometry/tools/determinant/SimpleIncremental2x2DetComputer.h"
47
#include "DGtal/geometry/tools/determinant/AvnaimEtAl2x2DetSignComputer.h"
48
#include "DGtal/geometry/tools/determinant/Filtered2x2DetComputer.h"
49
#include "DGtal/geometry/tools/determinant/InHalfPlaneBy2x2DetComputer.h"
51
#include "DGtal/geometry/tools/determinant/PredicateFromOrientationFunctor2.h"
52
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
55
56
using namespace
std;
57
using namespace
DGtal
;
58
60
61
bool
62
basicUsage
()
63
{
65
//domain definition
66
typedef
SpaceND< 2, DGtal::int16_t >
DigitalSpace;
67
typedef
HyperRectDomain< DigitalSpace >
Domain
;
68
typedef
Domain::Point
Point
;
69
Domain
domain
(
Point
(-32767,-32767),
Point
(32767,32767) );
71
73
Point
P, Q, R;
74
P =
Point
(0,0);
75
Q =
Point
(5,2);
76
R =
Point
(2,1);
77
//problem: are P, Q, R counter-clockwise oriented ?
79
81
//orientation functor
82
typedef
InHalfPlaneBySimple3x3Matrix<Point, DGtal::int32_t>
OrientationFunctor;
83
OrientationFunctor orientationFunctor;
85
87
//geometric predicate
88
PredicateFromOrientationFunctor2<OrientationFunctor>
89
pointPredicate( orientationFunctor );
91
93
//initialization
94
pointPredicate.
init
( P, Q );
95
//which is equivalent to
96
//orientationFunctor.init( P, Q );
97
//because the predicate stores a pointer to the functor
99
100
bool
isCCW;
102
//decision
103
isCCW = pointPredicate( R );
104
//which is equivalent to the following shortcut:
105
//isCCW = pointPredicate( P, Q, R );
107
108
return
isCCW;
109
}
110
111
void
112
advice
()
113
{
114
{
116
//for coordinates of 30 (not zero) bits
117
typedef
PointVector<2, DGtal::int32_t>
Point
;
118
typedef
InHalfPlaneBySimple3x3Matrix<Point, DGtal::int64_t>
Functor
;
120
Functor
*a =
new
Functor
();
121
BOOST_VERIFY(a);
122
delete
a;
123
}
124
125
{
127
//for coordinates of 52 (not zero) bits
128
typedef
PointVector<2, DGtal::int64_t>
Point
;
129
typedef
AvnaimEtAl2x2DetSignComputer<double>
DetComputer;
130
typedef
Filtered2x2DetComputer<DetComputer>
FDetComputer;
131
typedef
InHalfPlaneBy2x2DetComputer<Point, FDetComputer>
Functor
;
133
Functor
*a =
new
Functor
();
134
BOOST_VERIFY(a);
135
delete
a;
136
//NB. using double as coordinate type is slightly faster than using DGtal::int64_t
137
//typedef PointVector<2, double> Point;
138
}
139
140
{
142
//for coordinates of 62 (not zero) bits
143
typedef
PointVector<2, DGtal::int64_t>
Point
;
144
typedef
AvnaimEtAl2x2DetSignComputer<DGtal::int64_t>
DetComputer;
145
typedef
InHalfPlaneBy2x2DetComputer<Point, DetComputer>
Functor
;
147
Functor
*a=
new
Functor
();
148
BOOST_VERIFY( a);
149
delete
a;
150
}
151
152
{
154
//for coordinates of 62 (not zero) bits
155
//if long double is implemented as the 80-bit extended precision type
156
typedef
PointVector<2, DGtal::int64_t>
Point
;
157
typedef
AvnaimEtAl2x2DetSignComputer<long double>
DetComputer;
158
typedef
Filtered2x2DetComputer<DetComputer>
FDetComputer;
159
typedef
InHalfPlaneBy2x2DetComputer<Point, FDetComputer>
Functor
;
160
Functor
*a =
new
Functor
();
161
BOOST_VERIFY(a == a);
163
delete
a;
164
}
165
166
#ifdef WITH_BIGINTEGER
167
{
169
//for arbitrary coordinates
170
typedef
PointVector<2, DGtal::BigInteger>
Point
;
171
typedef
Simple2x2DetComputer<DGtal::BigInteger>
DetComputer;
172
typedef
InHalfPlaneBy2x2DetComputer<Point, DetComputer>
Functor
;
173
Functor
*a=
new
Functor
();
174
BOOST_VERIFY( a);
176
delete
a;
177
}
178
#endif
179
180
}
181
182
int
main
(
int
argc,
char
** argv )
183
{
184
trace
.
beginBlock
(
"Example exampleInHalfPlane"
);
185
trace
.
info
() <<
"Args:"
;
186
for
(
int
i = 0; i < argc; ++i )
187
trace
.
info
() <<
" "
<< argv[ i ];
188
trace
.
info
() << endl;
189
190
basicUsage
();
191
advice
();
192
193
trace
.
endBlock
();
194
return
0;
195
}
196
// //
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:145
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:84
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition:
HyperRectDomain.h:100
DGtal::InHalfPlaneBy2x2DetComputer
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition:
InHalfPlaneBy2x2DetComputer.h:93
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition:
InHalfPlaneBySimple3x3Matrix.h:92
DGtal::PointVector< dim, Integer >
DGtal::PredicateFromOrientationFunctor2
Aim: Small adapter to models of COrientationFunctor2. It is a model of concepts::CPointPredicate....
Definition:
PredicateFromOrientationFunctor2.h:82
DGtal::PredicateFromOrientationFunctor2::init
void init(const Point &aPoint1, const Point &aPoint2)
DGtal::Simple2x2DetComputer
Aim: Small class useful to compute the determinant of a 2x2 matrix from its four coefficients,...
Definition:
Simple2x2DetComputer.h:93
DGtal::SpaceND
Definition:
SpaceND.h:96
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
basicUsage
bool basicUsage()
Definition:
exampleInHalfPlane.cpp:62
main
int main(int argc, char **argv)
Definition:
exampleInHalfPlane.cpp:182
advice
void advice()
Definition:
exampleInHalfPlane.cpp:112
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::trace
Trace trace
Definition:
Common.h:153
Point
MyPointD Point
Definition:
testClone2.cpp:383
Functor
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
Definition:
testConvexHull2DReverse.cpp:49
domain
Domain domain
Definition:
testProjection.cpp:88
Domain
HyperRectDomain< Space > Domain
Definition:
testSimpleRandomAccessRangeFromPoint.cpp:44
examples
geometry
tools
determinant
exampleInHalfPlane.cpp
Generated on Fri Dec 20 2024 12:44:21 for DGtal by
1.9.1