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