From 6f4f12d1eda685f03a2e4b54b479813d134248cf Mon Sep 17 00:00:00 2001 From: Tal Hadad Date: Mon, 17 Oct 2016 22:23:47 +0300 Subject: Add isApprox() and cast() functions. test cases included --- unsupported/Eigen/src/EulerAngles/EulerAngles.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'unsupported/Eigen/src/EulerAngles/EulerAngles.h') diff --git a/unsupported/Eigen/src/EulerAngles/EulerAngles.h b/unsupported/Eigen/src/EulerAngles/EulerAngles.h index 8a723d9ee..6594e4d13 100644 --- a/unsupported/Eigen/src/EulerAngles/EulerAngles.h +++ b/unsupported/Eigen/src/EulerAngles/EulerAngles.h @@ -105,8 +105,11 @@ namespace Eigen class EulerAngles : public RotationBase, 3> { public: + typedef RotationBase, 3> Base; + /** the scalar type of the angles */ typedef _Scalar Scalar; + typedef typename NumTraits::Real RealScalar; /** the EulerSystem to use, which represents the axes of rotation. */ typedef _System System; @@ -248,7 +251,13 @@ namespace Eigen return *this; } - // TODO: Support isApprox function + /** \returns \c true if \c *this is approximately equal to \a other, within the precision + * determined by \a prec. + * + * \sa MatrixBase::isApprox() */ + bool isApprox(const EulerAngles& other, + const RealScalar& prec = NumTraits::dummy_precision()) const + { return angles().isApprox(other.angles(), prec); } /** \returns an equivalent 3x3 rotation matrix. */ Matrix3 toRotationMatrix() const @@ -271,6 +280,15 @@ namespace Eigen s << eulerAngles.angles().transpose(); return s; } + + /** \returns \c *this with scalar type casted to \a NewScalarType */ + template + EulerAngles cast() const + { + EulerAngles e; + e.angles() = angles().cast(); + return e; + } }; #define EIGEN_EULER_ANGLES_SINGLE_TYPEDEF(AXES, SCALAR_TYPE, SCALAR_POSTFIX) \ -- cgit v1.2.3