Scalar.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_MATH_SCALAR_H
17 #define SURGSIM_MATH_SCALAR_H
18 
19 namespace SurgSim
20 {
21 namespace Math
22 {
31 template <class T>
32 T clamp(T value, T min, T max, T epsilon);
33 
41 template<typename T>
43 {
44 public:
51  clampOperator(const T& min, const T& max, const T& epsilon) : m_min(min), m_max(max),
52  m_epsilon(epsilon) {}
53 
57  const T operator()(const T& x) const;
58 
59 private:
61  T m_min;
62 
64  T m_max;
65 
69 };
70 
71 };
72 };
73 
75 
76 #endif // SURGSIM_MATH_SCALAR_H
T m_max
The maximum value of the interval.
Definition: Scalar.h:64
Definition: CompoundShapeToGraphics.cpp:29
T m_epsilon
The closeness parameter for the clamp.
Definition: Scalar.h:68
clampOperator(const T &min, const T &max, const T &epsilon)
Constructor.
Definition: Scalar.h:51
T clamp(T value, T min, T max, T epsilon)
Clamp any values within an epsilon window to a maximum or minimum value.
Definition: Scalar-inl.h:27
T m_min
The minimum value of the interval.
Definition: Scalar.h:61
define a custom template unary functor to execute the clamp operation over an Eigen matrix structure...
Definition: Scalar.h:42
const T operator()(const T &x) const
Execute the clamp operator.
Definition: Scalar-inl.h:33