30#include "DGtal/kernel/CPointFunctor.h"
31#include "DGtal/kernel/PointVector.h"
32#include "DGtal/kernel/PointFunctorHolder.h"
34#include "DGtalCatch.h"
36template <
typename T,
typename Po
int>
37T kernel(
Point const& pt,
Point const& center, T radius)
39 return (pt - center).norm() - radius;
42template <
typename T,
typename Po
int>
58TEST_CASE(
"2D PointFunctorHolder from functor by rvalue",
"[2D][functor][rvalue]" )
60 using namespace DGtal;
70 std::cout << fn << std::endl;
74 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
77TEST_CASE(
"2D PointFunctorHolder from functor by lvalue",
"[2D][functor][lvalue]" )
79 using namespace DGtal;
90 std::cout << fn << std::endl;
94 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
97TEST_CASE(
"2D PointFunctorHolder from lambda by rvalue",
"[2D][lambda][rvalue]" )
99 using namespace DGtal;
101 using Value = double;
104 const Value radius = 1;
107 [¢er, &radius] (
Point const& pt) {
return kernel<Value>(pt, center, radius); }
114 std::cout << fn << std::endl;
118 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
121TEST_CASE(
"2D PointFunctorHolder from lambda by lvalue",
"[2D][lambda][lvalue]" )
123 using namespace DGtal;
125 using Value = double;
128 const Value radius = 1;
130 const auto lambda = [&
center, &radius] (
Point const& pt) {
return kernel<Value>(pt, center, radius); };
137 std::cout << fn << std::endl;
141 REQUIRE( fn(
Point(2, 1)) == Approx( std::sqrt(2) - 1. ) );
Aim: Implements basic operations that will be used in Point and Vector classes.
Point center(const std::vector< Point > &points)
auto holdPointFunctor(TFunctor &&aFunctor) -> PointFunctorHolder< TPoint, TValue, decltype(holdFunctor(std::forward< TFunctor >(aFunctor)))>
PointFunctorHolder construction helper with specification of the return type.
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines a functor on points.
double operator()(double v) const
Functor(Point const &c, T r)
TEST_CASE("int container traits", "[int][traits]")
InHalfPlaneBySimple3x3Matrix< Point, double > Functor
REQUIRE(domain.isInside(aPoint))