aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Geometry/AngleAxis.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-10-25 22:38:22 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-10-25 22:38:22 +0000
commite5b8a59cfa5d9d7f81aad80d91c90b613efb2b67 (patch)
treeb1d2d0d0c4b0a74e93e2feb2cbe34e711ff48599 /Eigen/src/Geometry/AngleAxis.h
parent568a7e8eba0cac0555c286aa44a594c109b73276 (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/AngleAxis.h')
-rw-r--r--Eigen/src/Geometry/AngleAxis.h21
1 files changed, 19 insertions, 2 deletions
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h
index 662ae95fb..e3759c4af 100644
--- a/Eigen/src/Geometry/AngleAxis.h
+++ b/Eigen/src/Geometry/AngleAxis.h
@@ -47,7 +47,7 @@
* \note This class is not aimed to be used to store a rotation transformation,
* but rather to make easier the creation of other rotation (Quaternion, rotation Matrix)
* and transformation objects.
- *
+ *
* \sa class Quaternion, class Transform, MatrixBase::UnitX()
*/
@@ -64,7 +64,7 @@ class AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>
public:
using Base::operator*;
-
+
enum { Dim = 3 };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;
@@ -132,6 +132,23 @@ public:
template<typename Derived>
AngleAxis& fromRotationMatrix(const MatrixBase<Derived>& m);
Matrix3 toRotationMatrix(void) const;
+
+ /** \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<AngleAxis,AngleAxis<NewScalarType> >::type cast() const
+ { return typename ei_cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
+
+ /** Copy constructor with scalar type conversion */
+ template<typename OtherScalarType>
+ explicit AngleAxis(const AngleAxis<OtherScalarType>& other)
+ {
+ m_axis = other.axis().template cast<OtherScalarType>();
+ m_angle = other.angle();
+ }
};
/** \ingroup GeometryModule