1 # Created by Octave 3.6.1, Mon Apr 02 12:18:12 2012 UTC <root@t61>
13 # name: <cell-element>
17 -- Function File: [AXIS, ANGLE] = q2rot (Q)
18 Extract vector/angle form of a unit quaternion Q.
22 Unit quaternion describing the rotation.
26 Eigenaxis as a 3-d unit vector `[x, y, z]'.
29 Rotation angle in radians. The positive direction is
30 determined by the right-hand rule applied to AXIS.
33 octave:1> axis = [0, 0, 1]
36 octave:2> angle = pi/4
38 octave:3> q = rot2q (axis, angle)
39 q = 0.9239 + 0i + 0j + 0.3827k
40 octave:4> [vv, th] = q2rot (q)
44 octave:5> theta = th*180/pi
52 # name: <cell-element>
56 Extract vector/angle form of a unit quaternion Q.
60 # name: <cell-element>
67 # name: <cell-element>
71 @deftypefn {Function File} {} qi
72 Create x-component of a quaternion's vector part.
75 q = w + x*qi + y*qj + z*qk
81 octave:1> q1 = quaternion (1, 2, 3, 4)
83 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
93 # name: <cell-element>
97 @deftypefn {Function File} {} qi
98 Create x-component of a quaternion's vector p
102 # name: <cell-element>
109 # name: <cell-element>
113 @deftypefn {Function File} {} qj
114 Create y-component of a quaternion's vector part.
117 q = w + x*qi + y*qj + z*qk
123 octave:1> q1 = quaternion (1, 2, 3, 4)
124 q1 = 1 + 2i + 3j + 4k
125 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
126 q2 = 1 + 2i + 3j + 4k
135 # name: <cell-element>
139 @deftypefn {Function File} {} qj
140 Create y-component of a quaternion's vector p
144 # name: <cell-element>
151 # name: <cell-element>
155 @deftypefn {Function File} {} qk
156 Create z-component of a quaternion's vector part.
159 q = w + x*qi + y*qj + z*qk
165 octave:1> q1 = quaternion (1, 2, 3, 4)
166 q1 = 1 + 2i + 3j + 4k
167 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
168 q2 = 1 + 2i + 3j + 4k
177 # name: <cell-element>
181 @deftypefn {Function File} {} qk
182 Create z-component of a quaternion's vector p
186 # name: <cell-element>
193 # name: <cell-element>
197 -- Function File: Q = rot2q (AXIS, ANGLE)
198 Create unit quaternion Q which describes a rotation of ANGLE
199 radians about the vector AXIS. This function uses the active
200 convention where the vector AXIS is rotated by ANGLE radians. If
201 the coordinate frame should be rotated by ANGLE radians, also
202 called the passive convention, this is equivalent to rotating the
203 AXIS by -ANGLE radians.
207 Vector `[x, y, z]' describing the axis of rotation.
210 Rotation angle in radians. The positive direction is
211 determined by the right-hand rule applied to AXIS.
215 Unit quaternion describing the rotation.
218 octave:1> axis = [0, 0, 1];
219 octave:2> angle = pi/4;
220 octave:3> q = rot2q (axis, angle)
221 q = 0.9239 + 0i + 0j + 0.3827k
222 octave:4> v = quaternion (1, 1, 0)
224 octave:5> vr = q * v * conj (q)
225 vr = 0 + 0i + 1.414j + 0k
232 # name: <cell-element>
236 Create unit quaternion Q which describes a rotation of ANGLE radians