DGtal  1.5.beta
testMeasure.cpp File Reference
#include <cstdio>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include "DGtal/base/Common.h"
#include "DGtal/math/MeasureOfStraightLines.h"
Include dependency graph for testMeasure.cpp:

Go to the source code of this file.

Functions

void testUnitSquare ()
 
void testUnitSquareCentroid ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2011/06/25

Functions for testing class Measure.

This file is part of the DGtal library.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr )
Date
2010/03/03

This file is part of the DGtal library

Definition in file testMeasure.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 100 of file testMeasure.cpp.

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 }
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
Trace trace
Definition: Common.h:153
void testUnitSquareCentroid()
Definition: testMeasure.cpp:78
void testUnitSquare()
Definition: testMeasure.cpp:51

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testUnitSquare(), testUnitSquareCentroid(), and DGtal::trace.

◆ testUnitSquare()

void testUnitSquare ( )

Compute the measure of the unit square [0,1]x[0,1]

Expected value : sqrt{2}/2

Definition at line 51 of file testMeasure.cpp.

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 }
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)
std::ostream & emphase()

References DGtal::MeasureOfStraightLines::computeMeasure(), DGtal::Trace::emphase(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

◆ testUnitSquareCentroid()

void testUnitSquareCentroid ( )

Compute the measure of the unit square [0,1]x[0,1]

Expected value : sqrt{2}/2

Definition at line 78 of file testMeasure.cpp.

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 }
double computeCentroidA(const std::vector< double > &a, const std::vector< double > &b)
double computeCentroidB(const std::vector< double > &a, const std::vector< double > &b)

References DGtal::MeasureOfStraightLines::computeCentroidA(), DGtal::MeasureOfStraightLines::computeCentroidB(), DGtal::Trace::emphase(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().