~ubuntu-branches/ubuntu/trusty/octave-quaternion/trusty-proposed

« back to all changes in this revision

Viewing changes to doc/functions.texi

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Sébastien Villemot, Thomas Weber
  • Date: 2013-11-06 14:44:29 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20131106144429-1286885ymo2ldcp4
Tags: 2.0.3-1
[ Sébastien Villemot ]
* Imported Upstream version 2.0.3
* debian/copyright: reflect upstream changes.
* Bump Standards-Version to 3.9.5, no changes needed.

[ Thomas Weber ]
* debian/control: Use canonical URLs in Vcs-* fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
@chapter Quaternions
2
 
@section quaternion
3
 
@findex quaternion
4
 
 
5
 
 @deftypefn {Function File} {@var{q} =} quaternion (@var{w})
6
 
 @deftypefnx {Function File} {@var{q} =} quaternion (@var{x}, @var{y}, @var{z})
7
 
 @deftypefnx {Function File} {@var{q} =} quaternion (@var{w}, @var{x}, @var{y}, @var{z})
8
 
 Constructor for quaternions - create or convert to quaternion.
9
 
 
10
 
 @example
11
 
 q = w + x*i + y*j + z*k
12
 
 @end example
13
 
 
14
 
 Arguments @var{w}, @var{x}, @var{y} and @var{z} can be scalars,
15
 
 matrices or n-dimensional arrays, but they must be real-valued
16
 
 and of equal size.
17
 
 If scalar part @var{w} or components @var{x}, @var{y} and @var{z}
18
 
 of the vector part are not specified, zero matrices of appropriate
19
 
 size are assumed.
20
 
 
21
 
 @strong{Example}
22
 
 @example
23
 
 @group
24
 
 octave:1> q = quaternion (2)
25
 
 q = 2 + 0i + 0j + 0k
26
 
 
27
 
 octave:2> q = quaternion (3, 4, 5)
28
 
 q = 0 + 3i + 4j + 5k
29
 
 
30
 
 octave:3> q = quaternion (2, 3, 4, 5)
31
 
 q = 2 + 3i + 4j + 5k
32
 
 @end group
33
 
 @end example
34
 
 @example
35
 
 @group
36
 
 octave:4> w = [2, 6, 10; 14, 18, 22];
37
 
 octave:5> x = [3, 7, 11; 15, 19, 23];
38
 
 octave:6> y = [4, 8, 12; 16, 20, 24];
39
 
 octave:7> z = [5, 9, 13; 17, 21, 25];
40
 
 octave:8> q = quaternion (w, x, y, z)
41
 
 q.w =
42
 
     2    6   10
43
 
    14   18   22
44
 
 
45
 
 q.x =
46
 
     3    7   11
47
 
    15   19   23
48
 
 
49
 
 q.y =
50
 
     4    8   12
51
 
    16   20   24
52
 
 
53
 
 q.z =
54
 
     5    9   13
55
 
    17   21   25
56
 
 
57
 
 octave:9> 
58
 
 @end group
59
 
 @end example
60
 
 
61
 
 @end deftypefn
62
 
@section qi
63
 
@findex qi
64
 
 
65
 
 @deftypefn {Function File} {} qi
66
 
 Create x-component of a quaternion's vector part.
67
 
 
68
 
 @example
69
 
 q = w + x*qi + y*qj + z*qk
70
 
 @end example
71
 
 
72
 
 @strong{Example}
73
 
 @example
74
 
 @group
75
 
 octave:1> q1 = quaternion (1, 2, 3, 4)
76
 
 q1 = 1 + 2i + 3j + 4k
77
 
 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
78
 
 q2 = 1 + 2i + 3j + 4k
79
 
 octave:3> 
80
 
 @end group
81
 
 @end example
82
 
 
83
 
 @end deftypefn
84
 
@section qj
85
 
