DGtal  1.1.0
ScalarFunctors.h
1 
17 #pragma once
18 
31 #if defined(ScalarFunctors_RECURSES)
32 #error Recursive header files inclusion detected in ScalarFunctors.h
33 #else // defined(ScalarFunctors_RECURSES)
34 
35 #define ScalarFunctors_RECURSES
36 
37 #if !defined ScalarFunctors_h
38 
39 #define ScalarFunctors_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
46 
47 namespace DGtal {
48  namespace functors {
49 
54  template <typename TScalar>
55  struct HatFunction {
56  typedef TScalar Scalar;
58  typedef Scalar value_type;
59 
63 
64  public:
66  : myV0( v0 ), myV0OverR( v0 / r ), myR( r ) {}
68  { // d >= 0
69  ASSERT( d >= 0.0 );
70  if ( d >= myR ) return 0.0;
71  return myV0 - myV0OverR * d;
72  }
73  };
74 
79  template <typename TScalar>
81  typedef TScalar Scalar;
83  typedef Scalar value_type;
84 
87 
88  public:
90  : myV0( v0 ), myR( r ) {}
92  {// d >= 0
93  ASSERT( d >= 0.0 );
94  return ( d > myR ) ? 0.0 : myV0;
95  }
96  };
97 
98 
99  } // namespace functors
100 } // namespace DGtal
101 
102 
104 // Includes inline functions.
105 #include "DGtal/math/ScalarFunctors.ih"
106 
107 // //
109 
110 #endif // !defined ScalarFunctors_h
111 
112 #undef ScalarFunctors_RECURSES
113 #endif // else defined(ScalarFunctors_RECURSES)
DGtal::functors::BallConstantFunction::value_type
Scalar value_type
Definition: ScalarFunctors.h:83
DGtal::functors::BallConstantFunction::myR
Scalar myR
Definition: ScalarFunctors.h:86
DGtal::functors::BallConstantFunction::myV0
Scalar myV0
Definition: ScalarFunctors.h:85
DGtal::functors::BallConstantFunction::operator()
Scalar operator()(Scalar d) const
Definition: ScalarFunctors.h:91
DGtal::functors::HatFunction::myV0
Scalar myV0
Definition: ScalarFunctors.h:60
DGtal::functors::HatFunction
Definition: ScalarFunctors.h:55
DGtal::functors::HatFunction::Scalar
TScalar Scalar
Definition: ScalarFunctors.h:56
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::functors::BallConstantFunction::BallConstantFunction
BallConstantFunction(Scalar v0, Scalar r)
Definition: ScalarFunctors.h:89
DGtal::functors::HatFunction::myR
Scalar myR
Definition: ScalarFunctors.h:62
DGtal::functors::HatFunction::myV0OverR
Scalar myV0OverR
Definition: ScalarFunctors.h:61
DGtal::functors::BallConstantFunction::Scalar
TScalar Scalar
Definition: ScalarFunctors.h:81
DGtal::functors::HatFunction::operator()
Scalar operator()(Scalar d) const
Definition: ScalarFunctors.h:67
DGtal::functors::BallConstantFunction::argument_type
Scalar argument_type
Definition: ScalarFunctors.h:82
DGtal::functors::HatFunction::value_type
Scalar value_type
Definition: ScalarFunctors.h:58
DGtal::functors::HatFunction::HatFunction
HatFunction(Scalar v0, Scalar r)
Definition: ScalarFunctors.h:65
DGtal::functors::BallConstantFunction
Definition: ScalarFunctors.h:80
DGtal::functors::HatFunction::argument_type
Scalar argument_type
Definition: ScalarFunctors.h:57