DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testMeasure.cpp
Go to the documentation of this file.
1
16
26
31
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
DGtal::MeasureOfStraightLines
The aim of this class is to compute the measure in the Lebesgues sense of the set of straight lines a...
Definition
MeasureOfStraightLines.h:80
DGtal::MeasureOfStraightLines::computeMeasure
double computeMeasure(const std::vector< double > &a, const std::vector< double > &b)
DGtal::MeasureOfStraightLines::computeCentroidA
double computeCentroidA(const std::vector< double > &a, const std::vector< double > &b)
DGtal::MeasureOfStraightLines::computeCentroidB
double computeCentroidB(const std::vector< double > &a, const std::vector< double > &b)
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
testUnitSquareCentroid
void testUnitSquareCentroid()
Definition
testMeasure.cpp:78
testUnitSquare
void testUnitSquare()
Definition
testMeasure.cpp:51
tests
math
testMeasure.cpp
Generated on
for DGtal by
1.18.0