@findex qj
86
 
 
87
 
 @deftypefn {Function File} {} qj
88
 
 Create y-component of a quaternion's vector part.
89
 
 
90
 
 @example
91
 
 q = w + x*qi + y*qj + z*qk
92
 
 @end example
93
 
 
94
 
 @strong{Example}
95
 
 @example
96
 
 @group
97
 
 octave:1> q1 = quaternion (1, 2, 3, 4)
98
 
 q1 = 1 + 2i + 3j + 4k
99
 
 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
100
 
 q2 = 1 + 2i + 3j + 4k
101
 
 octave:3> 
102
 
 @end group
103
 
 @end example
104
 
 
105
 
 @end deftypefn
106
 
@section qk
107
 
@findex qk
108
 
 
109
 
 @deftypefn {Function File} {} qk
110
 
 Create z-component of a quaternion's vector part.
111
 
 
112
 
 @example
113
 
 q = w + x*qi + y*qj + z*qk
114
 
 @end example
115
 
 
116
 
 @strong{Example}
117
 
 @example
118
 
 @group
119
 
 octave:1> q1 = quaternion (1, 2, 3, 4)
120
 
 q1 = 1 + 2i + 3j + 4k
121
 
 octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk
122
 
 q2 = 1 + 2i + 3j + 4k
123
 
 octave:3> 
124
 
 @end group
125
 
 @end example
126
 
 
127
 
 @end deftypefn
128
 
@section q2rot
129
 
@findex q2rot
130
 
 
131
 
 @deftypefn {Function File} {[@var{axis}, @var{angle}] =} q2rot (@var{q})
132
 
 Extract vector/angle form of a unit quaternion @var{q}.
133
 
 
134
 
 @strong{Inputs}
135
 
 @table @var
136
 
 @item q
137
 
 Unit quaternion describing the rotation.
138
 
 @end table
139
 
 
140
 
 @strong{Outputs}
141
 
 @table @var
142
 
 @item axis
143
 
 Eigenaxis as a 3-d unit vector @code{[x, y, z]}.
144
 
 @item angle
145
 
 Rotation angle in radians.  The positive direction is
146
 
 determined by the right-hand rule applied to @var{axis}.
147
 
 @end table
148
 
 
149
 
 @strong{Example}
150
 
 @example
151
 
 @group
152
 
 octave:1> axis = [0, 0, 1]
153
 
 axis =
154
 
    0   0   1
155
 
 octave:2> angle = pi/4
156
 
 angle =  0.78540
157
 
 octave:3> q = rot2q (axis, angle)
158
 
 q = 0.9239 + 0i + 0j + 0.3827k
159
 
 octave:4> [vv, th] = q2rot (q)
160
 
 vv =
161
 
    0   0   1
162
 
 th =  0.78540
163
 
 octave:5> theta = th*180/pi
164
 
 theta =  45.000
165
 
 octave:6> 
166
 
 @end group
167
 
 @end example
168
 
 
169
 
 @end deftypefn
170
 
@section rot2q
171
 
@findex rot2q
172
 
 
173
 
 @deftypefn {Function File} {@var{q} =} rot2q (@var{axis}, @var{angle})
174
 
 Create unit quaternion @var{q} which describes a rotation of
175
 
 @var{angle} radians about the vector @var{axis}.  This function uses
176
 
 the active convention where the vector @var{axis} is rotated by @var{angle}
177
 
 radians.  If the coordinate frame should be rotated by @var{angle}
178
 
 radians, also called the passive convention, this is equivalent
179
 
 to rotating the @var{axis} by @var{-angle} radians.
180
 
 
181
 
 @strong{Inputs}
182
 
 @table @var
183
 
 @item axis
184
 
 Vector @code{[x, y, z]} describing the axis of rotation.
185
 
 @item angle
186
 
 Rotation angle in radians.  The positive direction is
187
 
 determined by the right-hand rule applied to @var{axis}.
