math-quaternion.qbk 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  1. [def __R ['[*R]]]
  2. [def __C ['[*C]]]
  3. [def __H ['[*H]]]
  4. [def __O ['[*O]]]
  5. [def __R3 ['[*'''R<superscript>3</superscript>''']]]
  6. [def __R4 ['[*'''R<superscript>4</superscript>''']]]
  7. [def __quadrulple ('''&#x03B1;,&#x03B2;,&#x03B3;,&#x03B4;''')]
  8. [def __quat_formula ['[^q = '''&#x03B1; + &#x03B2;i + &#x03B3;j + &#x03B4;k''']]]
  9. [def __quat_complex_formula ['[^q = ('''&#x03B1; + &#x03B2;i) + (&#x03B3; + &#x03B4;i)j''' ]]]
  10. [def __not_equal ['[^xy '''&#x2260;''' yx]]]
  11. [mathpart quaternions Quaternions]
  12. [section:quat_overview Overview]
  13. Quaternions are a relative of complex numbers.
  14. Quaternions are in fact part of a small hierarchy of structures built
  15. upon the real numbers, which comprise only the set of real numbers
  16. (traditionally named __R), the set of complex numbers (traditionally named __C),
  17. the set of quaternions (traditionally named __H) and the set of octonions
  18. (traditionally named __O), which possess interesting mathematical properties
  19. (chief among which is the fact that they are ['division algebras],
  20. ['i.e.] where the following property is true: if ['[^y]] is an element of that
  21. algebra and is [*not equal to zero], then ['[^yx = yx']], where ['[^x]] and ['[^x']]
  22. denote elements of that algebra, implies that ['[^x = x']]).
  23. Each member of the hierarchy is a super-set of the former.
  24. One of the most important aspects of quaternions is that they provide an
  25. efficient way to parameterize rotations in __R3 (the usual three-dimensional space)
  26. and __R4.
  27. In practical terms, a quaternion is simply a quadruple of real numbers __quadrulple,
  28. which we can write in the form __quat_formula, where ['[^i]] is the same object as for complex numbers,
  29. and ['[^j]] and ['[^k]] are distinct objects which play essentially the same kind of role as ['[^i]].
  30. An addition and a multiplication is defined on the set of quaternions,
  31. which generalize their real and complex counterparts. The main novelty
  32. here is that [*the multiplication is not commutative] (i.e. there are
  33. quaternions ['[^x]] and ['[^y]] such that __not_equal). A good mnemotechnical way of remembering
  34. things is by using the formula ['[^i*i = j*j = k*k = -1]].
  35. Quaternions (and their kin) are described in far more details in this
  36. other [@../quaternion/TQE.pdf document]
  37. (with [@../quaternion/TQE_EA.pdf errata and addenda]).
  38. Some traditional constructs, such as the exponential, carry over without
  39. too much change into the realms of quaternions, but other, such as taking
  40. a square root, do not.
  41. [endsect] [/section:quat_overview Overview]
  42. [section:quat_header Header File]
  43. The interface and implementation are both supplied by the header file
  44. [@../../../../boost/math/quaternion.hpp quaternion.hpp].
  45. [endsect]
  46. [section:quat_synopsis Synopsis]
  47. namespace boost{ namespace math{
  48. template<typename T> class ``[link math_toolkit.quat quaternion]``;
  49. template<> class ``[link math_toolkit.spec quaternion<float>]``;
  50. template<> class ``[link math_quaternion_double quaternion<double>]``;
  51. template<> class ``[link math_quaternion_long_double quaternion<long double>]``;
  52. // operators
  53. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_addition_operators operator +]`` (T const & lhs, quaternion<T> const & rhs);
  54. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_addition_operators operator +]`` (quaternion<T> const & lhs, T const & rhs);
  55. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_addition_operators operator +]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  56. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_addition_operators operator +]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  57. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_addition_operators operator +]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  58. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_subtraction_operators operator -]`` (T const & lhs, quaternion<T> const & rhs);
  59. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_subtraction_operators operator -]`` (quaternion<T> const & lhs, T const & rhs);
  60. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_subtraction_operators operator -]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  61. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_subtraction_operators operator -]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  62. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_subtraction_operators operator -]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  63. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_multiplication_operators operator *]`` (T const & lhs, quaternion<T> const & rhs);
  64. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_multiplication_operators operator *]`` (quaternion<T> const & lhs, T const & rhs);
  65. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_multiplication_operators operator *]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  66. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_multiplication_operators operator *]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  67. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_multiplication_operators operator *]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  68. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_division_operators operator /]`` (T const & lhs, quaternion<T> const & rhs);
  69. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_division_operators operator /]`` (quaternion<T> const & lhs, T const & rhs);
  70. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_division_operators operator /]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  71. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_division_operators operator /]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  72. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.binary_division_operators operator /]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  73. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.unary_plus operator +]`` (quaternion<T> const & q);
  74. template<typename T> quaternion<T> ``[link math_toolkit.quat_non_mem.unary_minus operator -]`` (quaternion<T> const & q);
  75. template<typename T> bool ``[link math_toolkit.quat_non_mem.equality_operators operator ==]`` (T const & lhs, quaternion<T> const & rhs);
  76. template<typename T> bool ``[link math_toolkit.quat_non_mem.equality_operators operator ==]`` (quaternion<T> const & lhs, T const & rhs);
  77. template<typename T> bool ``[link math_toolkit.quat_non_mem.equality_operators operator ==]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  78. template<typename T> bool ``[link math_toolkit.quat_non_mem.equality_operators operator ==]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  79. template<typename T> bool ``[link math_toolkit.quat_non_mem.equality_operators operator ==]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  80. template<typename T> bool ``[link math_toolkit.quat_non_mem.inequality_operators operator !=]`` (T const & lhs, quaternion<T> const & rhs);
  81. template<typename T> bool ``[link math_toolkit.quat_non_mem.inequality_operators operator !=]`` (quaternion<T> const & lhs, T const & rhs);
  82. template<typename T> bool ``[link math_toolkit.quat_non_mem.inequality_operators operator !=]`` (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  83. template<typename T> bool ``[link math_toolkit.quat_non_mem.inequality_operators operator !=]`` (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  84. template<typename T> bool ``[link math_toolkit.quat_non_mem.inequality_operators operator !=]`` (quaternion<T> const & lhs, quaternion<T> const & rhs);
  85. template<typename T, typename charT, class traits>
  86. ::std::basic_istream<charT,traits>& ``[link math_toolkit.quat_non_mem.stream_extractor operator >>]`` (::std::basic_istream<charT,traits> & is, quaternion<T> & q);
  87. template<typename T, typename charT, class traits>
  88. ::std::basic_ostream<charT,traits>& operator ``[link math_toolkit.quat_non_mem.stream_inserter operator <<]`` (::std::basic_ostream<charT,traits> & os, quaternion<T> const & q);
  89. // values
  90. template<typename T> T ``[link math_toolkit.value_op.real_and_unreal real]``(quaternion<T> const & q);
  91. template<typename T> quaternion<T> ``[link math_toolkit.value_op.real_and_unreal unreal]``(quaternion<T> const & q);
  92. template<typename T> T ``[link math_toolkit.value_op.sup sup]``(quaternion<T> const & q);
  93. template<typename T> T ``[link math_toolkit.value_op.l1 l1]``(quaternion<T> const & q);
  94. template<typename T> T ``[link math_toolkit.value_op.abs abs]``(quaternion<T> const & q);
  95. template<typename T> T ``[link math_toolkit.value_op.norm norm]``(quaternion<T>const & q);
  96. template<typename T> quaternion<T> ``[link math_toolkit.value_op.conj conj]``(quaternion<T> const & q);
  97. template<typename T> quaternion<T> ``[link math_quaternions.creation_spherical]``(T const & rho, T const & theta, T const & phi1, T const & phi2);
  98. template<typename T> quaternion<T> ``[link math_quaternions.creation_semipolar semipolar]``(T const & rho, T const & alpha, T const & theta1, T const & theta2);
  99. template<typename T> quaternion<T> ``[link math_quaternions.creation_multipolar multipolar]``(T const & rho1, T const & theta1, T const & rho2, T const & theta2);
  100. template<typename T> quaternion<T> ``[link math_quaternions.creation_cylindrospherical cylindrospherical]``(T const & t, T const & radius, T const & longitude, T const & latitude);
  101. template<typename T> quaternion<T> ``[link math_quaternions.creation_cylindrical cylindrical]``(T const & r, T const & angle, T const & h1, T const & h2);
  102. // transcendentals
  103. template<typename T> quaternion<T> ``[link math_toolkit.trans.exp exp]``(quaternion<T> const & q);
  104. template<typename T> quaternion<T> ``[link math_toolkit.trans.cos cos]``(quaternion<T> const & q);
  105. template<typename T> quaternion<T> ``[link math_toolkit.trans.sin sin]``(quaternion<T> const & q);
  106. template<typename T> quaternion<T> ``[link math_toolkit.trans.tan tan]``(quaternion<T> const & q);
  107. template<typename T> quaternion<T> ``[link math_toolkit.trans.cosh cosh]``(quaternion<T> const & q);
  108. template<typename T> quaternion<T> ``[link math_toolkit.trans.sinh sinh]``(quaternion<T> const & q);
  109. template<typename T> quaternion<T> ``[link math_toolkit.trans.tanh tanh]``(quaternion<T> const & q);
  110. template<typename T> quaternion<T> ``[link math_toolkit.trans.pow pow]``(quaternion<T> const & q, int n);
  111. } // namespace math
  112. } // namespace boost
  113. [endsect] [/section:quat_header Header File]
  114. [section:quat Template Class quaternion]
  115. namespace boost{ namespace math{
  116. template<typename T>
  117. class quaternion
  118. {
  119. public:
  120. typedef T ``[link math_toolkit.mem_typedef value_type]``;
  121. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), T const & requested_d = T());
  122. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(::std::complex<T> const & z0, ::std::complex<T> const & z1 = ::std::complex<T>());
  123. template<typename X>
  124. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<X> const & a_recopier);
  125. T ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts real]``() const;
  126. quaternion<T> ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts unreal]``() const;
  127. T ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_1]``() const;
  128. T ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_2]``() const;
  129. T ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_3]``() const;
  130. T ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_4]``() const;
  131. ::std::complex<T> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_1]``() const;
  132. ::std::complex<T> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_2]``() const;
  133. quaternion<T>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<T> const & a_affecter);
  134. template<typename X>
  135. quaternion<T>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<X> const & a_affecter);
  136. quaternion<T>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(T const & a_affecter);
  137. quaternion<T>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(::std::complex<T> const & a_affecter);
  138. quaternion<T>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(T const & rhs);
  139. quaternion<T>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(::std::complex<T> const & rhs);
  140. template<typename X>
  141. quaternion<T>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(quaternion<X> const & rhs);
  142. quaternion<T>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(T const & rhs);
  143. quaternion<T>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(::std::complex<T> const & rhs);
  144. template<typename X>
  145. quaternion<T>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(quaternion<X> const & rhs);
  146. quaternion<T>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(T const & rhs);
  147. quaternion<T>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(::std::complex<T> const & rhs);
  148. template<typename X>
  149. quaternion<T>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(quaternion<X> const & rhs);
  150. quaternion<T>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(T const & rhs);
  151. quaternion<T>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(::std::complex<T> const & rhs);
  152. template<typename X>
  153. quaternion<T>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(quaternion<X> const & rhs);
  154. };
  155. } // namespace math
  156. } // namespace boost
  157. [endsect] [/section:quat Template Class quaternion]
  158. [section:spec Quaternion Specializations]
  159. namespace boost{ namespace math{
  160. template<>
  161. class quaternion<float>
  162. {
  163. public:
  164. typedef float ``[link math_toolkit.mem_typedef value_type]``;
  165. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(float const & requested_a = 0.0f, float const & requested_b = 0.0f, float const & requested_c = 0.0f, float const & requested_d = 0.0f);
  166. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(::std::complex<float> const & z0, ::std::complex<float> const & z1 = ::std::complex<float>());
  167. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<double> const & a_recopier);
  168. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<long double> const & a_recopier);
  169. float ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts real]``() const;
  170. quaternion<float> ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts unreal]``() const;
  171. float ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_1]``() const;
  172. float ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_2]``() const;
  173. float ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_3]``() const;
  174. float ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_4]``() const;
  175. ::std::complex<float> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_1]``() const;
  176. ::std::complex<float> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_2]``() const;
  177. quaternion<float>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<float> const & a_affecter);
  178. template<typename X>
  179. quaternion<float>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<X> const & a_affecter);
  180. quaternion<float>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(float const & a_affecter);
  181. quaternion<float>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(::std::complex<float> const & a_affecter);
  182. quaternion<float>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(float const & rhs);
  183. quaternion<float>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(::std::complex<float> const & rhs);
  184. template<typename X>
  185. quaternion<float>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(quaternion<X> const & rhs);
  186. quaternion<float>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(float const & rhs);
  187. quaternion<float>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(::std::complex<float> const & rhs);
  188. template<typename X>
  189. quaternion<float>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(quaternion<X> const & rhs);
  190. quaternion<float>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(float const & rhs);
  191. quaternion<float>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(::std::complex<float> const & rhs);
  192. template<typename X>
  193. quaternion<float>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(quaternion<X> const & rhs);
  194. quaternion<float>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(float const & rhs);
  195. quaternion<float>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(::std::complex<float> const & rhs);
  196. template<typename X>
  197. quaternion<float>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(quaternion<X> const & rhs);
  198. };
  199. [#math_quaternion_double]
  200. template<>
  201. class quaternion<double>
  202. {
  203. public:
  204. typedef double ``[link math_toolkit.mem_typedef value_type]``;
  205. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(double const & requested_a = 0.0, double const & requested_b = 0.0, double const & requested_c = 0.0, double const & requested_d = 0.0);
  206. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(::std::complex<double> const & z0, ::std::complex<double> const & z1 = ::std::complex<double>());
  207. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<float> const & a_recopier);
  208. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<long double> const & a_recopier);
  209. double ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts real]``() const;
  210. quaternion<double> ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts unreal]``() const;
  211. double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_1]``() const;
  212. double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_2]``() const;
  213. double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_3]``() const;
  214. double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_4]``() const;
  215. ::std::complex<double> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_1]``() const;
  216. ::std::complex<double> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_2]``() const;
  217. quaternion<double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<double> const & a_affecter);
  218. template<typename X>
  219. quaternion<double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<X> const & a_affecter);
  220. quaternion<double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(double const & a_affecter);
  221. quaternion<double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(::std::complex<double> const & a_affecter);
  222. quaternion<double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(double const & rhs);
  223. quaternion<double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(::std::complex<double> const & rhs);
  224. template<typename X>
  225. quaternion<double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(quaternion<X> const & rhs);
  226. quaternion<double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(double const & rhs);
  227. quaternion<double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(::std::complex<double> const & rhs);
  228. template<typename X>
  229. quaternion<double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(quaternion<X> const & rhs);
  230. quaternion<double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(double const & rhs);
  231. quaternion<double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(::std::complex<double> const & rhs);
  232. template<typename X>
  233. quaternion<double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(quaternion<X> const & rhs);
  234. quaternion<double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(double const & rhs);
  235. quaternion<double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(::std::complex<double> const & rhs);
  236. template<typename X>
  237. quaternion<double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(quaternion<X> const & rhs);
  238. };
  239. [#math_quaternion_long_double]
  240. template<>
  241. class quaternion<long double>
  242. {
  243. public:
  244. typedef long double ``[link math_toolkit.mem_typedef value_type]``;
  245. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(long double const & requested_a = 0.0L, long double const & requested_b = 0.0L, long double const & requested_c = 0.0L, long double const & requested_d = 0.0L);
  246. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(::std::complex<long double> const & z0, ::std::complex<long double> const & z1 = ::std::complex<long double>());
  247. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<float> const & a_recopier);
  248. explicit ``[link math_toolkit.quat_mem_fun.constructors quaternion]``(quaternion<double> const & a_recopier);
  249. long double ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts real]``() const;
  250. quaternion<long double> ``[link math_toolkit.quat_mem_fun.real_and_unreal_parts unreal]``() const;
  251. long double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_1]``() const;
  252. long double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_2]``() const;
  253. long double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_3]``() const;
  254. long double ``[link math_toolkit.quat_mem_fun.individual_real_components R_component_4]``() const;
  255. ::std::complex<long double> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_1]``() const;
  256. ::std::complex<long double> ``[link math_toolkit.quat_mem_fun.individual_complex_components C_component_2]``() const;
  257. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<long double> const & a_affecter);
  258. template<typename X>
  259. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(quaternion<X> const & a_affecter);
  260. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(long double const & a_affecter);
  261. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.assignment_operators operator = ]``(::std::complex<long double> const & a_affecter);
  262. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(long double const & rhs);
  263. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(::std::complex<long double> const & rhs);
  264. template<typename X>
  265. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.addition_operators operator += ]``(quaternion<X> const & rhs);
  266. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(long double const & rhs);
  267. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(::std::complex<long double> const & rhs);
  268. template<typename X>
  269. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.subtraction_operators operator -= ]``(quaternion<X> const & rhs);
  270. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(long double const & rhs);
  271. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(::std::complex<long double> const & rhs);
  272. template<typename X>
  273. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.multiplication_operators operator *= ]``(quaternion<X> const & rhs);
  274. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(long double const & rhs);
  275. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(::std::complex<long double> const & rhs);
  276. template<typename X>
  277. quaternion<long double>& ``[link math_toolkit.quat_mem_fun.division_operators operator /= ]``(quaternion<X> const & rhs);
  278. };
  279. } // namespace math
  280. } // namespace boost
  281. [endsect] [/section:spec Quaternion Specializations]
  282. [section:mem_typedef Quaternion Member Typedefs]
  283. [*value_type]
  284. Template version:
  285. typedef T value_type;
  286. Float specialization version:
  287. typedef float value_type;
  288. Double specialization version:
  289. typedef double value_type;
  290. Long double specialization version:
  291. typedef long double value_type;
  292. These provide easy acces to the type the template is built upon.
  293. [endsect]
  294. [section:quat_mem_fun Quaternion Member Functions]
  295. [h3 Constructors]
  296. Template version:
  297. explicit quaternion(T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), T const & requested_d = T());
  298. explicit quaternion(::std::complex<T> const & z0, ::std::complex<T> const & z1 = ::std::complex<T>());
  299. template<typename X>
  300. explicit quaternion(quaternion<X> const & a_recopier);
  301. Float specialization version:
  302. explicit quaternion(float const & requested_a = 0.0f, float const & requested_b = 0.0f, float const & requested_c = 0.0f, float const & requested_d = 0.0f);
  303. explicit quaternion(::std::complex<float> const & z0,::std::complex<float> const & z1 = ::std::complex<float>());
  304. explicit quaternion(quaternion<double> const & a_recopier);
  305. explicit quaternion(quaternion<long double> const & a_recopier);
  306. Double specialization version:
  307. explicit quaternion(double const & requested_a = 0.0, double const & requested_b = 0.0, double const & requested_c = 0.0, double const & requested_d = 0.0);
  308. explicit quaternion(::std::complex<double> const & z0, ::std::complex<double> const & z1 = ::std::complex<double>());
  309. explicit quaternion(quaternion<float> const & a_recopier);
  310. explicit quaternion(quaternion<long double> const & a_recopier);
  311. Long double specialization version:
  312. explicit quaternion(long double const & requested_a = 0.0L, long double const & requested_b = 0.0L, long double const & requested_c = 0.0L, long double const & requested_d = 0.0L);
  313. explicit quaternion( ::std::complex<long double> const & z0, ::std::complex<long double> const & z1 = ::std::complex<long double>());
  314. explicit quaternion(quaternion<float> const & a_recopier);
  315. explicit quaternion(quaternion<double> const & a_recopier);
  316. A default constructor is provided for each form, which initializes
  317. each component to the default values for their type
  318. (i.e. zero for floating numbers). This constructor can also accept
  319. one to four base type arguments. A constructor is also provided to
  320. build quaternions from one or two complex numbers sharing the same
  321. base type. The unspecialized template also sports a templarized copy
  322. constructor, while the specialized forms have copy constructors
  323. from the other two specializations, which are explicit when a risk of
  324. precision loss exists. For the unspecialized form, the base type's
  325. constructors must not throw.
  326. Destructors and untemplated copy constructors (from the same type) are
  327. provided by the compiler. Converting copy constructors make use of a
  328. templated helper function in a "detail" subnamespace.
  329. [h3 Other member functions]
  330. [h4 Real and Unreal Parts]
  331. T real() const;
  332. quaternion<T> unreal() const;
  333. Like complex number, quaternions do have a meaningful notion of "real part",
  334. but unlike them there is no meaningful notion of "imaginary part".
  335. Instead there is an "unreal part" which itself is a quaternion,
  336. and usually nothing simpler (as opposed to the complex number case).
  337. These are returned by the first two functions.
  338. [h4 Individual Real Components]
  339. T R_component_1() const;
  340. T R_component_2() const;
  341. T R_component_3() const;
  342. T R_component_4() const;
  343. A quaternion having four real components, these are returned by these four
  344. functions. Hence real and R_component_1 return the same value.
  345. [h4 Individual Complex Components]
  346. ::std::complex<T> C_component_1() const;
  347. ::std::complex<T> C_component_2() const;
  348. A quaternion likewise has two complex components, and as we have seen above,
  349. for any quaternion __quat_formula we also have __quat_complex_formula. These functions return them.
  350. The real part of `q.C_component_1()` is the same as `q.real()`.
  351. [h3 Quaternion Member Operators]
  352. [h4 Assignment Operators]
  353. quaternion<T>& operator = (quaternion<T> const & a_affecter);
  354. template<typename X>
  355. quaternion<T>& operator = (quaternion<X> const& a_affecter);
  356. quaternion<T>& operator = (T const& a_affecter);
  357. quaternion<T>& operator = (::std::complex<T> const& a_affecter);
  358. These perform the expected assignment, with type modification if necessary
  359. (for instance, assigning from a base type will set the real part to that
  360. value, and all other components to zero). For the unspecialized form,
  361. the base type's assignment operators must not throw.
  362. [h4 Addition Operators]
  363. quaternion<T>& operator += (T const & rhs)
  364. quaternion<T>& operator += (::std::complex<T> const & rhs);
  365. template<typename X>
  366. quaternion<T>& operator += (quaternion<X> const & rhs);
  367. These perform the mathematical operation `(*this)+rhs` and store the result in
  368. `*this`. The unspecialized form has exception guards, which the specialized
  369. forms do not, so as to insure exception safety. For the unspecialized form,
  370. the base type's assignment operators must not throw.
  371. [h4 Subtraction Operators]
  372. quaternion<T>& operator -= (T const & rhs)
  373. quaternion<T>& operator -= (::std::complex<T> const & rhs);
  374. template<typename X>
  375. quaternion<T>& operator -= (quaternion<X> const & rhs);
  376. These perform the mathematical operation `(*this)-rhs` and store the result
  377. in `*this`. The unspecialized form has exception guards, which the
  378. specialized forms do not, so as to insure exception safety.
  379. For the unspecialized form, the base type's assignment operators
  380. must not throw.
  381. [h4 Multiplication Operators]
  382. quaternion<T>& operator *= (T const & rhs)
  383. quaternion<T>& operator *= (::std::complex<T> const & rhs);
  384. template<typename X>
  385. quaternion<T>& operator *= (quaternion<X> const & rhs);
  386. These perform the mathematical operation `(*this)*rhs` [*in this order]
  387. (order is important as multiplication is not commutative for quaternions)
  388. and store the result in `*this`. The unspecialized form has exception guards,
  389. which the specialized forms do not, so as to insure exception safety.
  390. For the unspecialized form, the base type's assignment operators must not throw.
  391. [h4 Division Operators]
  392. quaternion<T>& operator /= (T const & rhs)
  393. quaternion<T>& operator /= (::std::complex<T> const & rhs);
  394. template<typename X>
  395. quaternion<T>& operator /= (quaternion<X> const & rhs);
  396. These perform the mathematical operation `(*this)*inverse_of(rhs)` [*in this
  397. order] (order is important as multiplication is not commutative for quaternions)
  398. and store the result in `*this`. The unspecialized form has exception guards,
  399. which the specialized forms do not, so as to insure exception safety.
  400. For the unspecialized form, the base type's assignment operators must not throw.
  401. [endsect] [/section:mem_typedef Quaternion Member Typedefs]
  402. [section:quat_non_mem Quaternion Non-Member Operators]
  403. [h4 Unary Plus]
  404. template<typename T>
  405. quaternion<T> operator + (quaternion<T> const & q);
  406. This unary operator simply returns q.
  407. [h4 Unary Minus]
  408. template<typename T>
  409. quaternion<T> operator - (quaternion<T> const & q);
  410. This unary operator returns the opposite of q.
  411. [h4 Binary Addition Operators]
  412. template<typename T> quaternion<T> operator + (T const & lhs, quaternion<T> const & rhs);
  413. template<typename T> quaternion<T> operator + (quaternion<T> const & lhs, T const & rhs);
  414. template<typename T> quaternion<T> operator + (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  415. template<typename T> quaternion<T> operator + (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  416. template<typename T> quaternion<T> operator + (quaternion<T> const & lhs, quaternion<T> const & rhs);
  417. These operators return `quaternion<T>(lhs) += rhs`.
  418. [h4 Binary Subtraction Operators]
  419. template<typename T> quaternion<T> operator - (T const & lhs, quaternion<T> const & rhs);
  420. template<typename T> quaternion<T> operator - (quaternion<T> const & lhs, T const & rhs);
  421. template<typename T> quaternion<T> operator - (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  422. template<typename T> quaternion<T> operator - (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  423. template<typename T> quaternion<T> operator - (quaternion<T> const & lhs, quaternion<T> const & rhs);
  424. These operators return `quaternion<T>(lhs) -= rhs`.
  425. [h4 Binary Multiplication Operators]
  426. template<typename T> quaternion<T> operator * (T const & lhs, quaternion<T> const & rhs);
  427. template<typename T> quaternion<T> operator * (quaternion<T> const & lhs, T const & rhs);
  428. template<typename T> quaternion<T> operator * (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  429. template<typename T> quaternion<T> operator * (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  430. template<typename T> quaternion<T> operator * (quaternion<T> const & lhs, quaternion<T> const & rhs);
  431. These operators return `quaternion<T>(lhs) *= rhs`.
  432. [h4 Binary Division Operators]
  433. template<typename T> quaternion<T> operator / (T const & lhs, quaternion<T> const & rhs);
  434. template<typename T> quaternion<T> operator / (quaternion<T> const & lhs, T const & rhs);
  435. template<typename T> quaternion<T> operator / (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  436. template<typename T> quaternion<T> operator / (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  437. template<typename T> quaternion<T> operator / (quaternion<T> const & lhs, quaternion<T> const & rhs);
  438. These operators return `quaternion<T>(lhs) /= rhs`. It is of course still an
  439. error to divide by zero...
  440. [h4 Equality Operators]
  441. template<typename T> bool operator == (T const & lhs, quaternion<T> const & rhs);
  442. template<typename T> bool operator == (quaternion<T> const & lhs, T const & rhs);
  443. template<typename T> bool operator == (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  444. template<typename T> bool operator == (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  445. template<typename T> bool operator == (quaternion<T> const & lhs, quaternion<T> const & rhs);
  446. These return true if and only if the four components of `quaternion<T>(lhs)`
  447. are equal to their counterparts in `quaternion<T>(rhs)`. As with any
  448. floating-type entity, this is essentially meaningless.
  449. [h4 Inequality Operators]
  450. template<typename T> bool operator != (T const & lhs, quaternion<T> const & rhs);
  451. template<typename T> bool operator != (quaternion<T> const & lhs, T const & rhs);
  452. template<typename T> bool operator != (::std::complex<T> const & lhs, quaternion<T> const & rhs);
  453. template<typename T> bool operator != (quaternion<T> const & lhs, ::std::complex<T> const & rhs);
  454. template<typename T> bool operator != (quaternion<T> const & lhs, quaternion<T> const & rhs);
  455. These return true if and only if `quaternion<T>(lhs) == quaternion<T>(rhs)` is
  456. false. As with any floating-type entity, this is essentially meaningless.
  457. [h4 Stream Extractor]
  458. template<typename T, typename charT, class traits>
  459. ::std::basic_istream<charT,traits>& operator >> (::std::basic_istream<charT,traits> & is, quaternion<T> & q);
  460. Extracts a quaternion q of one of the following forms
  461. (with a, b, c and d of type `T`):
  462. [^a (a), (a,b), (a,b,c), (a,b,c,d) (a,(c)), (a,(c,d)), ((a)), ((a),c), ((a),(c)), ((a),(c,d)), ((a,b)), ((a,b),c), ((a,b),(c)), ((a,b),(c,d))]
  463. The input values must be convertible to `T`. If bad input is encountered,
  464. calls `is.setstate(ios::failbit)` (which may throw ios::failure (27.4.5.3)).
  465. [*Returns:] `is`.
  466. The rationale for the list of accepted formats is that either we have a
  467. list of up to four reals, or else we have a couple of complex numbers,
  468. and in that case if it formated as a proper complex number, then it should
  469. be accepted. Thus potential ambiguities are lifted (for instance (a,b) is
  470. (a,b,0,0) and not (a,0,b,0), i.e. it is parsed as a list of two real numbers
  471. and not two complex numbers which happen to have imaginary parts equal to zero).
  472. [h4 Stream Inserter]
  473. template<typename T, typename charT, class traits>
  474. ::std::basic_ostream<charT,traits>& operator << (::std::basic_ostream<charT,traits> & os, quaternion<T> const & q);
  475. Inserts the quaternion q onto the stream `os` as if it were implemented as follows:
  476. template<typename T, typename charT, class traits>
  477. ::std::basic_ostream<charT,traits>& operator << (
  478. ::std::basic_ostream<charT,traits> & os,
  479. quaternion<T> const & q)
  480. {
  481. ::std::basic_ostringstream<charT,traits> s;
  482. s.flags(os.flags());
  483. s.imbue(os.getloc());
  484. s.precision(os.precision());
  485. s << '(' << q.R_component_1() << ','
  486. << q.R_component_2() << ','
  487. << q.R_component_3() << ','
  488. << q.R_component_4() << ')';
  489. return os << s.str();
  490. }
  491. [endsect] [/section:quat_non_mem Quaternion Non-Member Operators]
  492. [section:value_op Quaternion Value Operations]
  493. [h4 real and unreal]
  494. template<typename T> T real(quaternion<T> const & q);
  495. template<typename T> quaternion<T> unreal(quaternion<T> const & q);
  496. These return `q.real()` and `q.unreal()` respectively.
  497. [h4 conj]
  498. template<typename T> quaternion<T> conj(quaternion<T> const & q);
  499. This returns the conjugate of the quaternion.
  500. [h4 sup]
  501. template<typename T> T sup(quaternion<T> const & q);
  502. This return the sup norm (the greatest among
  503. `abs(q.R_component_1())...abs(q.R_component_4()))` of the quaternion.
  504. [h4 l1]
  505. template<typename T> T l1(quaternion<T> const & q);
  506. This return the l1 norm `(abs(q.R_component_1())+...+abs(q.R_component_4()))`
  507. of the quaternion.
  508. [h4 abs]
  509. template<typename T> T abs(quaternion<T> const & q);
  510. This return the magnitude (Euclidian norm) of the quaternion.
  511. [h4 norm]
  512. template<typename T> T norm(quaternion<T>const & q);
  513. This return the (Cayley) norm of the quaternion.
  514. The term "norm" might be confusing, as most people associate it with the
  515. Euclidian norm (and quadratic functionals). For this version of
  516. (the mathematical objects known as) quaternions, the Euclidian norm
  517. (also known as magnitude) is the square root of the Cayley norm.
  518. [endsect] [/section:value_op Quaternion Value Operations]
  519. [section:create Quaternion Creation Functions]
  520. template<typename T> quaternion<T> spherical(T const & rho, T const & theta, T const & phi1, T const & phi2);
  521. template<typename T> quaternion<T> semipolar(T const & rho, T const & alpha, T const & theta1, T const & theta2);
  522. template<typename T> quaternion<T> multipolar(T const & rho1, T const & theta1, T const & rho2, T const & theta2);
  523. template<typename T> quaternion<T> cylindrospherical(T const & t, T const & radius, T const & longitude, T const & latitude);
  524. template<typename T> quaternion<T> cylindrical(T const & r, T const & angle, T const & h1, T const & h2);
  525. These build quaternions in a way similar to the way polar builds complex
  526. numbers, as there is no strict equivalent to polar coordinates for quaternions.
  527. [#math_quaternions.creation_spherical] `spherical` is a simple transposition of `polar`, it takes as inputs
  528. a (positive) magnitude and a point on the hypersphere, given by three angles.
  529. The first of these, `theta` has a natural range of `-pi` to `+pi`, and the other
  530. two have natural ranges of `-pi/2` to `+pi/2` (as is the case with the usual
  531. spherical coordinates in __R3). Due to the many symmetries and periodicities,
  532. nothing untoward happens if the magnitude is negative or the angles are
  533. outside their natural ranges. The expected degeneracies (a magnitude of
  534. zero ignores the angles settings...) do happen however.
  535. [#math_quaternions.creation_cylindrical] `cylindrical` is likewise a simple transposition of the usual
  536. cylindrical coordinates in __R3, which in turn is another derivative of
  537. planar polar coordinates. The first two inputs are the polar coordinates of
  538. the first __C component of the quaternion. The third and fourth inputs
  539. are placed into the third and fourth __R components of the quaternion,
  540. respectively.
  541. [#math_quaternions.creation_multipolar] `multipolar` is yet another simple generalization of polar coordinates.
  542. This time, both __C components of the quaternion are given in polar coordinates.
  543. [#math_quaternions.creation_cylindrospherical] `cylindrospherical` is specific to quaternions. It is often interesting to
  544. consider __H as the cartesian product of __R by __R3 (the quaternionic
  545. multiplication as then a special form, as given here). This function
  546. therefore builds a quaternion from this representation, with the __R3
  547. component given in usual __R3 spherical coordinates.
  548. [#math_quaternions.creation_semipolar] `semipolar` is another generator which is specific to quaternions.
  549. It takes as a first input the magnitude of the quaternion, as a
  550. second input an angle in the range `0` to `+pi/2` such that magnitudes
  551. of the first two __C components of the quaternion are the product of the
  552. first input and the sine and cosine of this angle, respectively, and finally
  553. as third and fourth inputs angles in the range `-pi/2` to `+pi/2` which
  554. represent the arguments of the first and second __C components of
  555. the quaternion, respectively. As usual, nothing untoward happens if
  556. what should be magnitudes are negative numbers or angles are out of their
  557. natural ranges, as symmetries and periodicities kick in.
  558. In this version of our implementation of quaternions, there is no
  559. analogue of the complex value operation `arg` as the situation is
  560. somewhat more complicated. Unit quaternions are linked both to
  561. rotations in __R3 and in __R4, and the correspondences are not too complicated,
  562. but there is currently a lack of standard (de facto or de jure) matrix
  563. library with which the conversions could work. This should be remedied in
  564. a further revision. In the mean time, an example of how this could be
  565. done is presented here for
  566. [@../../example/HSO3.hpp __R3], and here for
  567. [@../../example/HSO4.hpp __R4]
  568. ([@../../example/HSO3SO4.cpp example test file]).
  569. [endsect] [/section:create Quaternion Creation Functions]
  570. [section:trans Quaternion Transcendentals]
  571. There is no `log` or `sqrt` provided for quaternions in this implementation,
  572. and `pow` is likewise restricted to integral powers of the exponent.
  573. There are several reasons to this: on the one hand, the equivalent of
  574. analytic continuation for quaternions ("branch cuts") remains to be
  575. investigated thoroughly (by me, at any rate...), and we wish to avoid the
  576. nonsense introduced in the standard by exponentiations of complexes by
  577. complexes (which is well defined, but not in the standard...).
  578. Talking of nonsense, saying that `pow(0,0)` is "implementation defined" is just
  579. plain brain-dead...
  580. We do, however provide several transcendentals, chief among which is the
  581. exponential. This author claims the complete proof of the "closed formula"
  582. as his own, as well as its independant invention (there are claims to prior
  583. invention of the formula, such as one by Professor Shoemake, and it is
  584. possible that the formula had been known a couple of centuries back, but in
  585. absence of bibliographical reference, the matter is pending, awaiting further
  586. investigation; on the other hand, the definition and existence of the
  587. exponential on the quaternions, is of course a fact known for a very long time).
  588. Basically, any converging power series with real coefficients which allows for a
  589. closed formula in __C can be transposed to __H. More transcendentals of this
  590. type could be added in a further revision upon request. It should be
  591. noted that it is these functions which force the dependency upon the
  592. [@../../../../boost/math/special_functions/sinc.hpp boost/math/special_functions/sinc.hpp] and the
  593. [@../../../../boost/math/special_functions/sinhc.hpp boost/math/special_functions/sinhc.hpp] headers.
  594. [h4 exp]
  595. template<typename T> quaternion<T> exp(quaternion<T> const & q);
  596. Computes the exponential of the quaternion.
  597. [h4 cos]
  598. template<typename T> quaternion<T> cos(quaternion<T> const & q);
  599. Computes the cosine of the quaternion
  600. [h4 sin]
  601. template<typename T> quaternion<T> sin(quaternion<T> const & q);
  602. Computes the sine of the quaternion.
  603. [h4 tan]
  604. template<typename T> quaternion<T> tan(quaternion<T> const & q);
  605. Computes the tangent of the quaternion.
  606. [h4 cosh]
  607. template<typename T> quaternion<T> cosh(quaternion<T> const & q);
  608. Computes the hyperbolic cosine of the quaternion.
  609. [h4 sinh]
  610. template<typename T> quaternion<T> sinh(quaternion<T> const & q);
  611. Computes the hyperbolic sine of the quaternion.
  612. [h4 tanh]
  613. template<typename T> quaternion<T> tanh(quaternion<T> const & q);
  614. Computes the hyperbolic tangent of the quaternion.
  615. [h4 pow]
  616. template<typename T> quaternion<T> pow(quaternion<T> const & q, int n);
  617. Computes the n-th power of the quaternion q.
  618. [endsect] [/section:trans Quaternion Transcendentals]
  619. [section:quat_tests Test Program]
  620. The [@../../test/quaternion_test.cpp quaternion_test.cpp]
  621. test program tests quaternions specializations for float, double and long double
  622. ([@../quaternion/output.txt sample output], with message output
  623. enabled).
  624. If you define the symbol TEST_VERBOSE, you will get
  625. additional output ([@../quaternion/output_more.txt verbose output]);
  626. this will only be helpfull if you enable message output at the same time,
  627. of course (by uncommenting the relevant line in the test or by adding
  628. [^--log_level=messages] to your command line,...). In that case, and if you
  629. are running interactively, you may in addition define the symbol
  630. BOOST_INTERACTIVE_TEST_INPUT_ITERATOR to interactively test the input
  631. operator with input of your choice from the standard input
  632. (instead of hard-coding it in the test).
  633. [endsect] [/section:quat_tests Test Program]
  634. [section:exp The Quaternionic Exponential]
  635. Please refer to the following PDF's:
  636. *[@../quaternion/TQE.pdf The Quaternionic Exponential (and beyond)]
  637. *[@../quaternion/TQE_EA.pdf The Quaternionic Exponential (and beyond) ERRATA & ADDENDA]
  638. [endsect] [/section:exp The Quaternionic Exponential]
  639. [section:acknowledgement Acknowledgements]
  640. The mathematical text has been typeset with
  641. [@http://www.nisus-soft.com/ Nisus Writer]. Jens Maurer has helped with
  642. portability and standard adherence, and was the Review Manager
  643. for this library. More acknowledgements in the History section.
  644. Thank you to all who contributed to the discution about this library.
  645. [endsect] [/section:quat_tests Test Program]
  646. [section:quat_history History]
  647. * 1.5.9 - 13/5/2013: Incorporated into Boost.Math.
  648. * 1.5.8 - 17/12/2005: Converted documentation to Quickbook Format.
  649. * 1.5.7 - 24/02/2003: transitionned to the unit test framework; <boost/config.hpp> now included by the library header (rather than the test files).
  650. * 1.5.6 - 15/10/2002: Gcc2.95.x and stlport on linux compatibility by Alkis Evlogimenos (alkis@routescience.com).
  651. * 1.5.5 - 27/09/2002: Microsoft VCPP 7 compatibility, by Michael Stevens (michael@acfr.usyd.edu.au); requires the /Za compiler option.
  652. * 1.5.4 - 19/09/2002: fixed problem with multiple inclusion (in different translation units); attempt at an improved compatibility with Microsoft compilers, by Michael Stevens (michael@acfr.usyd.edu.au) and Fredrik Blomqvist; other compatibility fixes.
  653. * 1.5.3 - 01/02/2002: bugfix and Gcc 2.95.3 compatibility by Douglas Gregor (gregod@cs.rpi.edu).
  654. * 1.5.2 - 07/07/2001: introduced namespace math.
  655. * 1.5.1 - 07/06/2001: (end of Boost review) now includes <boost/math/special_functions/sinc.hpp> and <boost/math/special_functions/sinhc.hpp> instead of <boost/special_functions.hpp>; corrected bug in sin (Daryle Walker); removed check for self-assignment (Gary Powel); made converting functions explicit (Gary Powel); added overflow guards for division operators and abs (Peter Schmitteckert); added sup and l1; used Vesa Karvonen's CPP metaprograming technique to simplify code.
  656. * 1.5.0 - 26/03/2001: boostification, inlining of all operators except input, output and pow, fixed exception safety of some members (template version) and output operator, added spherical, semipolar, multipolar, cylindrospherical and cylindrical.
  657. * 1.4.0 - 09/01/2001: added tan and tanh.
  658. * 1.3.1 - 08/01/2001: cosmetic fixes.
  659. * 1.3.0 - 12/07/2000: pow now uses Maarten Hilferink's (mhilferink@tip.nl) algorithm.
  660. * 1.2.0 - 25/05/2000: fixed the division operators and output; changed many signatures.
  661. * 1.1.0 - 23/05/2000: changed sinc into sinc_pi; added sin, cos, sinh, cosh.
  662. * 1.0.0 - 10/08/1999: first public version.
  663. [endsect] [/section:quat_history History]
  664. [section:quat_todo To Do]
  665. * Improve testing.
  666. * Rewrite input operatore using Spirit (creates a dependency).
  667. * Put in place an Expression Template mechanism (perhaps borrowing from uBlas).
  668. * Use uBlas for the link with rotations (and move from the
  669. [@../../example/HSO3SO4.cpp example]
  670. implementation to an efficient one).
  671. [endsect] [/section:quat_todo To Do]
  672. [endmathpart] [/mathpart quaternions Quaternions]
  673. [/
  674. Copyright 1999, 2005, 2013 Hubert Holin.
  675. Distributed under the Boost Software License, Version 1.0.
  676. (See accompanying file LICENSE_1_0.txt or copy at
  677. http://www.boost.org/LICENSE_1_0.txt).
  678. ]