📄 math-quaternion.qbk
字号:
`abs(q.R_component_1())...abs(q.R_component_4()))` of the quaternion.[h4 l1] template<typename T> T l1(quaternion<T> const & q);This return the l1 norm `(abs(q.R_component_1())+...+abs(q.R_component_4()))`of the quaternion.[h4 abs] template<typename T> T abs(quaternion<T> const & q);This return the magnitude (Euclidian norm) of the quaternion.[h4 norm] template<typename T> T norm(quaternion<T>const & q);This return the (Cayley) norm of the quaternion. The term "norm" might be confusing, as most people associate it with the Euclidian norm (and quadratic functionals). For this version of (the mathematical objects known as) quaternions, the Euclidian norm (also known as magnitude) is the square root of the Cayley norm.[endsect][section:create Quaternion Creation Functions] template<typename T> quaternion<T> spherical(T const & rho, T const & theta, T const & phi1, T const & phi2); template<typename T> quaternion<T> semipolar(T const & rho, T const & alpha, T const & theta1, T const & theta2); template<typename T> quaternion<T> multipolar(T const & rho1, T const & theta1, T const & rho2, T const & theta2); template<typename T> quaternion<T> cylindrospherical(T const & t, T const & radius, T const & longitude, T const & latitude); template<typename T> quaternion<T> cylindrical(T const & r, T const & angle, T const & h1, T const & h2);These build quaternions in a way similar to the way polar builds complex numbers, as there is no strict equivalent to polar coordinates for quaternions.[#boost_quaternions.quaternions.creation_spherical] `spherical` is a simple transposition of `polar`, it takes as inputs a (positive) magnitude and a point on the hypersphere, given by three angles. The first of these, `theta` has a natural range of `-pi` to `+pi`, and the other two have natural ranges of `-pi/2` to `+pi/2` (as is the case with the usual spherical coordinates in __R3). Due to the many symmetries and periodicities, nothing untoward happens if the magnitude is negative or the angles are outside their natural ranges. The expected degeneracies (a magnitude of zero ignores the angles settings...) do happen however.[#boost_quaternions.quaternions.creation_cylindrical] `cylindrical` is likewise a simple transposition of the usual cylindrical coordinates in __R3, which in turn is another derivative of planar polar coordinates. The first two inputs are the polar coordinates of the first __C component of the quaternion. The third and fourth inputs are placed into the third and fourth __R components of the quaternion, respectively.[#boost_quaternions.quaternions.creation_multipolar] `multipolar` is yet another simple generalization of polar coordinates. This time, both __C components of the quaternion are given in polar coordinates.[#boost_quaternions.quaternions.creation_cylindrospherical] `cylindrospherical` is specific to quaternions. It is often interesting to consider __H as the cartesian product of __R by __R3 (the quaternionic multiplication as then a special form, as given here). This function therefore builds a quaternion from this representation, with the __R3 component given in usual __R3 spherical coordinates.[#boost_quaternions.quaternions.creation_semipolar] `semipolar` is another generator which is specific to quaternions. It takes as a first input the magnitude of the quaternion, as a second input an angle in the range `0` to `+pi/2` such that magnitudes of the first two __C components of the quaternion are the product of the first input and the sine and cosine of this angle, respectively, and finally as third and fourth inputs angles in the range `-pi/2` to `+pi/2` which represent the arguments of the first and second __C components of the quaternion, respectively. As usual, nothing untoward happens if what should be magnitudes are negative numbers or angles are out of their natural ranges, as symmetries and periodicities kick in.In this version of our implementation of quaternions, there is no analogue of the complex value operation `arg` as the situation is somewhat more complicated. Unit quaternions are linked both to rotations in __R3 and in __R4, and the correspondences are not too complicated, but there is currently a lack of standard (de facto or de jure) matrix library with which the conversions could work. This should be remedied in a further revision. In the mean time, an example of how this could be done is presented here for [@../../../quaternion/HSO3.hpp __R3], and here for [@../../../quaternion/HSO4.hpp __R4] ([@../../../quaternion/HSO3SO4.cpp example test file]).[endsect][section:trans Quaternion Transcendentals]There is no `log` or `sqrt` provided for quaternions in this implementation, and `pow` is likewise restricted to integral powers of the exponent. There are several reasons to this: on the one hand, the equivalent of analytic continuation for quaternions ("branch cuts") remains to be investigated thoroughly (by me, at any rate...), and we wish to avoid the nonsense introduced in the standard by exponentiations of complexes by complexes (which is well defined, but not in the standard...). Talking of nonsense, saying that `pow(0,0)` is "implementation defined" is just plain brain-dead...We do, however provide several transcendentals, chief among which is the exponential. This author claims the complete proof of the "closed formula" as his own, as well as its independant invention (there are claims to prior invention of the formula, such as one by Professor Shoemake, and it is possible that the formula had been known a couple of centuries back, but in absence of bibliographical reference, the matter is pending, awaiting further investigation; on the other hand, the definition and existence of the exponential on the quaternions, is of course a fact known for a very long time). Basically, any converging power series with real coefficients which allows for a closed formula in __C can be transposed to __H. More transcendentals of this type could be added in a further revision upon request. It should be noted that it is these functions which force the dependency upon the [@../../../../../boost/math/special_functions/sinc.hpp boost/math/special_functions/sinc.hpp] and the [@../../../../../boost/math/special_functions/sinhc.hpp boost/math/special_functions/sinhc.hpp] headers.[h4 exp] template<typename T> quaternion<T> exp(quaternion<T> const & q);Computes the exponential of the quaternion.[h4 cos] template<typename T> quaternion<T> cos(quaternion<T> const & q);Computes the cosine of the quaternion[h4 sin] template<typename T> quaternion<T> sin(quaternion<T> const & q);Computes the sine of the quaternion.[h4 tan] template<typename T> quaternion<T> tan(quaternion<T> const & q);Computes the tangent of the quaternion.[h4 cosh] template<typename T> quaternion<T> cosh(quaternion<T> const & q);Computes the hyperbolic cosine of the quaternion.[h4 sinh] template<typename T> quaternion<T> sinh(quaternion<T> const & q);Computes the hyperbolic sine of the quaternion.[h4 tanh] template<typename T> quaternion<T> tanh(quaternion<T> const & q);Computes the hyperbolic tangent of the quaternion.[h4 pow] template<typename T> quaternion<T> pow(quaternion<T> const & q, int n);Computes the n-th power of the quaternion q.[endsect][section Test Program]The [@../../../quaternion/quaternion_test.cpp quaternion_test.cpp] test program tests quaternions specializations for float, double and long double ([@../../../quaternion/output.txt sample output], with message output enabled).If you define the symbol boost_quaternions_TEST_VERBOSE, you will get additional output ([@../../../quaternion/output_more.txt verbose output]); this will only be helpfull if you enable message output at the same time, of course (by uncommenting the relevant line in the test or by adding [^--log_level=messages] to your command line,...). In that case, and if you are running interactively, you may in addition define the symbol BOOST_INTERACTIVE_TEST_INPUT_ITERATOR to interactively test the input operator with input of your choice from the standard input (instead of hard-coding it in the test).[endsect][section:exp The Quaternionic Exponential]Please refer to the following PDF's:*[@../../../quaternion/TQE.pdf The Quaternionic Exponential (and beyond)]*[@../../../quaternion/TQE_EA.pdf The Quaternionic Exponential (and beyond) ERRATA & ADDENDA][endsect][section Acknowledgements]The mathematical text has been typeset with [@http://www.nisus-soft.com/ Nisus Writer]. Jens Maurer has helped with portability and standard adherence, and was the Review Manager for this library. More acknowledgements in the History section. Thank you to all who contributed to the discution about this library.[endsect][section History]* 1.5.8 - 17/12/2005: Converted documentation to Quickbook Format.* 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).* 1.5.6 - 15/10/2002: Gcc2.95.x and stlport on linux compatibility by Alkis Evlogimenos (alkis@routescience.com).* 1.5.5 - 27/09/2002: Microsoft VCPP 7 compatibility, by Michael Stevens (michael@acfr.usyd.edu.au); requires the /Za compiler option.* 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.* 1.5.3 - 01/02/2002: bugfix and Gcc 2.95.3 compatibility by Douglas Gregor (gregod@cs.rpi.edu).* 1.5.2 - 07/07/2001: introduced namespace math.* 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.* 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.* 1.4.0 - 09/01/2001: added tan and tanh.* 1.3.1 - 08/01/2001: cosmetic fixes.* 1.3.0 - 12/07/2000: pow now uses Maarten Hilferink's (mhilferink@tip.nl) algorithm.* 1.2.0 - 25/05/2000: fixed the division operators and output; changed many signatures.* 1.1.0 - 23/05/2000: changed sinc into sinc_pi; added sin, cos, sinh, cosh.* 1.0.0 - 10/08/1999: first public version. [endsect][section To Do]* Improve testing.* Rewrite input operatore using Spirit (creates a dependency).* Put in place an Expression Template mechanism (perhaps borrowing from uBlas).* Use uBlas for the link with rotations (and move from the [@../../../quaternion/HSO3SO4.cpp example] implementation to an efficient one). [endsect][endsect]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -