Eigen::AngleAxisd
时间: 2023-07-07 22:44:18 浏览: 143
Eigen::AngleAxisd是Eigen库中用于描述3D旋转的类,它包含一个旋转角度和一个旋转轴向量。AngleAxisd的定义如下:
```
template<typename _Scalar>
class AngleAxis : public EigenBase<AngleAxis<_Scalar> >
{
public:
typedef _Scalar Scalar;
enum { Isometry = 0, Options = 0 };
enum { Dim = 3, Axis = 0 };
typedef Matrix<Scalar,3,1> Vector3;
typedef Matrix<Scalar,4,1> Vector4;
typedef Quaternion<Scalar> QuaternionType;
typedef AngleAxis<Scalar> AngleAxisType;
typedef Matrix<Scalar,3,3> Matrix3;
typedef Matrix<Scalar,4,4> Matrix4;
typedef Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> DenseMatrix;
typedef Matrix<Scalar,Eigen::Dynamic,1> DenseVector;
AngleAxis() : m_angle(Scalar(0)), m_axis(Vector3::UnitX()) {}
AngleAxis(const Quaternion<Scalar>& q);
template<typename OtherScalar>
explicit AngleAxis(const AngleAxis<OtherScalar>& other)
{
m_angle = static_cast<Scalar>(other.angle());
m_axis = other.axis().template cast<Scalar>();
}
explicit AngleAxis(const Matrix<Scalar,3,1>& axis, Scalar angle)
: m_angle(angle), m_axis(axis)
{
eigen_assert(axis.norm() > NumTraits<Scalar>::epsilon());
m_axis.normalize();
}
explicit AngleAxis(Scalar roll, Scalar pitch, Scalar yaw);
explicit AngleAxis(const Matrix<Scalar,3,3>& R);
EIGEN_STRONG_INLINE const Scalar& angle() const { return m_angle; }
EIGEN_STRONG_INLINE const Vector3& axis() const { return m_axis; }
EIGEN_STRONG_INLINE QuaternionType toQuaternion() const
{
return QuaternionType(Eigen::AngleAxis<Scalar>(m_angle, m_axis));
}
EIGEN_STRONG_INLINE Matrix3 toRotationMatrix() const;
static inline AngleAxisType Identity() { return AngleAxisType(); }
EIGEN_STRONG_INLINE void setIdentity() { m_axis = Vector3::UnitX(); m_angle = Scalar(0); }
bool operator==(const AngleAxisType& other) const
{
return m_angle == other.m_angle && m_axis == other.m_axis;
}
bool operator!=(const AngleAxisType& other) const
{
return m_angle != other.m_angle || m_axis != other.m_axis;
}
private:
Scalar m_angle;
Vector3 m_axis;
};
```
其中,AngleAxisd的构造函数有多种形式,可以通过旋转角度和旋转轴向量来创建,也可以通过旋转矩阵或四元数来创建。此外,它还提供了一些方法,例如toQuaternion()用于将旋转向量转换为四元数,toRotationMatrix()用于将旋转向量转换为旋转矩阵等。
阅读全文