diff options
author | Tal Hadad <tal_hd@hotmail.com> | 2016-10-17 22:23:47 +0300 |
---|---|---|
committer | Tal Hadad <tal_hd@hotmail.com> | 2016-10-17 22:23:47 +0300 |
commit | 6f4f12d1eda685f03a2e4b54b479813d134248cf (patch) | |
tree | 1fddaee443ffe7a3a932e215bc0779919e66003e /unsupported/Eigen/src/EulerAngles | |
parent | 7402cfd4cc3bc129b0fc906eb51347882307cbe0 (diff) |
Add isApprox() and cast() functions.
test cases included
Diffstat (limited to 'unsupported/Eigen/src/EulerAngles')
-rw-r--r-- | unsupported/Eigen/src/EulerAngles/EulerAngles.h | 20 |
1 files changed, 19 insertions, 1 deletions
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<EulerAngles<_Scalar, _System>, 3> { public: + typedef RotationBase<EulerAngles<_Scalar, _System>, 3> Base; + /** the scalar type of the angles */ typedef _Scalar Scalar; + typedef typename NumTraits<Scalar>::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<Scalar>::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 <typename NewScalarType> + EulerAngles<NewScalarType, System> cast() const + { + EulerAngles<NewScalarType, System> e; + e.angles() = angles().cast<NewScalarType>(); + return e; + } }; #define EIGEN_EULER_ANGLES_SINGLE_TYPEDEF(AXES, SCALAR_TYPE, SCALAR_POSTFIX) \ |