DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testConvexHull2DThickness.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtalCatch.h"
35
#include "DGtal/helpers/StdDefs.h"
36
#include "DGtal/geometry/tools/Hull2DHelpers.h"
37
#include "DGtal/geometry/tools/determinant/InHalfPlaneBySimple3x3Matrix.h"
38
39
41
42
using namespace
std
;
43
using namespace
DGtal
;
44
46
// Functions for testing class ConvexHull2D-catch.
48
49
TEST_CASE
(
"Testing Rotating Caliper of ConvexHull2D (basic convex hull)"
)
50
{
51
typedef
PointVector<2,DGtal::int32_t>
Point
;
52
typedef
InHalfPlaneBySimple3x3Matrix<Point, DGtal::int64_t>
Functor
;
53
DGtal::MelkmanConvexHull<Point, Functor>
ch
;
54
ch
.add(
Point
(0,0));
55
ch
.add(
Point
(1,0));
56
ch
.add(
Point
(1,1));
57
58
Point
pHV
,
qHV
,
sHV
,
pE
,
qE
,
sE
;
59
double
thicknessHV
=
60
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
61
DGtal::functions::Hull2D::HorizontalVerticalThickness
,
62
pHV
,
qHV
,
sHV
);
63
64
double
thicknessEucl
=
65
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
66
DGtal::functions::Hull2D::EuclideanThickness
,
67
pE
,
qE
,
sE
);
68
69
SECTION
(
"Testing computation of horizontal/vertical thickness of ConvexHull2D"
)
70
{
71
REQUIRE
(
thicknessHV
== 1.0 );
72
REQUIRE
(
pHV
==
Point
(0,0) );
73
REQUIRE
(
qHV
==
Point
(1,0) );
74
REQUIRE
(
sHV
==
Point
(1,1) );
75
}
76
77
78
SECTION
(
"Testing computation of euclidean thickness of ConvexHull2D"
)
79
{
80
REQUIRE
(
thicknessEucl
== Approx(std::sqrt(2.0)/2.0) );
81
REQUIRE
(
pE
==
Point
(1,1) );
82
REQUIRE
(
qE
==
Point
(0,0) );
83
REQUIRE
(
sE
==
Point
(1,0) );
84
}
85
86
}
87
88
89
TEST_CASE
(
"Testing Rotating Caliper of ConvexHull2D (convex hull with floating coordinates)"
)
90
{
91
typedef
PointVector<2, double_t>
Point
;
92
typedef
InHalfPlaneBySimple3x3Matrix<Point, double>
Functor
;
93
DGtal::MelkmanConvexHull<Point, Functor>
ch
;
94
95
ch
.add(
Point
(104.0, 54.2));
96
ch
.add(
Point
(104.2, 53.2));
97
ch
.add(
Point
(103.2, 53.4));
98
ch
.add(
Point
(103.3, 52.3));
99
ch
.add(
Point
(102.3, 52.3));
100
ch
.add(
Point
(102.2, 51.0));
101
ch
.add(
Point
(102.2, 50.2));
102
ch
.add(
Point
(101.0, 50.0));
103
ch
.add(
Point
(101.0, 49.1));
104
ch
.add(
Point
(101.2, 48.2));
105
ch
.add(
Point
(100.0, 48.2));
106
ch
.add(
Point
(100.4, 47.4));
107
108
Point
pHV
,
qHV
,
sHV
,
pE
,
qE
,
sE
;
109
110
const
double
thicknessHV
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
111
DGtal::functions::Hull2D::HorizontalVerticalThickness
,
112
pHV
,
qHV
,
sHV
);
113
const
double
thicknessE
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
114
DGtal::functions::Hull2D::EuclideanThickness
,
115
pE
,
qE
,
sE
);
116
117
CAPTURE
(
thicknessHV
);
118
CAPTURE
(
thicknessE
);
119
120
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
121
{
122
REQUIRE
(
pHV
==
Point
(101.2, 48.2) );
123
REQUIRE
(
qHV
==
Point
(104.2, 53.2) );
124
REQUIRE
(
sHV
==
Point
(102.3, 52.3) );
125
}
126
SECTION
(
"Testing antipodal points of ConvexHull2D"
)
127
{
128
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
129
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
130
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
131
}
132
ch
.reverse();
133
134
const
double
thicknessEb
=
DGtal::functions::Hull2D::computeHullThickness
(
ch
.begin(),
ch
.end(),
135
DGtal::functions::Hull2D::EuclideanThickness
,
136
pE
,
qE
,
sE
);
137
138
CAPTURE
(
thicknessEb
);
139
140
SECTION
(
"Testing same antipodal points after hull reversing "
)
141
{
142
REQUIRE
(
pE
==
Point
(101.2, 48.2) );
143
REQUIRE
(
qE
==
Point
(104.2, 53.2) );
144
REQUIRE
(
sE
==
Point
(102.3, 52.3) );
145
}
146
}
147
DGtal::InHalfPlaneBySimple3x3Matrix
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Definition
InHalfPlaneBySimple3x3Matrix.h:92
DGtal::MelkmanConvexHull
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
Definition
MelkmanConvexHull.h:90
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
DGtal::Point
DGtal::functions::Hull2D::computeHullThickness
double computeHullThickness(const ForwardIterator &itb, const ForwardIterator &ite, const ThicknessDefinition &def)
Procedure to compute the convex hull thickness given from different definitions (Horizontal/vertical ...
DGtal::functions::Hull2D::HorizontalVerticalThickness
@ HorizontalVerticalThickness
Definition
Hull2DHelpers.h:78
DGtal::functions::Hull2D::EuclideanThickness
@ EuclideanThickness
Definition
Hull2DHelpers.h:78
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
Functor
Definition
testFunctorHolder.cpp:45
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
thicknessEb
const double thicknessEb
Definition
testConvexHull2DReverse.cpp:98
pHV
Point pHV
Definition
testConvexHull2DReverse.cpp:71
qHV
Point qHV
Definition
testConvexHull2DReverse.cpp:71
qE
Point qE
Definition
testConvexHull2DReverse.cpp:71
ch
DGtal::MelkmanConvexHull< Point, Functor > ch
Definition
testConvexHull2DReverse.cpp:52
pE
Point pE
Definition
testConvexHull2DReverse.cpp:71
thicknessE
const double thicknessE
Definition
testConvexHull2DReverse.cpp:77
CAPTURE
CAPTURE(thicknessHV)
sE
Point sE
Definition
testConvexHull2DReverse.cpp:71
sHV
Point sHV
Definition
testConvexHull2DReverse.cpp:71
thicknessHV
const double thicknessHV
Definition
testConvexHull2DReverse.cpp:73
thicknessEucl
double thicknessEucl
Definition
testConvexHull2DThickness.cpp:64
SECTION
SECTION("Testing constant forward iterators")
Definition
testSimpleRandomAccessRangeFromPoint.cpp:66
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
geometry
tools
testConvexHull2DThickness.cpp
Generated on
for DGtal by
1.18.0