From fb77b7288ce5406ff819d8fd71ad59e317d1817f Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 9 Jul 2020 12:49:58 -0700 Subject: Add operator<< to print a quaternion. --- Eigen/src/Geometry/Quaternion.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'Eigen/src/Geometry') diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index dd1217e5e..bebfca422 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -197,20 +197,25 @@ class QuaternionBase : public RotationBase #else template - EIGEN_DEVICE_FUNC inline + EIGEN_DEVICE_FUNC inline typename internal::enable_if::value,const Derived&>::type cast() const { return derived(); } template - EIGEN_DEVICE_FUNC inline + EIGEN_DEVICE_FUNC inline typename internal::enable_if::value,Quaternion >::type cast() const { return Quaternion(coeffs().template cast()); } #endif + friend std::ostream& operator<<(std::ostream& s, const QuaternionBase& q) { + s << q.x() << "i + " << q.y() << "j + " << q.z() << "k" << " + " << q.w(); + return s; + } + #ifdef EIGEN_QUATERNIONBASE_PLUGIN # include EIGEN_QUATERNIONBASE_PLUGIN #endif -- cgit v1.2.3