DGtal 1.4.0
Loading...
Searching...
No Matches
testLpMetric.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "ConfigTest.h"
#include "DGtalCatch.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/volumes/distance/LpMetric.h"
#include "DGtal/geometry/volumes/distance/CMetricSpace.h"
Include dependency graph for testLpMetric.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("Testing LpMetric")
 

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 Systemes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2019/01/27

Functions for testing class LpMetric.

This file is part of the DGtal library.

Definition in file testLpMetric.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "Testing LpMetric" )

Definition at line 46 of file testLpMetric.cpp.

47{
48
49 BOOST_CONCEPT_ASSERT(( concepts::CMetricSpace<LpMetric<Z2i::Space>> ));
50
51 LpMetric<Z2i::Space> l2_2D(2.0);
52 LpMetric<Z3i::Space> l2_3D(2.0);
53 LpMetric<Z2i::Space> l55_2D(5.5);
54 Z2i::Space::RealPoint a(0,0), b(1.0,1.0), c(0.5,0.5);
55 Z3i::Space::RealPoint aa(0,0,0), bb(1.0,1.0,1.0);
56
57 SECTION("Testing LpMetric distance values")
58 {
59 CAPTURE( l55_2D) ;
60 REQUIRE( l2_2D.rawDistance(a,b) == Approx(2.0) );
61 REQUIRE( l2_3D.rawDistance(aa,bb) == Approx(3.0) );
62 REQUIRE( l2_2D(a,b) == Approx(std::sqrt(2.0)) );
63 REQUIRE( l55_2D(a,b) == Approx(1.1343125) );
64 REQUIRE( l2_2D.closest(a,c,b) == DGtal::ClosestFIRST );
65 REQUIRE( l2_2D.closest(c,a,b) == DGtal::ClosestBOTH );
66 }
67}
Aim: implements l_p metrics.
Definition LpMetric.h:75
Aim: Implements basic operations that will be used in Point and Vector classes.
@ ClosestBOTH
Definition Common.h:146
@ ClosestFIRST
Definition Common.h:146
Aim: defines the concept of metric spaces.
CAPTURE(thicknessHV)
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References CAPTURE(), DGtal::LpMetric< TSpace >::closest(), DGtal::ClosestBOTH, DGtal::ClosestFIRST, DGtal::LpMetric< TSpace >::rawDistance(), REQUIRE(), and SECTION().