25 #ifndef INCLUDED_EigenQuatExponentialMap_h_GUID_7E15BC44_BCFB_438B_902B_BA0787BEE405 26 #define INCLUDED_EigenQuatExponentialMap_h_GUID_7E15BC44_BCFB_438B_902B_BA0787BEE405 39 namespace ei_quat_exp_map {
44 static double get() {
return 1.e-13; }
48 static float get() {
return 1.e-6f; }
53 template <
typename Scalar>
inline Scalar
sinc(Scalar theta) {
66 ret = std::sin(theta) / theta;
71 template <
typename Derived>
74 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
86 Scalar theta = vec.
norm();
87 Scalar vecscale =
sinc(theta);
89 ret.
vec() = vecscale * vec;
90 ret.
w() = std::cos(theta);
96 template <
typename Scalar>
100 (theta * theta) /
Scalar(6) +
102 (
Scalar(7) * theta * theta * theta * theta) /
Scalar(360) +
104 (
Scalar(31) * theta * theta * theta * theta * theta *
115 template <
typename Scalar>
122 Scalar vecnorm = quat.
vec().norm();
125 Scalar phi = std::atan2(vecnorm, quat.
w());
133 vecnorm < 1e-4 ? cscTaylorExpansion<Scalar>(phi)
134 : (phi / std::sin(phi));
135 return quat.
vec() * phiOverSin;
140 template <
typename Derived>
143 template <
typename Derived>
146 template <
typename Derived>
152 using Derived = Derived_;
155 Derived
const &derived()
const {
156 return *
static_cast<Derived
const *
>(
this);
162 static const double eps = 1.e-2;
163 ScalarType<Derived> vecNorm = myVec.norm();
164 if (vecNorm > M_PI - eps) {
167 myVec *= ((1. - 2. * M_PI) / vecNorm);
176 using type = Scalar_;
179 template <
typename Scalar_>
182 using Scalar = Scalar_;
186 VecType const &vec()
const {
return m_vec; }
188 static const bool AlwaysPureVec =
true;
189 static bool pureVec() {
return true; }
198 using type = Scalar_;
203 template <
typename Scalar_>
206 using Scalar = Scalar_;
222 static const bool AlwaysPureVec =
false;
225 return m_quat.w() == 0;
232 template <
typename Scalar>
238 template <
typename Scalar>
244 using ei_quat_exp_map::quat_exp;
245 using ei_quat_exp_map::quat_ln;
246 using ei_quat_exp_map::quat_exp_map;
250 #endif // INCLUDED_EigenQuatExponentialMap_h_GUID_7E15BC44_BCFB_438B_902B_BA0787BEE405 Matrix< Scalar, 4, 1 > Coefficients
the type of the Coefficients 4-vector
Definition: Quaternion.h:60
Definition: EigenQuatExponentialMap.h:138
Definition: RunLoopManager.h:42
Definition: EigenQuatExponentialMap.h:173
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: EigenQuatExponentialMap.h:41
Scalar sinc(Scalar theta)
Computes the "historical" (un-normalized) sinc(Theta) (sine(theta)/theta for theta != 0...
Definition: EigenQuatExponentialMap.h:53
VecType< Derived > avoidSingularities() const
Definition: EigenQuatExponentialMap.h:159
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
const Block< const Coefficients, 3, 1 > vec() const
Definition: Quaternion.h:87
RealScalar norm() const
Definition: Dot.h:125
Expression of a fixed-size or dynamic-size sub-vector.
Definition: ForwardDeclarations.h:83
LogVectorType ln() const
Gets the log of the quat, in the exponential-map sense, as a 3d vector.
Definition: EigenQuatExponentialMap.h:216
VecBlock vec() const
Access to just the vector part, in case we're actually trying to exponentiate here.
Definition: EigenQuatExponentialMap.h:220
Scalar w() const
Definition: Quaternion.h:75
Eigen::Quaternion< typename Derived::Scalar > quat_exp(Eigen::MatrixBase< Derived > const &vec)
fully-templated free function for quaternion expontiation
Definition: EigenQuatExponentialMap.h:73
bool pureVec() const
Definition: EigenQuatExponentialMap.h:223
Definition: Quaternion.h:47
CRTP base for quaternion exponential map.
Definition: EigenQuatExponentialMap.h:150
Wrapper class for a quaternion to provide access to ln() in its exponential-map meaning.
Definition: EigenQuatExponentialMap.h:196
Quaternion normalized() const
Definition: Quaternion.h:154
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::Matrix< Scalar, 3, 1 > quat_ln(Eigen::Quaternion< Scalar > const &quat)
fully-templated free function for quaternion log map, intended for implementation use within the clas...
Definition: EigenQuatExponentialMap.h:117
Scalar cscTaylorExpansion(Scalar theta)
Taylor series expansion of theta over sin(theta), aka cosecant, for use near 0 when you want continui...
Definition: EigenQuatExponentialMap.h:97
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48