]> gitweb.factorcode.org Git - factor.git/blob - basis/math/quaternions/quaternions-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / math / quaternions / quaternions-docs.factor
1 USING: help.markup help.syntax math math.vectors vectors ;
2 IN: math.quaternions
3
4 HELP: q*
5 { $values { "u" "a quaternion" } { "v" "a quaternion" } { "u*v" "a quaternion" } }
6 { $description "Multiply quaternions." }
7 { $examples { $example "USING: math.quaternions prettyprint ;" "{ C{ 0 1 } 0 } { 0 1 } q* ." "{ 0 C{ 0 1 } }" } } ;
8
9 HELP: qconjugate
10 { $values { "u" "a quaternion" } { "u'" "a quaternion" } }
11 { $description "Quaternion conjugate." } ;
12
13 HELP: qrecip
14 { $values { "u" "a quaternion" } { "1/u" "a quaternion" } }
15 { $description "Quaternion inverse." } ;
16
17 HELP: q/
18 { $values { "u" "a quaternion" } { "v" "a quaternion" } { "u/v" "a quaternion" } }
19 { $description "Divide quaternions." }
20 { $examples { $example "USING: math.quaternions prettyprint ;" "{ 0 C{ 0 1 } } { 0 1 } q/ ." "{ C{ 0 1 } 0 }" } } ;
21
22 HELP: q*n
23 { $values { "q" "a quaternion" } { "n" number } { "q" "a quaternion" } }
24 { $description "Multiplies each element of " { $snippet "q" } " by " { $snippet "n" } "." }
25 { $notes "You will get the wrong result if you try to multiply a quaternion by a complex number on the right using " { $link v*n } ". Use this word instead."
26     $nl "Note that " { $link v*n } " with a quaternion and a real is okay." } ;
27
28 HELP: c>q
29 { $values { "c" number } { "q" "a quaternion" } }
30 { $description "Turn a complex number into a quaternion." }
31 { $examples { $example "USING: math.quaternions prettyprint ;" "C{ 0 1 } c>q ." "{ C{ 0 1 } 0 }" } } ;
32
33 HELP: v>q
34 { $values { "v" vector } { "q" "a quaternion" } }
35 { $description "Turn a 3-vector into a quaternion with real part 0." }
36 { $examples { $example "USING: math.quaternions prettyprint ;" "{ 1 0 0 } v>q ." "{ C{ 0 1 } 0 }" } } ;
37
38 HELP: q>v
39 { $values { "q" "a quaternion" } { "v" vector } }
40 { $description "Get the vector part of a quaternion, discarding the real part." }
41 { $examples { $example "USING: math.quaternions prettyprint ;" "{ C{ 0 1 } 0 } q>v ." "{ 1 0 0 }" } } ;
42
43 HELP: euler
44 { $values { "phi" number } { "theta" number } { "psi" number } { "q" "a quaternion" } }
45 { $description "Convert a rotation given by Euler angles (phi, theta, and psi) to a quaternion." } ;
46