10#ifndef EIGEN_ANGLEAXIS_H
11#define EIGEN_ANGLEAXIS_H
42template<
typename _Scalar>
struct traits<AngleAxis<_Scalar> >
44 typedef _Scalar Scalar;
48template<
typename _Scalar>
51 typedef RotationBase<AngleAxis<_Scalar>,3>
Base;
55 using Base::operator*;
60 typedef Matrix<Scalar,3,3> Matrix3;
61 typedef Matrix<Scalar,3,1>
Vector3;
78 template<
typename Derived>
84 template<
typename QuatDerived>
85 EIGEN_DEVICE_FUNC
inline explicit AngleAxis(
const QuaternionBase<QuatDerived>& q) { *
this = q; }
87 template<
typename Derived>
88 EIGEN_DEVICE_FUNC
inline explicit AngleAxis(
const MatrixBase<Derived>& m) { *
this = m; }
96 EIGEN_DEVICE_FUNC
const Vector3&
axis()
const {
return m_axis; }
119 template<
class QuatDerived>
120 EIGEN_DEVICE_FUNC
AngleAxis& operator=(
const QuaternionBase<QuatDerived>& q);
121 template<
typename Derived>
122 EIGEN_DEVICE_FUNC
AngleAxis& operator=(
const MatrixBase<Derived>& m);
124 template<
typename Derived>
125 EIGEN_DEVICE_FUNC
AngleAxis& fromRotationMatrix(
const MatrixBase<Derived>& m);
133 template<
typename NewScalarType>
134 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type
cast()
const
135 {
return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*
this); }
138 template<
typename OtherScalarType>
139 EIGEN_DEVICE_FUNC
inline explicit AngleAxis(
const AngleAxis<OtherScalarType>& other)
141 m_axis = other.axis().template cast<Scalar>();
142 m_angle =
Scalar(other.angle());
152 {
return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle,other.m_angle, prec); }
168template<
typename Scalar>
169template<
typename QuatDerived>
172 EIGEN_USING_STD(atan2)
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;
195template<
typename Scalar>
196template<
typename Derived>
207template<
typename Scalar>
208template<
typename Derived>
216template<
typename Scalar>
217typename AngleAxis<Scalar>::Matrix3
223 Vector3 sin_axis = sin(m_angle) * 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;
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
Definition AngleAxis.h:50
AngleAxis()
Definition AngleAxis.h:72
Scalar & angle()
Definition AngleAxis.h:93
Vector3 & axis()
Definition AngleAxis.h:101
AngleAxis(const MatrixBase< Derived > &m)
Definition AngleAxis.h:88
Scalar angle() const
Definition AngleAxis.h:91
AngleAxis(const AngleAxis< OtherScalarType > &other)
Definition AngleAxis.h:139
AngleAxis(const Scalar &angle, const MatrixBase< Derived > &axis)
Definition AngleAxis.h:80
internal::cast_return_type< AngleAxis, AngleAxis< NewScalarType > >::type cast() const
Definition AngleAxis.h:134
bool isApprox(const AngleAxis &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition AngleAxis.h:151
const Vector3 & axis() const
Definition AngleAxis.h:96
_Scalar Scalar
Definition AngleAxis.h:59
friend QuaternionType operator*(const QuaternionType &a, const AngleAxis &b)
Definition AngleAxis.h:112
Matrix3 toRotationMatrix(void) const
Definition AngleAxis.h:218
AngleAxis inverse() const
Definition AngleAxis.h:116
AngleAxis(const QuaternionBase< QuatDerived > &q)
Definition AngleAxis.h:85
The quaternion class used to represent 3D orientations and rotations.
Definition Quaternion.h:274
Common base class for compact rotation representations.
Definition RotationBase.h:30
AngleAxis< float > AngleAxisf
Definition AngleAxis.h:157
AngleAxis< double > AngleAxisd
Definition AngleAxis.h:160
Matrix< Type, 3, 3 > Matrix3
[c++11]
Definition Matrix.h:541
Namespace containing all symbols from the Eigen library.
Definition Core:141
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition NumTraits.h:233