11#ifndef EIGEN_ANGLEAXIS_H
12#define EIGEN_ANGLEAXIS_H
15#include "./InternalHeaderCheck.h"
46template <
typename Scalar_>
47struct traits<AngleAxis<Scalar_> > {
48 using Scalar = Scalar_;
52template <
typename Scalar_>
57 using Base::operator*;
78 template <
typename Derived>
84 template <
typename QuatDerived>
89 template <
typename Derived>
100 EIGEN_DEVICE_FUNC
const Vector3&
axis()
const {
return m_axis; }
105 EIGEN_DEVICE_FUNC Vector3&
axis() {
return m_axis; }
109 return QuaternionType(*
this) * QuaternionType(other);
113 EIGEN_DEVICE_FUNC
inline QuaternionType
operator*(
const QuaternionType& other)
const {
114 return QuaternionType(*
this) * other;
118 friend EIGEN_DEVICE_FUNC
inline QuaternionType
operator*(
const QuaternionType& a,
const AngleAxis& b) {
119 return a * QuaternionType(b);
125 template <
class QuatDerived>
127 template <
typename Derived>
130 template <
typename Derived>
136 template <
typename OtherVectorType>
137 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3
_transformVector(
const OtherVectorType& v)
const {
140 eigen_assert(v.size() == 3);
144 const Scalar c = cos(m_angle);
145 const Scalar s = sin(m_angle);
146 return v3 * c + m_axis.cross(v3) * s + m_axis * (m_axis.dot(v3) * (
Scalar(1) - c));
154 template <
typename NewScalarType>
155 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<AngleAxis, AngleAxis<NewScalarType> >::type
cast()
157 return typename internal::cast_return_type<AngleAxis, AngleAxis<NewScalarType> >::type(*
this);
161 template <
typename OtherScalarType>
173 EIGEN_DEVICE_FUNC
bool isApprox(
const AngleAxis& other,
const typename NumTraits<Scalar>::Real& prec =
174 NumTraits<Scalar>::dummy_precision())
const {
175 return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle, other.m_angle, prec);
192template <
typename Scalar>
193template <
typename QuatDerived>
195 EIGEN_USING_STD(
atan2)
198 if (n < NumTraits<Scalar>::epsilon()) n = q.
vec().stableNorm();
203 m_axis = q.
vec() / n;
213template <
typename Scalar>
214template <
typename Derived>
217 if (mat.size() == 4) {
218 return *
this = QuaternionType(mat);
220 return fromRotationMatrix(mat);
228template <
typename Scalar>
229template <
typename Derived>
232 (std::is_same<Scalar, typename Derived::Scalar>::value),
233 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
234 eigen_assert(mat.cols() == 3 && mat.rows() == 3);
241 internal::quaternionbase_assign_impl<Derived, 3, 3>::template run<false>(q, mat.derived());
247template <
typename Scalar>
252 Vector3 sin_axis = sin(m_angle) * m_axis;
254 Vector3 cos1_axis = (
Scalar(1) - c) * m_axis;
257 tmp = cos1_axis.x() * m_axis.y();
258 res.
coeffRef(0, 1) = tmp - sin_axis.z();
259 res.
coeffRef(1, 0) = tmp + sin_axis.z();
261 tmp = cos1_axis.x() * m_axis.z();
262 res.
coeffRef(0, 2) = tmp + sin_axis.y();
263 res.
coeffRef(2, 0) = tmp - sin_axis.y();
265 tmp = cos1_axis.y() * m_axis.z();
266 res.
coeffRef(1, 2) = tmp - sin_axis.x();
267 res.
coeffRef(2, 1) = tmp + sin_axis.x();
269 res.diagonal() = cos1_axis.cwiseProduct(m_axis).array() + c;
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
Definition AngleAxis.h:53
QuaternionType operator*(const QuaternionType &other) const
Definition AngleAxis.h:113
AngleAxis(const AngleAxis< OtherScalarType > &other)
Definition AngleAxis.h:162
QuaternionType operator*(const AngleAxis &other) const
Definition AngleAxis.h:108
Scalar & angle()
Definition AngleAxis.h:97
Vector3 & axis()
Definition AngleAxis.h:105
AngleAxis(const QuaternionBase< QuatDerived > &q)
Definition AngleAxis.h:85
internal::cast_return_type< AngleAxis, AngleAxis< NewScalarType > >::type cast() const
Definition AngleAxis.h:155
Vector3 _transformVector(const OtherVectorType &v) const
Definition AngleAxis.h:137
AngleAxis(const Scalar &angle, const MatrixBase< Derived > &axis)
Definition AngleAxis.h:79
Scalar_ Scalar
Definition AngleAxis.h:61
AngleAxis(const MatrixBase< Derived > &m)
Definition AngleAxis.h:90
AngleAxis inverse() const
Definition AngleAxis.h:123
const Vector3 & axis() const
Definition AngleAxis.h:100
AngleAxis()
Definition AngleAxis.h:72
bool isApprox(const AngleAxis &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition AngleAxis.h:173
friend QuaternionType operator*(const QuaternionType &a, const AngleAxis &b)
Definition AngleAxis.h:118
Matrix3 toRotationMatrix(void) const
Definition AngleAxis.h:248
Scalar angle() const
Definition AngleAxis.h:95
const std::enable_if_t< std::is_same< typename LhsDerived::Scalar, typename RhsDerived::Scalar >::value, Eigen::CwiseBinaryOp< Eigen::internal::scalar_atan2_op< typename LhsDerived::Scalar, typename RhsDerived::Scalar >, const LhsDerived, const RhsDerived > > atan2(const Eigen::ArrayBase< LhsDerived > &x, const Eigen::ArrayBase< RhsDerived > &exponents)
Definition GlobalFunctions.h:222
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:53
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:188
constexpr Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:205
Base class for quaternion expressions.
Definition Quaternion.h:36
const VectorBlock< const Coefficients, 3 > vec() const
Definition Quaternion.h:78
constexpr CoeffReturnType w() const
Definition Quaternion.h:66
The quaternion class used to represent 3D orientations and rotations.
Definition Quaternion.h:304
Common base class for compact rotation representations.
Definition RotationBase.h:33
AngleAxis< double > AngleAxisd
Definition AngleAxis.h:184
AngleAxis< float > AngleAxisf
Definition AngleAxis.h:181