25 #ifndef INCLUDED_ExponentialMap_h_GUID_FB61635E_CF8A_4FAE_5343_2258F4BC1E60 26 #define INCLUDED_ExponentialMap_h_GUID_FB61635E_CF8A_4FAE_5343_2258F4BC1E60 46 template <
typename Derived>
47 inline Eigen::Matrix3d
51 ret << 0, -v.z(), v.y(),
75 namespace matrix_exponential_map {
82 if (omega.squaredNorm() > M_PI * M_PI) {
84 omega = ((1 - (2 * M_PI) / omega.norm()) * omega).eval();
90 template <
typename Derived>
98 template <
typename Derived>
102 auto xyz = omega * std::sin(theta / 2.);
110 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
113 template <
typename Derived>
121 if (&other !=
this) {
122 m_omega = other.m_omega;
123 m_gotTheta = other.m_gotTheta;
125 m_theta = other.m_theta;
127 m_gotBigOmega = other.m_gotBigOmega;
129 m_bigOmega = other.m_bigOmega;
131 m_gotR = other.m_gotR;
135 m_gotQuat = other.m_gotQuat;
137 m_quat = other.m_quat;
145 if (&other !=
this) {
146 m_omega = std::move(other.m_omega);
147 m_gotTheta = std::move(other.m_gotTheta);
149 m_theta = std::move(other.m_theta);
151 m_gotBigOmega = std::move(other.m_gotBigOmega);
153 m_bigOmega = std::move(other.m_bigOmega);
155 m_gotR = std::move(other.m_gotR);
157 m_R = std::move(other.m_R);
159 m_gotQuat = std::move(other.m_gotQuat);
161 m_quat = std::move(other.m_quat);
167 template <
typename Derived>
177 if (!m_gotBigOmega) {
178 m_gotBigOmega =
true;
207 double k1 = 1. - theta * theta / 6.;
210 double k2 = theta / 2. - theta * theta * theta / 24.;
212 m_R = Eigen::Matrix3d::Identity() + k1 * Omega +
222 auto xyz = m_omega * std::sin(theta / 2.);
230 Eigen::Vector3d m_omega;
231 bool m_gotTheta =
false;
233 bool m_gotBigOmega =
false;
234 Eigen::Matrix3d m_bigOmega;
237 bool m_gotQuat =
false;
244 #endif // INCLUDED_ExponentialMap_h_GUID_FB61635E_CF8A_4FAE_5343_2258F4BC1E60 double getAngle(Eigen::MatrixBase< Derived > const &omega)
Gets the rotation angle of a rotation vector.
Definition: MatrixExponentialMap.h:91
void avoidSingularities(T &&omega)
Adjust a matrix exponential map rotation vector, if required, to avoid singularities.
Definition: MatrixExponentialMap.h:80
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Eigen::Matrix3d makeSkewSymmetrixCrossProductMatrix(Eigen::MatrixBase< Derived > const &v)
Produces the "hat matrix" that produces the same result as performing a cross-product with v...
Definition: MatrixExponentialMap.h:48
double getTheta()
Gets the rotation angle of a rotation vector.
Definition: MatrixExponentialMap.h:187
Header wrapping include of <Eigen/Core> and <Eigen/Geometry> for warning quieting.
Contained cached computed values.
Definition: MatrixExponentialMap.h:108
RealScalar norm() const
Definition: Dot.h:125
ExponentialMapData & operator=(ExponentialMapData const &other)
assignment operator - its presence is an optimization only.
Definition: MatrixExponentialMap.h:120
ExponentialMapData & operator=(ExponentialMapData &&other)
move-assignment operator - its presence is an optimization only.
Definition: MatrixExponentialMap.h:144
Eigen::Quaterniond getQuat(Eigen::MatrixBase< Derived > const &omega)
Gets the unit quaternion corresponding to the exponential rotation vector.
Definition: MatrixExponentialMap.h:100
Eigen::Matrix3d const & getRotationMatrix()
Converts a rotation vector to a rotation matrix: Uses Rodrigues' formula, and the first two terms of ...
Definition: MatrixExponentialMap.h:201
Definition: Quaternion.h:47
Quaternion< double > Quaterniond
double precision quaternion type
Definition: Quaternion.h:211
void reset(Eigen::MatrixBase< Derived > const &omega)
Definition: MatrixExponentialMap.h:168
Eigen::Matrix3d const & getBigOmega()
Gets the "capital omega" skew-symmetrix matrix.
Definition: MatrixExponentialMap.h:176
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ExponentialMapData(Eigen::MatrixBase< Derived > const &omega)
Construct from a matrixy-thing: should be a 3d vector containing a matrix-exponential-map rotation fo...
Definition: MatrixExponentialMap.h:114
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48