diff options
author | 2008-10-25 23:10:21 +0000 | |
---|---|---|
committer | 2008-10-25 23:10:21 +0000 | |
commit | ec0a423862d74cea10e2b33f7b37f43957adb465 (patch) | |
tree | 041c07641467df69289ef429fa7e3ce3a49752ea /Eigen/src/Geometry | |
parent | 505ce85814f9291b7d242ef57582d7b15e673f26 (diff) |
Add isApprox in Geometry module's classes.
Complete unit tests wrt previous commits.
Diffstat (limited to 'Eigen/src/Geometry')
-rw-r--r-- | Eigen/src/Geometry/AngleAxis.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/Hyperplane.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/ParametrizedLine.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/Quaternion.h | 11 | ||||
-rw-r--r-- | Eigen/src/Geometry/Rotation2D.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/Scaling.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/Transform.h | 7 | ||||
-rw-r--r-- | Eigen/src/Geometry/Translation.h | 7 |
8 files changed, 57 insertions, 3 deletions
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h index 85d7b69b0..37dee5c76 100644 --- a/Eigen/src/Geometry/AngleAxis.h +++ b/Eigen/src/Geometry/AngleAxis.h @@ -149,6 +149,13 @@ public: m_axis = other.axis().template cast<OtherScalarType>(); m_angle = other.angle(); } + + /** \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 AngleAxis& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_axis.isApprox(other.m_axis, prec) && ei_isApprox(m_angle,other.m_angle, prec); } }; /** \ingroup GeometryModule diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index d3327a418..a45268f07 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -256,6 +256,13 @@ public: inline explicit Hyperplane(const Hyperplane<OtherScalarType,AmbientDimAtCompileTime>& other) { m_coeffs = other.coeffs().template cast<OtherScalarType>(); } + /** \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 Hyperplane& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_coeffs.isApprox(other.m_coeffs, prec); } + protected: Coefficients m_coeffs; diff --git a/Eigen/src/Geometry/ParametrizedLine.h b/Eigen/src/Geometry/ParametrizedLine.h index e7d336e62..80ce72dcd 100644 --- a/Eigen/src/Geometry/ParametrizedLine.h +++ b/Eigen/src/Geometry/ParametrizedLine.h @@ -122,6 +122,13 @@ public: m_direction = other.direction().template cast<OtherScalarType>(); } + /** \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 ParametrizedLine& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_origin.isApprox(other.m_origin, prec) && m_direction.isApprox(other.m_direction, prec); } + protected: VectorType m_origin, m_direction; diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 688fac885..5b1b41d5e 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -207,9 +207,14 @@ public: /** Copy constructor with scalar type conversion */ template<typename OtherScalarType> inline explicit Quaternion(const Quaternion<OtherScalarType>& other) - { - m_coeffs = other.coeffs().template cast<OtherScalarType>(); - } + { m_coeffs = other.coeffs().template cast<OtherScalarType>(); } + + /** \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 Quaternion& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_coeffs.isApprox(other.m_coeffs, prec); } }; diff --git a/Eigen/src/Geometry/Rotation2D.h b/Eigen/src/Geometry/Rotation2D.h index 8d9bb8b8f..aac7648b1 100644 --- a/Eigen/src/Geometry/Rotation2D.h +++ b/Eigen/src/Geometry/Rotation2D.h @@ -116,6 +116,13 @@ public: { m_angle = other.angle(); } + + /** \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 Rotation2D& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return ei_isApprox(m_angle,other.m_angle, prec); } }; /** \ingroup GeometryModule diff --git a/Eigen/src/Geometry/Scaling.h b/Eigen/src/Geometry/Scaling.h index 54e772e99..8e98bd58a 100644 --- a/Eigen/src/Geometry/Scaling.h +++ b/Eigen/src/Geometry/Scaling.h @@ -142,6 +142,13 @@ public: inline explicit Scaling(const Scaling<OtherScalarType,Dim>& other) { m_coeffs = other.coeffs().template cast<OtherScalarType>(); } + /** \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 Scaling& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_coeffs.isApprox(other.m_coeffs, prec); } + }; /** \addtogroup GeometryModule */ diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 389c61f2c..a0c07e405 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -260,6 +260,13 @@ public: inline explicit Transform(const Transform<OtherScalarType,Dim>& other) { m_matrix = other.matrix().template cast<OtherScalarType>(); } + /** \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 Transform& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_matrix.isApprox(other.m_matrix, prec); } + protected: }; diff --git a/Eigen/src/Geometry/Translation.h b/Eigen/src/Geometry/Translation.h index c2e626112..8dce5dd4c 100644 --- a/Eigen/src/Geometry/Translation.h +++ b/Eigen/src/Geometry/Translation.h @@ -145,6 +145,13 @@ public: inline explicit Translation(const Translation<OtherScalarType,Dim>& other) { m_coeffs = other.vector().template cast<OtherScalarType>(); } + /** \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 Translation& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const + { return m_coeffs.isApprox(other.m_coeffs, prec); } + }; /** \addtogroup GeometryModule */ |