188
 
 @end table
189
 
 
190
 
 @strong{Outputs}
191
 
 @table @var
192
 
 @item q
193
 
 Unit quaternion describing the rotation.
194
 
 @end table
195
 
 
196
 
 @strong{Example}
197
 
 @example
198
 
 @group
199
 
 octave:1> axis = [0, 0, 1];
200
 
 octave:2> angle = pi/4;
201
 
 octave:3> q = rot2q (axis, angle)
202
 
 q = 0.9239 + 0i + 0j + 0.3827k
203
 
 octave:4> v = quaternion (1, 1, 0)
204
 
 v = 0 + 1i + 1j + 0k
205
 
 octave:5> vr = q * v * conj (q)
206
 
 vr = 0 + 0i + 1.414j + 0k
207
 
 octave:6>
208
 
 @end group
209
 
 @end example
210
 
 
211
 
 @end deftypefn
212
 
@chapter Quaternion Methods
213
 
@section @@quaternion/abs
214
 
@findex abs
215
 
 
216
 
 @deftypefn {Function File} {@var{qabs} =} abs (@var{q})
217
 
 Modulus of a quaternion.
218
 
 
219
 
 @example
220
 
 q = w + x*i + y*j + z*k
221
 
 abs (q) = sqrt (w.^2 + x.^2 + y.^2 + z.^2)
222
 
 @end example
223
 
 @end deftypefn
224
 
@section @@quaternion/blkdiag
225
 
@findex blkdiag
226
 
 
227
 
 @deftypefn {Function File} {@var{q} =} blkdiag (@var{q1}, @var{q2}, @dots{})
228
 
 Block-diagonal concatenation of quaternions.
229
 
 @end deftypefn
230
 
@section @@quaternion/cat
231
 
@findex cat
232
 
 
233
 
 @deftypefn {Function File} {@var{q} =} cat (@var{dim}, @var{q1}, @var{q2}, @dots{})
234
 
 Concatenation of quaternions along dimension @var{dim}.
235
 
 @end deftypefn
236
 
@section @@quaternion/columns
237
 
@findex columns
238
 
 
239
 
 @deftypefn {Function File} {@var{nc} =} columns (@var{q})
240
 
 Return number of columns @var{nc} of quaternion array @var{q}.
241
 
 @end deftypefn
242
 
@section @@quaternion/conj
243
 
@findex conj
244
 
 
245
 
 @deftypefn {Function File} {@var{q} =} conj (@var{q})
246
 
 Return conjugate of a quaternion.
247
 
 
248
 
 @example
249
 
 q = w + x*i + y*j + z*k
250
 
 conj (q) = w - x*i - y*j - z*k
251
 
 @end example
252
 
 @end deftypefn
253
 
@section @@quaternion/diag
254
 
@findex diag
255
 
 
256
 
 @deftypefn {Function File} {@var{q} =} diag (@var{v})
257
 
 @deftypefnx {Function File} {@var{q} =} diag (@var{v}, @var{k})
258
 
 Return a diagonal quaternion matrix with quaternion vector V on diagonal K.
259
 
 The second argument is optional. If it is positive,
260
 
 the vector is placed on the K-th super-diagonal.
261
 
 If it is negative, it is placed on the -K-th sub-diagonal.
262
 
 The default value of K is 0, and the vector is placed
263
 
 on the main diagonal.
264
 
 Given a matrix argument, instead of a vector, @command{diag}
265
 
 extracts the @var{K}-th diagonal of the matrix.
266
 
 @end deftypefn
267
 
@section @@quaternion/diff
268
 
@findex diff
269
 
 
270
 
 @deftypefn {Function File} {@var{qdot} =} diff (@var{q}, @var{omega})
271
 
 Derivative of a quaternion.
272
 
 
273
 
 Let Q be a quaternion to transform a vector from a fixed frame to
274
 
 a rotating frame.  If the rotating frame is rotating about the
