1 /* -*- C++ -*- ------------------------------------------------------------
3 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
5 The Configurable Math Library (CML) is distributed under the terms of the
6 Boost Software License, v1.0 (see cml/LICENSE for details).
8 *-----------------------------------------------------------------------*/
13 #ifndef quaternion_print_h
14 #define quaternion_print_h
20 /* NOTE: Made 'plain' quaternion output the default (Jesse) */
22 /* #if !defined(CML_PLAIN_QUATERNION_OUTPUT) */
23 #if defined(CML_COMPLEX_QUATERNION_OUTPUT)
25 template<typename E
, class AT
, class CT
> std::ostream
&
26 operator<<(std::ostream
& os
, const cml::quaternion
<E
,AT
,scalar_first
,CT
>& q
)
28 os
<< ((q
[0] < 0)?" - ":"") << std::fabs(q
[0]);
29 os
<< ((q
[1] < 0)?" - ":" + ") << std::fabs(q
[1]) << "i";
30 os
<< ((q
[2] < 0)?" - ":" + ") << std::fabs(q
[2]) << "j";
31 os
<< ((q
[3] < 0)?" - ":" + ") << std::fabs(q
[3]) << "k";
35 template<typename E
, class AT
, class CT
> std::ostream
&
36 operator<<(std::ostream
& os
, const cml::quaternion
<E
,AT
,vector_first
,CT
>& q
)
38 os
<< ((q
[0] < 0)?" - ":"") << std::fabs(q
[0]) << "i";
39 os
<< ((q
[1] < 0)?" - ":" + ") << std::fabs(q
[1]) << "j";
40 os
<< ((q
[2] < 0)?" - ":" + ") << std::fabs(q
[2]) << "k";
41 os
<< ((q
[3] < 0)?" - ":" + ") << std::fabs(q
[3]);
47 /** Output a quaternion to a std::ostream. */
48 template<typename E
, class AT
, class OT
, typename CT
> std::ostream
&
49 operator<<(std::ostream
& os
, const cml::quaternion
<E
,AT
,OT
,CT
>& q
)
51 typedef typename
cml::quaternion
<E
,AT
,OT
,CT
>::order_type order_type
;
71 /** Output a quaternion expression to a std::ostream. */
72 template< class XprT
> inline std::ostream
&
73 operator<<(std::ostream
& os
, const et::QuaternionXpr
<XprT
>& q
)
75 typedef typename
et::QuaternionXpr
<XprT
>::result_type quaternion_type
;
77 os
<< quaternion_type(q
);
78 /* XXX This temporary can be removed by templating the stream insertion
89 // -------------------------------------------------------------------------