DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
tests
math
testMeasure.cpp
1
32
#include <cstdio>
33
#include <cmath>
34
#include <iostream>
35
#include <fstream>
36
#include <vector>
37
#include "DGtal/base/Common.h"
38
#include "DGtal/math/MeasureOfStraightLines.h"
39
40
41
using namespace
DGtal;
42
using namespace
std;
43
44
45
51
void
testUnitSquare()
52
{
53
vector<double> a;
54
vector<double> b;
55
56
a.push_back(0);
57
b.push_back(0);
58
a.push_back(1);
59
b.push_back(0);
60
a.push_back(1);
61
b.push_back(1);
62
a.push_back(0);
63
b.push_back(1);
64
65
MeasureOfStraightLines
measure;
66
67
68
trace
.
info
() <<
"Measure of the Straight of Lines of the unit square = "
<< measure.
computeMeasure
(a,b)<< std::endl;
69
trace
.
emphase
() <<
"Expected value = 0.707107 (sqrt(2)/2)"
<<endl;
70
}
71
72
78
void
testUnitSquareCentroid()
79
{
80
vector<double> a;
81
vector<double> b;
82
83
a.push_back(0);
84
b.push_back(0);
85
a.push_back(1);
86
b.push_back(0);
87
a.push_back(1);
88
b.push_back(1);
89
a.push_back(0);
90
b.push_back(1);
91
92
MeasureOfStraightLines
measure;
93
94
trace
.
info
() <<
"Centroid measure of the unit square = ("
<< measure.
computeCentroidA
(a,b)
95
<<
","
<<measure.
computeCentroidB
(a,b)<<
")"
<<std::endl;
96
trace
.
emphase
() <<
"Expected value = (0.4142,0.5)"
<<endl;
97
}
98
99
100
int
main(
int
argc,
char
**argv)
101
{
102
trace
.
beginBlock
(
"Testing class MeasureOfStraightLines"
);
103
trace
.
info
() <<
"Args:"
;
104
for
(
int
i = 0; i < argc; ++i )
105
trace
.
info
() <<
" "
<< argv[ i ];
106
trace
.
info
() << endl;
107
108
testUnitSquare();
109
testUnitSquareCentroid();
110
111
trace
.
endBlock
();
112
113
return
0;
114
}
115
Generated on Wed Dec 19 2012 19:10:41 for DGtal by
1.8.1.1