DGtal
1.4.0
Loading...
Searching...
No Matches
Point2ScalarFunctors.h
1
17
#pragma once
18
31
#if defined(Point2ScalarFunctors_RECURSES)
32
#error Recursive header files inclusion detected in Point2ScalarFunctors.h
33
#else
// defined(Point2ScalarFunctors_RECURSES)
35
#define Point2ScalarFunctors_RECURSES
36
37
#if !defined Point2ScalarFunctors_h
39
#define Point2ScalarFunctors_h
40
42
// Inclusions
43
#include <iostream>
44
#include "DGtal/base/Common.h"
46
47
namespace
DGtal
{
48
namespace
functors {
49
54
template
<
typename
TPo
int
,
typename
TScalar>
55
struct
HatPointFunction
{
56
typedef
TPoint
Point
;
57
typedef
TScalar
Scalar
;
58
typedef
Point
argument_type
;
59
typedef
Scalar
value_type
;
60
61
Scalar
myV0
;
62
Scalar
myV0OverR
;
63
Scalar
myR
;
64
Scalar
myR2
;
65
66
public
:
67
HatPointFunction
(
Scalar
v0,
Scalar
r )
68
:
myV0
( v0 ),
myV0OverR
( v0 / r ),
myR
( r ),
myR2
( r*r ) {}
69
Scalar
operator()
(
const
Point
& p )
const
70
{
71
Scalar
d = 0;
72
for
(
typename
Point::ConstIterator it = p.begin(), itE = p.end(); it != itE; ++it )
73
d +=
functions::square
( (
Scalar
) *it );
74
if
( d >=
myR2
)
return
0.0;
75
d = sqrt( d );
76
return
myV0
-
myV0OverR
* d;
77
}
78
};
79
84
template
<
typename
TPo
int
,
typename
TScalar>
85
struct
BallConstantPointFunction
{
86
typedef
TPoint
Point
;
87
typedef
TScalar
Scalar
;
88
typedef
Point
argument_type
;
89
typedef
Scalar
value_type
;
90
91
Scalar
myV0
;
92
Scalar
myR2
;
93
94
public
:
95
BallConstantPointFunction
(
Scalar
v0,
Scalar
r )
96
:
myV0
( v0 ),
myR2
( r*r ) {}
97
Scalar
operator()
(
const
Point
& p )
const
98
{
99
Scalar
d = 0;
100
for
(
typename
Point::ConstIterator it = p.begin(), itE = p.end(); it != itE; ++it )
101
d +=
functions::square
( (
Scalar
) *it );
102
return
( d >
myR2
) ? 0.0 :
myV0
;
103
}
104
};
105
106
}
// namespace functors
107
}
// namespace DGtal
108
109
111
// Includes inline functions.
112
#include "DGtal/kernel/Point2ScalarFunctors.ih"
113
114
// //
116
117
#endif
// !defined Point2ScalarFunctors_h
118
119
#undef Point2ScalarFunctors_RECURSES
120
#endif
// else defined(Point2ScalarFunctors_RECURSES)
DGtal::functions::square
T square(T x)
Definition
BasicMathFunctions.h:133
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::functors::BallConstantPointFunction
Definition
Point2ScalarFunctors.h:85
DGtal::functors::BallConstantPointFunction::BallConstantPointFunction
BallConstantPointFunction(Scalar v0, Scalar r)
Definition
Point2ScalarFunctors.h:95
DGtal::functors::BallConstantPointFunction::Point
TPoint Point
Definition
Point2ScalarFunctors.h:86
DGtal::functors::BallConstantPointFunction::argument_type
Point argument_type
Definition
Point2ScalarFunctors.h:88
DGtal::functors::BallConstantPointFunction::myV0
Scalar myV0
Definition
Point2ScalarFunctors.h:91
DGtal::functors::BallConstantPointFunction::myR2
Scalar myR2
Definition
Point2ScalarFunctors.h:92
DGtal::functors::BallConstantPointFunction::Scalar
TScalar Scalar
Definition
Point2ScalarFunctors.h:87
DGtal::functors::BallConstantPointFunction::value_type
Scalar value_type
Definition
Point2ScalarFunctors.h:89
DGtal::functors::BallConstantPointFunction::operator()
Scalar operator()(const Point &p) const
Definition
Point2ScalarFunctors.h:97
DGtal::functors::HatPointFunction
Definition
Point2ScalarFunctors.h:55
DGtal::functors::HatPointFunction::myV0OverR
Scalar myV0OverR
Definition
Point2ScalarFunctors.h:62
DGtal::functors::HatPointFunction::value_type
Scalar value_type
Definition
Point2ScalarFunctors.h:59
DGtal::functors::HatPointFunction::Scalar
TScalar Scalar
Definition
Point2ScalarFunctors.h:57
DGtal::functors::HatPointFunction::myR
Scalar myR
Definition
Point2ScalarFunctors.h:63
DGtal::functors::HatPointFunction::HatPointFunction
HatPointFunction(Scalar v0, Scalar r)
Definition
Point2ScalarFunctors.h:67
DGtal::functors::HatPointFunction::argument_type
Point argument_type
Definition
Point2ScalarFunctors.h:58
DGtal::functors::HatPointFunction::myV0
Scalar myV0
Definition
Point2ScalarFunctors.h:61
DGtal::functors::HatPointFunction::Point
TPoint Point
Definition
Point2ScalarFunctors.h:56
DGtal::functors::HatPointFunction::operator()
Scalar operator()(const Point &p) const
Definition
Point2ScalarFunctors.h:69
DGtal::functors::HatPointFunction::myR2
Scalar myR2
Definition
Point2ScalarFunctors.h:64
src
DGtal
kernel
Point2ScalarFunctors.h
Generated on Mon Jun 10 2024 17:36:04 for DGtal by
1.11.0