DGtal  1.2.0
testConvexHull2DThickness.cpp
Go to the documentation of this file.
1 
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 {
54  ch.add(Point(0,0));
55  ch.add(Point(1,0));
56  ch.add(Point(1,1));
57 
59  double thicknessHV =
62  pHV, qHV, sHV);
63 
64  double thicknessEucl =
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 {
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(),
112  pHV, qHV, sHV);
115  pE, qE, sE);
116 
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 
136  pE, qE, sE);
137 
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 
Aim: Class that implements an orientation functor, ie. it provides a way to compute the orientation o...
Aim: This class implements the on-line algorithm of Melkman for the computation of the convex hull of...
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
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 is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
TEST_CASE("int container traits", "[int][traits]")
const double thicknessEb
InHalfPlaneBySimple3x3Matrix< Point, DGtal::int64_t > Functor
const double thicknessE
CAPTURE(thicknessHV)
DGtal::MelkmanConvexHull< Point, Functor > ch
SECTION("Testing computation of horizontal/vertical thickness of ConvexHull2D")
double thicknessHV
double thicknessEucl
REQUIRE(domain.isInside(aPoint))