SurgSim
Math
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>
42
class
clampOperator
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
68
T
m_epsilon
;
69
};
70
71
};
72
};
73
74
#include "
SurgSim/Math/Scalar-inl.h
"
75
76
#endif // SURGSIM_MATH_SCALAR_H
SurgSim::Math::clamp
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
SurgSim::Math::clampOperator::clampOperator
clampOperator(const T &min, const T &max, const T &epsilon)
Constructor.
Definition:
Scalar.h:51
SurgSim
Definition:
CompoundShapeToGraphics.cpp:29
SurgSim::Math::clampOperator::operator()
const T operator()(const T &x) const
Execute the clamp operator.
Definition:
Scalar-inl.h:33
SurgSim::Math::clampOperator::m_epsilon
T m_epsilon
The closeness parameter for the clamp.
Definition:
Scalar.h:68
Scalar-inl.h
SurgSim::Math::clampOperator
define a custom template unary functor to execute the clamp operation over an Eigen matrix structure.
Definition:
Scalar.h:42
SurgSim::Math::clampOperator::m_max
T m_max
The maximum value of the interval.
Definition:
Scalar.h:64
SurgSim::Math::clampOperator::m_min
T m_min
The minimum value of the interval.
Definition:
Scalar.h:61
Generated on Sun Feb 9 2020 17:22:37 for OpenSurgSim by
1.8.16