DGtal 1.3.0
Loading...
Searching...
No Matches
testLpMetric.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include "DGtal/base/Common.h"
33#include "ConfigTest.h"
34#include "DGtalCatch.h"
35#include "DGtal/helpers/StdDefs.h"
36#include "DGtal/geometry/volumes/distance/LpMetric.h"
37#include "DGtal/geometry/volumes/distance/CMetricSpace.h"
39
40using namespace std;
41using namespace DGtal;
42
44// Functions for testing class LpMetric.
46TEST_CASE( "Testing LpMetric" )
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}
68
Aim: implements l_p metrics.
Definition: LpMetric.h:75
Closest closest(const Point &origin, const Point &first, const Point &second) const
Definition: LpMetric.h:170
RawValue rawDistance(const Point &aP, const Point &aQ) const
Definition: LpMetric.h:150
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
DGtal is the top-level namespace which contains all DGtal functions and types.
@ ClosestBOTH
Definition: Common.h:147
@ ClosestFIRST
Definition: Common.h:147
STL namespace.
Aim: defines the concept of metric spaces.
Definition: CMetricSpace.h:125
CAPTURE(thicknessHV)
TEST_CASE("Testing LpMetric")
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))