275
 
 [x, y, z] axes at angular rates [wx, wy, wz], then the derivative
276
 
 of Q is given by
277
 
 
278
 
 @example
279
 
 Q' = diff(Q, omega)
280
 
 @end example
281
 
 
282
 
 If the passive convention is used (rotate the frame, not the vector),
283
 
 then
284
 
 
285
 
 @example
286
 
 Q' = diff(Q,-omega)
287
 
 @end example
288
 
 @end deftypefn
289
 
@section @@quaternion/exp
290
 
@findex exp
291
 
 
292
 
 @deftypefn {Function File} {@var{qexp} =} exp (@var{q})
293
 
 Exponential of a quaternion.
294
 
 @end deftypefn
295
 
@section @@quaternion/inv
296
 
@findex inv
297
 
 
298
 
 @deftypefn {Function File} {@var{qinv} =} inv (@var{q})
299
 
 Return inverse of a quaternion.
300
 
 @end deftypefn
301
 
@section @@quaternion/ispure
302
 
@findex ispure
303
 
 
304
 
 @deftypefn {Function File} {@var{flg} =} ispure (@var{q})
305
 
 Return 1 if scalar part of quaternion is zero, otherwise return 0
306
 
 @end deftypefn
307
 
@section @@quaternion/log
308
 
@findex log
309
 
 
310
 
 @deftypefn {Function File} {@var{qlog} =} log (@var{q})
311
 
 Logarithmus naturalis of a quaternion.
312
 
 @end deftypefn
313
 
@section @@quaternion/norm
314
 
@findex norm
315
 
 
316
 
 @deftypefn {Function File} {@var{n} =} norm (@var{q})
317
 
 Norm of a quaternion.
318
 
 @end deftypefn
319
 
@section @@quaternion/rows
320
 
@findex rows
321
 
 
322
 
 @deftypefn {Function File} {@var{nr} =} rows (@var{q})
323
 
 Return number of rows @var{nr} of quaternion array @var{q}.
324
 
 @end deftypefn
325
 
@section @@quaternion/size
326
 
@findex size
327
 
 
328
 
 @deftypefn {Function File} {@var{nvec} =} size (@var{q})
329
 
 @deftypefnx {Function File} {@var{n} =} size (@var{q}, @var{dim})
330
 
 @deftypefnx {Function File} {[@var{nx}, @var{ny}, @dots{}] =} size (@var{q})
331
 
 Return size of quaternion arrays.
332
 
 
333
 
 @strong{Inputs}
334
 
 @table @var
335
 
 @item q
336
 
 Quaternion object.
337
 
 @item dim
338
 
 If given a second argument, @command{size} will return the size of the
339
 
 corresponding dimension.
340
 
 @end table
341
 
 
342
 
 @strong{Outputs}
343
 
 @table @var
344
 
 @item nvec
345
 
 Row vector.  The first element is the number of rows and the second
346
 
 element the number of columns.  If @var{q} is an n-dimensional array
347
 
 of quaternions, the n-th element of @var{nvec} corresponds to the
348
 
 size of the n-th dimension of @var{q}.
349
 
 @item n
350
 
 Scalar value.  The size of the dimension @var{dim}.
351
 
 @item nx
352
 
 Number of rows.
353
 
 @item ny
354
 
 Number of columns.
355
 
 @item @dots{}
356
 
 Sizes of the 3rd to n-th dimensions.
357
 
 @end table
358
 
 @end deftypefn
359
 
@section @@quaternion/size_equal
360
 
@findex size_equal
361
 
 
362
 
 @deftypefn {Function File} {@var{bool} =} size_equal (@var{a}, @var{b}, @dots{})
363
 
 Return true if quaternions (and matrices) @var{a}, @var{b}, @dots{}
364
 
 are of equal size and false otherwise.
365
 
 @end deftypefn
366
 
