DGtal 1.4.0
Loading...
Searching...
No Matches
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
41using namespace DGtal;
42using 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
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
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
100int 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
110
111 trace.endBlock();
112
113 return 0;
114}
115
The aim of this class is to compute the measure in the Lebesgues sense of the set of straight lines a...
double computeMeasure(const std::vector< double > &a, const std::vector< double > &b)
double computeCentroidA(const std::vector< double > &a, const std::vector< double > &b)
double computeCentroidB(const std::vector< double > &a, const std::vector< double > &b)
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
int main()
Definition testBits.cpp:56
void testUnitSquareCentroid()
void testUnitSquare()