diff options
Diffstat (limited to 'Eigen/src/Geometry')
-rw-r--r-- | Eigen/src/Geometry/AngleAxis.h | 40 | ||||
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 29 | ||||
-rw-r--r-- | Eigen/src/Geometry/Rotation.h | 25 |
3 files changed, 84 insertions, 10 deletions
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h index ba3e9f46e..563735376 100644 --- a/Eigen/src/Geometry/AngleAxis.h +++ b/Eigen/src/Geometry/AngleAxis.h @@ -82,27 +82,32 @@ public: const Vector3& axis() const { return m_axis; } Vector3& axis() { return m_axis; } - /** Automatic conversion to a 3x3 rotation matrix. - * \sa toRotationMatrix() */ - operator Matrix3 () const { return toRotationMatrix(); } - + /** Concatenates two rotations */ inline QuaternionType operator* (const AngleAxis& other) const { return QuaternionType(*this) * QuaternionType(other); } - + + /** Concatenates two rotations */ inline QuaternionType operator* (const QuaternionType& other) const { return QuaternionType(*this) * other; } + /** Concatenates two rotations */ friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b) { return a * QuaternionType(b); } + /** Concatenates two rotations */ inline typename ProductReturnType<Matrix3,Matrix3>::Type operator* (const Matrix3& other) const { return toRotationMatrix() * other; } + /** Concatenates two rotations */ inline friend typename ProductReturnType<Matrix3,Matrix3>::Type operator* (const Matrix3& a, const AngleAxis& b) { return a * b.toRotationMatrix(); } + /** \Returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */ + AngleAxis inverse() const + { return AngleAxis(-m_angle, m_axis); } + AngleAxis& operator=(const QuaternionType& q); template<typename Derived> AngleAxis& operator=(const MatrixBase<Derived>& m); @@ -179,4 +184,29 @@ AngleAxis<Scalar>::toRotationMatrix(void) const return res; } +/** \geometry_module + * + * Constructs a 3x3 rotation matrix from the angle-axis \a aa + * + * \sa Matrix(const Quaternion&) + */ +template<typename _Scalar, int _Rows, int _Cols, int _MaxRows, int _MaxCols, unsigned int _Flags> +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>::Matrix(const AngleAxis<Scalar>& aa) +{ + EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,3,3); + *this = aa.toRotationMatrix(); +} + +/** \geometry_module + * + * Set a 3x3 rotation matrix from the angle-axis \a aa + */ +template<typename _Scalar, int _Rows, int _Cols, int _MaxRows, int _MaxCols, unsigned int _Flags> +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>& +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>::operator=(const AngleAxis<Scalar>& aa) +{ + EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,3,3); + return *this = aa.toRotationMatrix(); +} + #endif // EIGEN_ANGLEAXIS_H diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index b2065fdcc..ba753fa43 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -118,6 +118,7 @@ public: /** Constructs and initializes a quaternion from the angle-axis \a aa */ explicit inline Quaternion(const AngleAxisType& aa) { *this = aa; } + /** Constructs and initializes a quaternion from either: * - a rotation matrix expression, * - a 4D vector expression representing quaternion coefficients. @@ -131,9 +132,6 @@ public: template<typename Derived> Quaternion& operator=(const MatrixBase<Derived>& m); - /** Automatic conversion to a rotation matrix. */ - operator Matrix3 () const { return toRotationMatrix(); } - /** \returns a quaternion representing an identity rotation * \sa MatrixBase::Identity() */ @@ -426,4 +424,29 @@ struct ei_quaternion_assign_impl<Other,4,1> } }; +/** \geometry_module + * + * Constructs a 3x3 rotation matrix from the quaternion \a q + * + * \sa Matrix(const AngleAxis&) + */ +template<typename _Scalar, int _Rows, int _Cols, int _MaxRows, int _MaxCols, unsigned int _Flags> +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>::Matrix(const Quaternion<Scalar>& q) +{ + EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,3,3); + *this = q.toRotationMatrix(); +} + +/** \geometry_module + * + * Set a 3x3 rotation matrix from the quaternion \a q + */ +template<typename _Scalar, int _Rows, int _Cols, int _MaxRows, int _MaxCols, unsigned int _Flags> +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>& +Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags>::operator=(const Quaternion<Scalar>& q) +{ + EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Matrix,3,3); + return *this = q.toRotationMatrix(); +} + #endif // EIGEN_QUATERNION_H diff --git a/Eigen/src/Geometry/Rotation.h b/Eigen/src/Geometry/Rotation.h index a98ed061a..f6c4fd4a1 100644 --- a/Eigen/src/Geometry/Rotation.h +++ b/Eigen/src/Geometry/Rotation.h @@ -126,6 +126,7 @@ public: enum { Dim = 2 }; /** the scalar type of the coefficients */ typedef _Scalar Scalar; + typedef Matrix<Scalar,2,1> Vector2; typedef Matrix<Scalar,2,2> Matrix2; protected: @@ -136,14 +137,34 @@ public: /** Construct a 2D counter clock wise rotation from the angle \a a in radian. */ inline Rotation2D(Scalar a) : m_angle(a) {} - inline operator Scalar& () { return m_angle; } - inline operator Scalar () const { return m_angle; } + + /** \Returns the rotation angle */ + inline Scalar angle() const { return m_angle; } + + /** \Returns a read-write reference to the rotation angle */ + inline Scalar& angle() { return m_angle; } /** Automatic convertion to a 2D rotation matrix. * \sa toRotationMatrix() */ inline operator Matrix2() const { return toRotationMatrix(); } + /** \Returns the inverse rotation */ + inline Rotation2D inverse() const { return -m_angle; } + + /** Concatenates two rotations */ + inline Rotation2D operator*(const Rotation2D& other) const + { return m_angle + other.m_angle; } + + /** Concatenates two rotations */ + inline Rotation2D& operator*=(const Rotation2D& other) + { return m_angle += other.m_angle; } + + /** Applies the rotation to a 2D vector */ + template<typename Derived> + Vector2 operator* (const MatrixBase<Derived>& vec) const + { return toRotationMatrix() * vec; } + template<typename Derived> Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m); Matrix2 toRotationMatrix(void) const; |