DGtal  0.9.3
testMeasure.cpp
Go to the documentation of this file.
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 
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 
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();
110 
111  trace.endBlock();
112 
113  return 0;
114 }
115 
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
The aim of this class is to compute the measure in the Lebesgues sense of the set of straight lines a...
STL namespace.
double endBlock()
void testUnitSquareCentroid()
Definition: testMeasure.cpp:78
double computeMeasure(const std::vector< double > &a, const std::vector< double > &b)
double computeCentroidA(const std::vector< double > &a, const std::vector< double > &b)
void testUnitSquare()
Definition: testMeasure.cpp:51
int main(int argc, char **argv)
std::ostream & emphase()
double computeCentroidB(const std::vector< double > &a, const std::vector< double > &b)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()