10 #ifndef EIGEN_ANGLEAXIS_H 11 #define EIGEN_ANGLEAXIS_H 44 typedef _Scalar Scalar;
48 template<
typename _Scalar>
55 using Base::operator*;
78 template<
typename Derived>
84 template<
typename QuatDerived>
87 template<
typename Derived>
91 EIGEN_DEVICE_FUNC Scalar
angle()
const {
return m_angle; }
93 EIGEN_DEVICE_FUNC Scalar&
angle() {
return m_angle; }
96 EIGEN_DEVICE_FUNC
const Vector3&
axis()
const {
return m_axis; }
101 EIGEN_DEVICE_FUNC Vector3&
axis() {
return m_axis; }
104 EIGEN_DEVICE_FUNC
inline QuaternionType operator* (
const AngleAxis& other)
const 105 {
return QuaternionType(*
this) * QuaternionType(other); }
108 EIGEN_DEVICE_FUNC
inline QuaternionType operator* (
const QuaternionType& other)
const 109 {
return QuaternionType(*
this) * other; }
112 friend EIGEN_DEVICE_FUNC
inline QuaternionType operator* (
const QuaternionType& a,
const AngleAxis& b)
113 {
return a * QuaternionType(b); }
119 template<
class QuatDerived>
121 template<
typename Derived>
124 template<
typename Derived>
126 EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix(
void)
const;
133 template<
typename NewScalarType>
138 template<
typename OtherScalarType>
141 m_axis = other.
axis().template cast<Scalar>();
142 m_angle = Scalar(other.
angle());
145 EIGEN_DEVICE_FUNC
static inline const AngleAxis Identity() {
return AngleAxis(Scalar(0), Vector3::UnitX()); }
152 {
return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle,other.m_angle, prec); }
168 template<
typename Scalar>
169 template<
typename QuatDerived>
172 EIGEN_USING_STD_MATH(atan2)
173 EIGEN_USING_STD_MATH(abs)
174 Scalar n = q.
vec().norm();
176 n = q.
vec().stableNorm();
180 m_angle = Scalar(2)*atan2(n, abs(q.
w()));
183 m_axis = q.
vec() / n;
188 m_axis << Scalar(1), Scalar(0), Scalar(0);
195 template<
typename Scalar>
196 template<
typename Derived>
201 return *
this = QuaternionType(mat);
207 template<
typename Scalar>
208 template<
typename Derived>
211 return *
this = QuaternionType(mat);
216 template<
typename Scalar>
220 EIGEN_USING_STD_MATH(sin)
221 EIGEN_USING_STD_MATH(cos)
223 Vector3 sin_axis = sin(m_angle) * m_axis;
224 Scalar c = cos(m_angle);
225 Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
228 tmp = cos1_axis.x() * m_axis.y();
229 res.
coeffRef(0,1) = tmp - sin_axis.z();
230 res.
coeffRef(1,0) = tmp + sin_axis.z();
232 tmp = cos1_axis.x() * m_axis.z();
233 res.
coeffRef(0,2) = tmp + sin_axis.y();
234 res.
coeffRef(2,0) = tmp - sin_axis.y();
236 tmp = cos1_axis.y() * m_axis.z();
237 res.
coeffRef(1,2) = tmp - sin_axis.x();
238 res.
coeffRef(2,1) = tmp + sin_axis.x();
240 res.diagonal() = (cos1_axis.cwiseProduct(m_axis)).
array() + c;
247 #endif // EIGEN_ANGLEAXIS_H Definition: XprHelper.h:489
EIGEN_DEVICE_FUNC AngleAxis(const MatrixBase< Derived > &m)
Constructs and initialize the angle-axis rotation from a 3x3 rotation matrix.
Definition: AngleAxis.h:88
EIGEN_DEVICE_FUNC AngleAxis(const Scalar &angle, const MatrixBase< Derived > &axis)
Constructs and initialize the angle-axis rotation from an angle in radian and an axis which must be n...
Definition: AngleAxis.h:80
EIGEN_DEVICE_FUNC const VectorBlock< const Coefficients, 3 > vec() const
Definition: Quaternion.h:79
EIGEN_DEVICE_FUNC internal::cast_return_type< AngleAxis, AngleAxis< NewScalarType > >::type cast() const
Definition: AngleAxis.h:134
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
AngleAxis< double > AngleAxisd
double precision angle-axis type
Definition: AngleAxis.h:160
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
EIGEN_DEVICE_FUNC Scalar w() const
Definition: Quaternion.h:67
EIGEN_DEVICE_FUNC AngleAxis()
Default constructor without initialization.
Definition: AngleAxis.h:72
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
Definition: PlainObjectBase.h:177
EIGEN_DEVICE_FUNC Scalar angle() const
Definition: AngleAxis.h:91
AngleAxis< float > AngleAxisf
single precision angle-axis type
Definition: AngleAxis.h:157
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:266
_Scalar Scalar
the scalar type of the coefficients
Definition: AngleAxis.h:59
Definition: ForwardDeclarations.h:268
EIGEN_DEVICE_FUNC const Vector3 & axis() const
Definition: AngleAxis.h:96
Definition: EmulateArray.h:21
EIGEN_DEVICE_FUNC AngleAxis inverse() const
Definition: AngleAxis.h:116
Definition: BandTriangularSolver.h:13
Definition: ForwardDeclarations.h:273
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix(void) const
Constructs and.
Definition: AngleAxis.h:218
EIGEN_DEVICE_FUNC Vector3 & axis()
Definition: AngleAxis.h:101
EIGEN_DEVICE_FUNC Scalar & angle()
Definition: AngleAxis.h:93
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
EIGEN_DEVICE_FUNC AngleAxis(const QuaternionBase< QuatDerived > &q)
Constructs and initialize the angle-axis rotation from a quaternion q.
Definition: AngleAxis.h:85
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:270
Definition: ForwardDeclarations.h:17
EIGEN_DEVICE_FUNC AngleAxis(const AngleAxis< OtherScalarType > &other)
Copy constructor with scalar type conversion.
Definition: AngleAxis.h:139
EIGEN_DEVICE_FUNC bool isApprox(const AngleAxis &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: AngleAxis.h:151