mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-21 07:19:46 +08:00
Add operator<< to print a quaternion.
This commit is contained in:
parent
ee4715ff48
commit
fb77b7288c
@ -211,6 +211,11 @@ class QuaternionBase : public RotationBase<Derived, 3>
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
friend std::ostream& operator<<(std::ostream& s, const QuaternionBase<Derived>& q) {
|
||||||
|
s << q.x() << "i + " << q.y() << "j + " << q.z() << "k" << " + " << q.w();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_QUATERNIONBASE_PLUGIN
|
#ifdef EIGEN_QUATERNIONBASE_PLUGIN
|
||||||
# include EIGEN_QUATERNIONBASE_PLUGIN
|
# include EIGEN_QUATERNIONBASE_PLUGIN
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,6 +75,11 @@ template<typename Scalar, int Options> void quaternion(void)
|
|||||||
q1.coeffs().setRandom();
|
q1.coeffs().setRandom();
|
||||||
VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs());
|
VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs());
|
||||||
|
|
||||||
|
// Printing
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << q2;
|
||||||
|
VERIFY(ss.str() == "0i + 0j + 0k + 1");
|
||||||
|
|
||||||
// concatenation
|
// concatenation
|
||||||
q1 *= q2;
|
q1 *= q2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user