@section @@quaternion/unit
367
 
@findex unit
368
 
 
369
 
 @deftypefn {Function File} {@var{qn} =} unit (@var{q})
370
 
 Normalize quaternion to length 1 (unit quaternion).
371
 
 
372
 
 @example
373
 
 q = w + x*i + y*j + z*k
374
 
 unit (q) = q ./ sqrt (w.^2 + x.^2 + y.^2 + z.^2)
375
 
 @end example
376
 
 @end deftypefn
377
 
@chapter Overloaded Quaternion Operators
378
 
@section @@quaternion/ctranspose
379
 
@findex ctranspose
380
 
 
381
 
 Conjugate transpose of a quaternion.  Used by Octave for "q'".
382
 
@section @@quaternion/eq
383
 
@findex eq
384
 
 
385
 
 Equal to operator for two quaternions.  Used by Octave for "q1 == q2".
386
 
@section @@quaternion/horzcat
387
 
@findex horzcat
388
 
 
389
 
 Horizontal concatenation of quaternions.  Used by Octave for "[q1, q2]".
390
 
@section @@quaternion/ldivide
391
 
@findex ldivide
392
 
 
393
 
 Element-wise left division for quaternions.  Used by Octave for "q1 .\ q2".
394
 
@section @@quaternion/minus
395
 
@findex minus
396
 
 
397
 
 Subtraction of two quaternions.  Used by Octave for "q1 - q2".
398
 
@section @@quaternion/mldivide
399
 
@findex mldivide
400
 
 
401
 
 Matrix left division for quaternions.  Used by Octave for "q1 \ q2".
402
 
@section @@quaternion/mpower
403
 
@findex mpower
404
 
 
405
 
 Matrix power operator of quaternions.  Used by Octave for "q^x".
406
 
@section @@quaternion/mrdivide
407
 
@findex mrdivide
408
 
 
409
 
 Matrix right division for quaternions.  Used by Octave for "q1 / q2".
410
 
@section @@quaternion/mtimes
411
 
@findex mtimes
412
 
 
413
 
 Matrix multiplication of two quaternions. Used by Octave for "q1 * q2".
414
 
@section @@quaternion/plus
415
 
@findex plus
416
 
 
417
 
 Addition of two quaternions.  Used by Octave for "q1 + q2".
418
 
@section @@quaternion/power
419
 
@findex power
420
 
 
421
 
 Power operator of quaternions.  Used by Octave for "q.^x".
422
 
 Exponent x can be scalar or of appropriate size.
423
 
@section @@quaternion/rdivide
424
 
@findex rdivide
425
 
 
426
 
 Element-wise right division for quaternions.  Used by Octave for "q1 ./ q2".
427
 
@section @@quaternion/subsasgn
428
 
@findex subsasgn
429
 
 
430
 
 Subscripted assignment for quaternions.
431
 
 Used by Octave for "q.key = value".
432
 
@section @@quaternion/subsref
433
 
@findex subsref
434
 
 
435
 
 Subscripted reference for quaternions.  Used by Octave for "q.w".
436
 
@section @@quaternion/times
437
 
@findex times
438
 
 
439
 
 Element-wise multiplication of two quaternions.  Used by Octave for "q1 .* q2".
440
 
@section @@quaternion/transpose
441
 
@findex transpose
442
 
 
443
 
 Transpose of a quaternion.  Used by Octave for "q.'".
444
 
@section @@quaternion/uminus
445
 
@findex uminus
446
 
 
447
 
 Unary minus of a quaternion.  Used by Octave for "-q".
448
 
@section @@quaternion/uplus
449
 
@findex uplus
450
 
 
451
 
 Unary plus of a quaternion.  Used by Octave for "+q".
452
 
@section @@quaternion/vertcat
453
 
@findex vertcat
454
 
 
455
 
 Vertical concatenation of quaternions.  Used by Octave for "[q1; q2]".