diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-10-25 22:38:22 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-10-25 22:38:22 +0000 |
commit | e5b8a59cfa5d9d7f81aad80d91c90b613efb2b67 (patch) | |
tree | b1d2d0d0c4b0a74e93e2feb2cbe34e711ff48599 /Eigen/src/Geometry/Rotation2D.h | |
parent | 568a7e8eba0cac0555c286aa44a594c109b73276 (diff) |
Add smart cast functions and ctor with scalar conversion (explicit)
to all classes of the Geometry module. By smart I mean that if current
type == new type, then it returns a const reference to *this => zero overhead
Diffstat (limited to 'Eigen/src/Geometry/Rotation2D.h')
-rw-r--r-- | Eigen/src/Geometry/Rotation2D.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Eigen/src/Geometry/Rotation2D.h b/Eigen/src/Geometry/Rotation2D.h index c0bda5f69..8e8396713 100644 --- a/Eigen/src/Geometry/Rotation2D.h +++ b/Eigen/src/Geometry/Rotation2D.h @@ -100,6 +100,22 @@ public: */ inline Rotation2D slerp(Scalar t, const Rotation2D& other) const { return m_angle * (1-t) + other.angle() * t; } + + /** \returns \c *this with scalar type casted to \a NewScalarType + * + * Note that if \a NewScalarType is equal to the current scalar type of \c *this + * then this function smartly returns a const reference to \c *this. + */ + template<typename NewScalarType> + typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const + { return typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); } + + /** Copy constructor with scalar type conversion */ + template<typename OtherScalarType> + explicit Rotation2D(const Rotation2D<OtherScalarType>& other) + { + m_angle = other.angle(); + } }; /** \ingroup GeometryModule |