./PaxHeaders/quaternion-2.4.20000644000000000000000000000013215116327664013055 xustar0030 mtime=1765388212.189950009 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/0000755000175000017500000000000015116327664012121 5ustar00nirnirquaternion-2.4.2/PaxHeaders/DESCRIPTION0000644000000000000000000000006215116327650014500 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/DESCRIPTION0000644000175000017500000000054315116327650013624 0ustar00nirnirName: quaternion Version: 2.4.2 Date: 2025-12-10 Author: Lukas Reichlin Maintainer: Lukas Reichlin Title: Quaternion Description: Quaternion package for GNU Octave, includes a quaternion class with overloaded operators Depends: octave (>= 4.4.0) Autoload: no License: GPLv3+ Url: http://octave.sf.net quaternion-2.4.2/PaxHeaders/doc0000644000000000000000000000012615116327664013470 xustar0026 mtime=1765388212.18895 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/doc/0000755000175000017500000000000015116327664012666 5ustar00nirnirquaternion-2.4.2/doc/PaxHeaders/placeholder.txt0000644000000000000000000000006215116327650016562 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/doc/placeholder.txt0000644000175000017500000000010515116327650015700 0ustar00nirnirThe documents in the 'doc' folder are generated upon package release.quaternion-2.4.2/PaxHeaders/INDEX0000644000000000000000000000006215116327650013564 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/INDEX0000644000175000017500000000274215116327650012713 0ustar00nirnirquaternion >> Quaternion Quaternion Constructors quaternion qi qj qk Conversions q2rot rot2q rotm2q Quaternion Methods @quaternion/abs @quaternion/arg @quaternion/blkdiag @quaternion/cast @quaternion/cat @quaternion/ceil @quaternion/columns @quaternion/conj @quaternion/cumsum @quaternion/diag @quaternion/diff @quaternion/exp @quaternion/fix @quaternion/floor @quaternion/full @quaternion/get @quaternion/inv @quaternion/isempty @quaternion/isfinite @quaternion/isinf @quaternion/isnan @quaternion/ispure @quaternion/isreal @quaternion/length @quaternion/log @quaternion/mean @quaternion/ndims @quaternion/norm @quaternion/numel @quaternion/repmat @quaternion/reshape @quaternion/round @quaternion/rows @quaternion/set @quaternion/size @quaternion/size_equal @quaternion/sparse @quaternion/squeeze @quaternion/sum @quaternion/tril @quaternion/triu @quaternion/unit Overloaded Quaternion Operators @quaternion/ctranspose @quaternion/end @quaternion/eq @quaternion/ge @quaternion/gt @quaternion/horzcat @quaternion/ldivide @quaternion/le @quaternion/lt @quaternion/minus @quaternion/mldivide @quaternion/mpower @quaternion/mrdivide @quaternion/mtimes @quaternion/ne @quaternion/plus @quaternion/power @quaternion/rdivide @quaternion/subsasgn @quaternion/subsref @quaternion/times @quaternion/transpose @quaternion/uminus @quaternion/uplus @quaternion/vertcat quaternion-2.4.2/PaxHeaders/inst0000644000000000000000000000013215116327664013675 xustar0030 mtime=1765388212.209950201 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/0000755000175000017500000000000015116327664013076 5ustar00nirnirquaternion-2.4.2/inst/PaxHeaders/qi.m0000644000000000000000000000006215116327650014536 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/qi.m0000644000175000017500000000243615116327650013665 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} qi ## Create x-component of a quaternion's vector part. ## ## @example ## q = w + x*qi + y*qj + z*qk ## @end example ## ## @strong{Example} ## @example ## @group ## octave:1> q1 = quaternion (1, 2, 3, 4) ## q1 = 1 + 2i + 3j + 4k ## octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk ## q2 = 1 + 2i + 3j + 4k ## octave:3> ## @end group ## @end example ## ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function q = qi if (nargin != 0) print_usage (); endif q = quaternion (0, 1, 0, 0); endfunction quaternion-2.4.2/inst/PaxHeaders/q2rot.m0000644000000000000000000000006215116327650015174 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/q2rot.m0000644000175000017500000001000215116327650014307 0ustar00nirnir## Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Auburn University ## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{axis}, @var{angle}] =} q2rot (@var{q}) ## @deftypefnx {Function File} {[@var{axis}, @var{angle}, @var{qn}] =} q2rot (@var{q}) ## Extract vector/angle form of a unit quaternion @var{q}. ## ## @strong{Inputs} ## @table @var ## @item q ## Unit quaternion describing the rotation. ## Quaternion @var{q} can be a scalar or an array. ## In the latter case, @var{q} is reshaped to a row vector ## and the return values @var{axis} and @var{angle} are ## concatenated horizontally, accordingly. ## @end table ## ## @strong{Outputs} ## @table @var ## @item axis ## Eigenaxis as a 3-d unit vector @code{[x; y; z]}. ## If input argument @var{q} is a quaternion array, ## @var{axis} becomes a matrix where ## @var{axis(:,i)} corresponds to @var{q(i)}. ## @item angle ## Rotation angle in radians. The positive direction is ## determined by the right-hand rule applied to @var{axis}. ## The angle lies in the interval [0, 2*pi]. ## If input argument @var{q} is a quaternion array, ## @var{angle} becomes a row vector where ## @var{angle(i)} corresponds to @var{q(i)}. ## @item qn ## Optional output of diagnostic nature. ## @code{qn = reshape (q, 1, [])} or, if needed, ## @code{qn = reshape (unit (q), 1, [])}. ## @end table ## ## @strong{Example} ## @example ## @group ## octave:1> axis = [0; 0; 1] ## axis = ## ## 0 ## 0 ## 1 ## ## octave:2> angle = pi/4 ## angle = 0.78540 ## octave:3> q = rot2q (axis, angle) ## q = 0.9239 + 0i + 0j + 0.3827k ## octave:4> [vv, th] = q2rot (q) ## vv = ## ## 0 ## 0 ## 1 ## ## th = 0.78540 ## octave:5> theta = th*180/pi ## theta = 45.000 ## octave:6> ## @end group ## @end example ## ## @end deftypefn ## Adapted from: quaternion by A. S. Hodel ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.4 function [vv, theta, q] = q2rot (q) if (nargin != 1 || nargout > 3) print_usage (); endif if (! isa (q, "quaternion")) error ("q2rot: require quaternion as input"); endif if (any (abs (abs (q) - 1) > 1e-12)) warning ("q2rot:normalizing", "q2rot: abs(q) != 1, normalizing"); q = unit (q); # do we still need this with the atan2 formula? endif q = reshape (q, 1, []); # row vector ## According to Wikipedia, ## ## the formula using atan2 ## theta = 2 * atan2 (||x||, s) ## should be numerically more stable than ## theta = 2 * acos (s) ## Possibly it helps if the quaternion has not exactly unit length. vv = [q.x; q.y; q.z]; norm_vv = norm (vv, 2, "cols"); theta = 2 * atan2 (norm_vv, q.w); ## NOTE: sin (theta/2) = norm (vv) idx = (norm_vv != 0); if (any (idx)) vv(:, idx) ./= ones (3, 1) * norm_vv(idx); # normalize vectors, prevent division by zero endif idx = ! idx; if (any (idx)) vv(:, idx) = [1; 0; 0] * ones (1, nnz (idx)); # set real-valued quaternions to default value endif endfunction %!test %! q = quaternion (2, 0, 0, 0); %! w = warning ("query", "q2rot:normalizing"); %! warning ("off", w.identifier); %! [vv, th, qn] = q2rot (q); %! warning (w.identifier, w.state); %! assert (vv, [1; 0; 0], 1e-4); %! assert (th, 0, 1e-4); %! assert (qn == quaternion (1), true); quaternion-2.4.2/inst/PaxHeaders/rotm2q.m0000644000000000000000000000006215116327650015351 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/rotm2q.m0000644000175000017500000000445115116327650014477 0ustar00nirnir## Copyright (C) 2013 Willem Atsma ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} rotm2q (@var{R}) ## Convert 3x3 rotation matrix @var{R} to unit quaternion @var{q}. ## @end deftypefn ## Author: Willem Atsma ## Based on C code from ## Created: May 2013 ## Version: 0.1 function q = rotm2q (R) if (nargin != 1) print_usage (); endif if (! (isnumeric (R) && isreal (R)) || ! isequal (size (R), [3, 3])) error ("rotm2q: require a (3x3) rotation matrix"); endif T = trace (R); if (T > 0) s = 0.5 / sqrt (T+1); w = 0.25 / s; x = (R(3,2) - R(2,3)) * s; y = (R(1,3) - R(3,1)) * s; z = (R(2,1) - R(1,2)) * s; else if (R(1,1) > R(2,2) && R(1,1) > R(3,3)) s = 2 * sqrt (1 + R(1,1) - R(2,2) - R(3,3)); w = (R(3,2) - R(2,3)) / s; x = 0.25 * s; y = (R(1,2) + R(2,1)) / s; z = (R(1,3) + R(3,1)) / s; elseif (R(2,2) > R(3,3)) s = 2 * sqrt (1 + R(2,2) - R(1,1) - R(3,3)); w = (R(1,3) - R(3,1)) / s; x = (R(1,2) + R(2,1)) / s; y = 0.25 * s; z = (R(2,3) + R(3,2) ) / s; else s = 2 * sqrt (1 + R(3,3) - R(1,1) - R(2,2)); w = (R(2,1) - R(1,2)) / s; x = (R(1,3) + R(3,1)) / s; y = (R(2,3) + R(3,2)) / s; z = 0.25 * s; endif endif q = quaternion (w, x, y, z); endfunction %!test %! R = eye (3); %! q = rotm2q (R); %! assert (q.w, 1, 1e-4); %! assert (q.x, 0, 1e-4); %! assert (q.y, 0, 1e-4); %! assert (q.z, 0, 1e-4); %!test %! R = [[1;0;0], [0;0;1], [0;-1;0]]; %! q = rotm2q (R); %! [ax, an] = q2rot (q); %! assert (ax(:), [1;0;0], 1e-4); %! assert (an, pi/2, 1e-4); quaternion-2.4.2/inst/PaxHeaders/qk.m0000644000000000000000000000006215116327650014540 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/qk.m0000644000175000017500000000243615116327650013667 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} qk ## Create z-component of a quaternion's vector part. ## ## @example ## q = w + x*qi + y*qj + z*qk ## @end example ## ## @strong{Example} ## @example ## @group ## octave:1> q1 = quaternion (1, 2, 3, 4) ## q1 = 1 + 2i + 3j + 4k ## octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk ## q2 = 1 + 2i + 3j + 4k ## octave:3> ## @end group ## @end example ## ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function q = qk if (nargin != 0) print_usage (); endif q = quaternion (0, 0, 0, 1); endfunction quaternion-2.4.2/inst/PaxHeaders/qj.m0000644000000000000000000000006215116327650014537 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/qj.m0000644000175000017500000000243615116327650013666 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} qj ## Create y-component of a quaternion's vector part. ## ## @example ## q = w + x*qi + y*qj + z*qk ## @end example ## ## @strong{Example} ## @example ## @group ## octave:1> q1 = quaternion (1, 2, 3, 4) ## q1 = 1 + 2i + 3j + 4k ## octave:2> q2 = 1 + 2*qi + 3*qj + 4*qk ## q2 = 1 + 2i + 3j + 4k ## octave:3> ## @end group ## @end example ## ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function q = qj if (nargin != 0) print_usage (); endif q = quaternion (0, 0, 1, 0); endfunction quaternion-2.4.2/inst/PaxHeaders/rot2q.m0000644000000000000000000000006215116327650015174 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/rot2q.m0000644000175000017500000000653615116327650014330 0ustar00nirnir## Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Auburn University ## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} rot2q (@var{axis}, @var{angle}) ## Create unit quaternion @var{q} which describes a rotation of ## @var{angle} radians about the vector @var{axis}. This function uses ## the active convention where the vector @var{axis} is rotated by @var{angle} ## radians. If the coordinate frame should be rotated by @var{angle} ## radians, also called the passive convention, this is equivalent ## to rotating the @var{axis} by @var{-angle} radians. ## ## @strong{Inputs} ## @table @var ## @item axis ## Vector @code{[x, y, z]} or @code{[x; y; z]} describing the axis of rotation. ## @item angle ## Rotation angle in radians. The positive direction is ## determined by the right-hand rule applied to @var{axis}. ## If @var{angle} is a real-valued array, a quaternion array ## @var{q} of the same size is returned. ## @end table ## ## @strong{Outputs} ## @table @var ## @item q ## Unit quaternion describing the rotation. ## If @var{angle} is an array, @var{q(i,j)} corresponds to ## the rotation angle @var{angle(i,j)}. ## @end table ## ## @strong{Example} ## @example ## @group ## octave:1> axis = [0, 0, 1]; ## octave:2> angle = pi/4; ## octave:3> q = rot2q (axis, angle) ## q = 0.9239 + 0i + 0j + 0.3827k ## octave:4> v = quaternion (1, 1, 0) ## v = 0 + 1i + 1j + 0k ## octave:5> vr = q * v * conj (q) ## vr = 0 + 0i + 1.414j + 0k ## octave:6> ## @end group ## @end example ## ## @end deftypefn ## Adapted from: quaternion by A. S. Hodel ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = rot2q (vv, theta) if (nargin != 2 || nargout > 1) print_usage (); endif if (! (isnumeric (vv) && isreal (vv)) || ! isvector (vv) || length (vv) != 3) error ("rot2q: first argument 'axis' must be a length three vector"); endif if (! (isnumeric (theta) && isreal (theta))) error ("rot2q: second argument 'angle' must be a scalar"); endif if (norm (vv) == 0) error ("rot2q: first argument 'axis' is zero"); endif if (abs (norm (vv) - 1) > 1e-12) warning ("rot2q:axis", "rot2q: ||axis|| != 1, normalizing") vv = vv / norm (vv); endif if (any ((abs (theta) > 2*pi)(:))) warning ("rot2q:angle", "rot2q: |angle| > 2 pi, normalizing") theta = rem (theta, 2*pi); endif w = cos (theta ./ 2); st2 = sin (theta ./ 2); x = vv(1) .* st2; y = vv(2) .* st2; z = vv(3) .* st2; q = quaternion (w, x, y, z); endfunction %!shared ax, an %! q = rot2q ([1;0;0], -1.2*pi); %! [ax, an] = q2rot (q); %!assert (abs (ax(1)), 1, 1e-4); %!assert (an*ax(1), -1.2*pi, 1e-4); quaternion-2.4.2/inst/PaxHeaders/@quaternion0000644000000000000000000000013215116327664016162 xustar0030 mtime=1765388212.208950192 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/0000755000175000017500000000000015116327664015363 5ustar00nirnirquaternion-2.4.2/inst/@quaternion/PaxHeaders/cat.m0000644000000000000000000000006215116327650017161 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/cat.m0000644000175000017500000000452515116327650016311 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} cat (@var{dim}, @var{q1}, @var{q2}, @dots{}) ## Concatenation of quaternions along dimension @var{dim}. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function q = cat (dim, varargin) ## Convert all inputs to quaternions tmp_cell = cellfun (@quaternion, varargin, "UniformOutput", false); ## Extract components from each quaternion in the cell array w_cell = cellfun (@(q) q.w, tmp_cell, "UniformOutput", false); x_cell = cellfun (@(q) q.x, tmp_cell, "UniformOutput", false); y_cell = cellfun (@(q) q.y, tmp_cell, "UniformOutput", false); z_cell = cellfun (@(q) q.z, tmp_cell, "UniformOutput", false); ## Explicitly call builtin to avoid recursion w = builtin ("cat", dim, w_cell{:}); x = builtin ("cat", dim, x_cell{:}); y = builtin ("cat", dim, y_cell{:}); z = builtin ("cat", dim, z_cell{:}); q = quaternion (w, x, y, z); endfunction %!shared A, B, C1, C2, D1, D2 %! Aw = [2, 6; 10, 14]; %! Ax = [3, 7; 11, 15]; %! Ay = [4, 8; 12, 16]; %! Az = [5, 9; 13, 17]; %! A = quaternion (Aw, Ax, Ay, Az); %! %! Bw = [18, 22; 26, 30]; %! Bx = [19, 23; 27, 31]; %! By = [20, 24; 28, 32]; %! Bz = [21, 25; 29, 33]; %! B = quaternion (Bw, Bx, By, Bz); %! %! C1 = cat (1, A, B); %! C2 = cat (2, A, B); %! %! D1w = cat (1, Aw, Bw); %! D1x = cat (1, Ax, Bx); %! D1y = cat (1, Ay, By); %! D1z = cat (1, Az, Bz); %! D1 = quaternion (D1w, D1x, D1y, D1z); %! %! D2w = cat (2, Aw, Bw); %! D2x = cat (2, Ax, Bx); %! D2y = cat (2, Ay, By); %! D2z = cat (2, Az, Bz); %! D2 = quaternion (D2w, D2x, D2y, D2z); %!assert (C1 == D1); %!assert (C2 == D2); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ne.m0000644000000000000000000000006215116327650017014 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ne.m0000644000175000017500000000221515116327650016136 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Not-equal-to operator for two quaternions. Used by Octave for "q1 != q2". ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = ne (a, b) if (nargin != 2) error ("quaternion: ne: this is a binary operator"); endif bool = ! eq (a, b); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a != a, false); %! assert (a != b, true); quaternion-2.4.2/inst/@quaternion/PaxHeaders/repmat.m0000644000000000000000000000006215116327650017702 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/repmat.m0000644000175000017500000000460315116327650017027 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qret} =} repmat (@var{q}, @var{m}) ## @deftypefnx {Function File} {@var{qret} =} repmat (@var{q}, @var{m}, @var{n}) ## @deftypefnx {Function File} {@var{qret} =} repmat (@var{q}, [@var{m} @var{n}]) ## @deftypefnx {Function File} {@var{qret} =} repmat (@var{q}, [@var{m} @var{n} @var{p} @dots{}]) ## Form a block quaternion matrix @var{qret} of size @var{m} by @var{n}, ## with a copy of quaternion matrix @var{q} as each element. ## If @var{n} is not specified, form an @var{m} by @var{m} block matrix. ## @end deftypefn ## Author: Lukas Reichlin ## Created: July 2014 ## Version: 0.1 function q = repmat (a, varargin) if (! isa (a, "quaternion")) print_usage (); endif w = builtin ("repmat", a.w, varargin{:}); x = builtin ("repmat", a.x, varargin{:}); y = builtin ("repmat", a.y, varargin{:}); z = builtin ("repmat", a.z, varargin{:}); q = quaternion (w, x, y, z); endfunction %!test %! ## Test repmat with single scalar argument %! q = quaternion (1, 2, 3, 4); %! result = repmat (q, 2); %! expected = quaternion (repmat(1, 2), repmat(2, 2), repmat(3, 2), repmat(4, 2)); %! assert (result == expected); %!test %! ## Test repmat with two arguments %! q = quaternion (1, 2, 3, 4); %! result = repmat (q, 2, 3); %! expected = quaternion (repmat(1, 2, 3), repmat(2, 2, 3), repmat(3, 2, 3), repmat(4, 2, 3)); %! assert (result == expected); %!test %! ## Test repmat with vector %! w = [1, 2]; %! x = [3, 4]; %! y = [5, 6]; %! z = [7, 8]; %! q = quaternion (w, x, y, z); %! result = repmat (q, 2, 1); %! expected = quaternion (repmat(w, 2, 1), repmat(x, 2, 1), repmat(y, 2, 1), repmat(z, 2, 1)); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/reshape.m0000644000000000000000000000006215116327650020041 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/reshape.m0000644000175000017500000000454015116327650017166 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} reshape (@var{q}, @var{m}, @var{n}, @dots{}) ## @deftypefnx {Function File} {@var{q} =} reshape (@var{q}, [@var{m} @var{n} @dots{}]) ## @deftypefnx {Function File} {@var{q} =} reshape (@var{q}, @dots{}, [], @dots{}) ## @deftypefnx {Function File} {@var{q} =} reshape (@var{q}, @var{size}) ## Return a quaternion array with the specified dimensions (@var{m}, @var{n}, @dots{}) ## whose elements are taken from the quaternion array @var{q}. The elements of the ## quaternion are accessed in column-major order (like Fortran arrays are stored). ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = reshape (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("reshape", q.w, varargin{:}); q.x = builtin ("reshape", q.x, varargin{:}); q.y = builtin ("reshape", q.y, varargin{:}); q.z = builtin ("reshape", q.z, varargin{:}); endfunction %!test %! ## Test reshape from 2x3 to 3x2 %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! result = reshape (q, 3, 2); %! expected = quaternion (reshape(w, 3, 2), reshape(x, 3, 2), reshape(y, 3, 2), reshape(z, 3, 2)); %! assert (result == expected); %!test %! ## Test reshape to row vector %! w = [1, 2; 3, 4]; %! x = [5, 6; 7, 8]; %! y = [9, 10; 11, 12]; %! z = [13, 14; 15, 16]; %! q = quaternion (w, x, y, z); %! result = reshape (q, 1, 4); %! expected = quaternion (reshape(w, 1, 4), reshape(x, 1, 4), reshape(y, 1, 4), reshape(z, 1, 4)); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ceil.m0000644000000000000000000000006215116327650017326 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ceil.m0000644000175000017500000000241715116327650016454 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} ceil (@var{q}) ## Round quaternion @var{q} towards positive infinity. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = ceil (q) if (nargin != 1) print_usage (); endif q.w = builtin ("ceil", q.w); q.x = builtin ("ceil", q.x); q.y = builtin ("ceil", q.y); q.z = builtin ("ceil", q.z); endfunction %!test %! q = quaternion (1.2, 2.7, 3.1, 4.9); %! result = ceil (q); %! expected = quaternion (2, 3, 4, 5); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/sum.m0000644000000000000000000000006215116327650017216 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/sum.m0000644000175000017500000000471615116327650016350 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} sum (@var{q}) ## @deftypefnx {Function File} {@var{q} =} sum (@var{q}, @var{dim}) ## @deftypefnx {Function File} {@var{q} =} sum (@dots{}, @var{'native'}) ## @deftypefnx {Function File} {@var{q} =} sum (@dots{}, @var{'double'}) ## @deftypefnx {Function File} {@var{q} =} sum (@dots{}, @var{'extra'}) ## Sum of elements along dimension @var{dim}. If @var{dim} is omitted, ## it defaults to the first non-singleton dimension. ## See @code{help sum} for more information. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = sum (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("sum", q.w, varargin{:}); q.x = builtin ("sum", q.x, varargin{:}); q.y = builtin ("sum", q.y, varargin{:}); q.z = builtin ("sum", q.z, varargin{:}); endfunction %!test %! ## Test sum along default dimension (columns) %! w = [1, 2; 3, 4]; %! x = [5, 6; 7, 8]; %! y = [9, 10; 11, 12]; %! z = [13, 14; 15, 16]; %! q = quaternion (w, x, y, z); %! result = sum (q); %! expected = quaternion (sum(w), sum(x), sum(y), sum(z)); %! assert (result == expected); %!test %! ## Test sum along dimension 2 (rows) %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! result = sum (q, 2); %! expected = quaternion (sum(w, 2), sum(x, 2), sum(y, 2), sum(z, 2)); %! assert (result == expected); %!test %! ## Test sum of vector %! q = quaternion ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]); %! result = sum (q); %! expected = quaternion (sum([1,2,3,4]), sum([5,6,7,8]), sum([9,10,11,12]), sum([13,14,15,16])); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/exp.m0000644000000000000000000000006215116327650017206 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/exp.m0000644000175000017500000000252215116327650016331 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qexp} =} exp (@var{q}) ## Exponential of a quaternion. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function q = exp (q) if (nargin != 1) print_usage (); endif normv = normv (q); exps = exp (q.w); sinv = sin (normv); q.w = exps .* cos (normv); q.x = exps .* (q.x ./ normv) .* sinv; q.y = exps .* (q.y ./ normv) .* sinv; q.z = exps .* (q.z ./ normv) .* sinv; endfunction %!test %! q = quaternion (0, 0, 0, 0); %! result = exp (q); %! expected = quaternion (1, 0, 0, 0); %! assert (result.w, expected.w, eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/gt.m0000644000000000000000000000006215116327650017024 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/gt.m0000644000175000017500000000260615116327650016152 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Greater-than operator for two quaternions. ## Used by Octave for "q1 > q2". ## The ordering is lexicographic. ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = gt (a, b) if (nargin != 2) error ("quaternion: gt: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); bool = (a.w > b.w) ... | (a.w == b.w & a.x > b.x) ... | (a.w == b.w & a.x == b.x & a.y > b.y) ... | (a.w == b.w & a.x == b.x & a.y == b.y & a.z > b.z); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a > b, true); %! assert (b > a, false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/mldivide.m0000644000000000000000000000006215116327650020207 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/mldivide.m0000644000175000017500000000235015116327650017331 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Matrix left division for quaternions. ## Used by Octave for ## ## @example ## @var{q1} @backslashchar{} @var{q2} ## @end example ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = mldivide (a, b) if (nargin != 2) error ("quaternion: mldivide: this is a binary operator"); endif q = inv (a) * b; endfunction %!test %! a = quaternion (2, 0, 0, 0); %! b = quaternion (4, 0, 0, 0); %! result = a \ b; %! expected = quaternion (2, 0, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/blkdiag.m0000644000000000000000000000006215116327650020007 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/blkdiag.m0000644000175000017500000000417615116327650017141 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} blkdiag (@var{q1}, @var{q2}, @dots{}) ## Block-diagonal concatenation of quaternions. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2011 ## Version: 0.1 function q = blkdiag (varargin) ## Convert all inputs to quaternions tmp_cell = cellfun (@quaternion, varargin, "UniformOutput", false); ## Extract components from each quaternion in the cell array w_cell = cellfun (@(q) q.w, tmp_cell, "UniformOutput", false); x_cell = cellfun (@(q) q.x, tmp_cell, "UniformOutput", false); y_cell = cellfun (@(q) q.y, tmp_cell, "UniformOutput", false); z_cell = cellfun (@(q) q.z, tmp_cell, "UniformOutput", false); ## Explicitly call builtin to avoid recursion w = builtin ("blkdiag", w_cell{:}); x = builtin ("blkdiag", x_cell{:}); y = builtin ("blkdiag", y_cell{:}); z = builtin ("blkdiag", z_cell{:}); q = quaternion (w, x, y, z); endfunction %!shared C, D %! Aw = [2, 6; 10, 14]; %! Ax = [3, 7; 11, 15]; %! Ay = [4, 8; 12, 16]; %! Az = [5, 9; 13, 17]; %! A = quaternion (Aw, Ax, Ay, Az); %! %! Bw = [2, 6, 10; 14, 18, 22]; %! Bx = [3, 7, 11; 15, 19, 23]; %! By = [4, 8, 12; 16, 20, 24]; %! Bz = [5, 9, 13; 17, 21, 25]; %! B = quaternion (Bw, Bx, By, Bz); %! %! C = blkdiag (A, B); %! %! Dw = blkdiag (Aw, Bw); %! Dx = blkdiag (Ax, Bx); %! Dy = blkdiag (Ay, By); %! Dz = blkdiag (Az, Bz); %! D = quaternion (Dw, Dx, Dy, Dz); %!assert (C == D); quaternion-2.4.2/inst/@quaternion/PaxHeaders/norm.m0000644000000000000000000000006215116327650017365 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/norm.m0000644000175000017500000000250215116327650016506 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{n} =} norm (@var{q}) ## Norm of a quaternion. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function n = norm (a) if (nargin != 1) print_usage (); endif if (! isscalar (a.w)) warning ("norm: use 'abs' to calculate the lengths of quaternion arrays"); error ("norm: only the 2-norm of scalar quaternions is implemented until now"); endif n = abs (a); endfunction %!test %! q = quaternion (2, 3, 4, 5); %! result = norm (q); %! expected = sqrt (4 + 9 + 16 + 25); %! assert (result, expected, eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/abs.m0000644000000000000000000000006215116327650017157 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/abs.m0000644000175000017500000000235615116327650016307 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qabs} =} abs (@var{q}) ## Modulus of a quaternion. ## ## @example ## q = w + x*i + y*j + z*k ## abs (q) = sqrt (w.^2 + x.^2 + y.^2 + z.^2) ## @end example ## @end deftypefn ## Author: Lukas Reichlin ## Created: August 2010 ## Version: 0.2 function b = abs (a) if (nargin != 1) print_usage (); endif b = sqrt (norm2 (a)); endfunction %!test %! q = quaternion (2, 3, 4, 5); %! result = abs (q); %! expected = sqrt (4 + 9 + 16 + 25); %! assert (result, expected, eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/rows.m0000644000000000000000000000006215116327650017404 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/rows.m0000644000175000017500000000215715116327650016533 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{nr} =} rows (@var{q}) ## Return number of rows @var{nr} of quaternion array @var{q}. ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function r = rows (a) if (nargin != 1) print_usage (); endif r = rows (a.w); endfunction %!test %! w = ones (3, 4); %! q = quaternion (w, w, w, w); %! assert (rows (q), 3); quaternion-2.4.2/inst/@quaternion/PaxHeaders/conj.m0000644000000000000000000000006215116327650017343 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/conj.m0000644000175000017500000000237315116327650016472 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} conj (@var{q}) ## Return conjugate of a quaternion. ## ## @example ## q = w + x*i + y*j + z*k ## conj (q) = w - x*i - y*j - z*k ## @end example ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function a = conj (a) if (nargin != 1) print_usage (); endif a.x = -a.x; a.y = -a.y; a.z = -a.z; endfunction %!test %! q = quaternion (1, 2, 3, 4); %! result = conj (q); %! expected = quaternion (1, -2, -3, -4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/columns.m0000644000000000000000000000006215116327650020072 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/columns.m0000644000175000017500000000217615116327650017222 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{nc} =} columns (@var{q}) ## Return number of columns @var{nc} of quaternion array @var{q}. ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function c = columns (a) if (nargin != 1) print_usage (); endif c = columns (a.w); endfunction %!test %! w = ones (3, 4); %! q = quaternion (w, w, w, w); %! assert (columns (q), 4); quaternion-2.4.2/inst/@quaternion/PaxHeaders/inv.m0000644000000000000000000000006215116327650017206 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/inv.m0000644000175000017500000000375215116327650016337 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qinv} =} inv (@var{q}) ## Return inverse of a quaternion. ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.4 function a = inv (a) if (nargin != 1) print_usage (); endif if (isscalar (a.w)) norm2 = norm2 (a); a.w = a.w / norm2; a.x = -a.x / norm2; a.y = -a.y / norm2; a.z = -a.z / norm2; elseif (issquare (a.w)) ## blockwise inversion, use recursion ## the formula is well-known from linear algebra n = rows (a.w); # a is square m1 = fix (n/2); m2 = m1 + 1; A = subsref (a, substruct ("()", {1:m1, 1:m1})); B = subsref (a, substruct ("()", {1:m1, m2:n})); C = subsref (a, substruct ("()", {m2:n, 1:m1})); D = subsref (a, substruct ("()", {m2:n, m2:n})); iA = inv (A); iAB = iA * B; CiA = C * iA; X = inv (D - C * iAB); Y = X * CiA; a = [iA + iAB*Y, -iAB*X; -Y, X]; else error ("quaternion: inv: require square matrices of quaternions"); endif endfunction %!test %! q = quaternion (1, 0, 0, 0); %! result = inv (q); %! assert (result == q); %!test %! q = quaternion (2, 0, 0, 0); %! result = inv (q) * q; %! expected = quaternion (1, 0, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/squeeze.m0000644000000000000000000000006215116327650020073 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/squeeze.m0000644000175000017500000000405115116327650017215 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qret} =} squeeze (@var{q}) ## Remove singleton dimensions from quaternion @var{q} and return the result. ## Note that for compatibility with @acronym{MATLAB}, all objects have a minimum ## of two dimensions and row vectors are left unchanged. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function ret = squeeze (q) if (nargin != 1) print_usage (); endif w = builtin ("squeeze", q.w); x = builtin ("squeeze", q.x); y = builtin ("squeeze", q.y); z = builtin ("squeeze", q.z); ret = quaternion (w, x, y, z); endfunction %!test %! ## Test squeeze on 3D array with singleton dimension %! w = ones (1, 3, 4); %! x = 2 * ones (1, 3, 4); %! y = 3 * ones (1, 3, 4); %! z = 4 * ones (1, 3, 4); %! q = quaternion (w, x, y, z); %! result = squeeze (q); %! expected = quaternion (squeeze(w), squeeze(x), squeeze(y), squeeze(z)); %! assert (size(result), size(expected)); %! assert (result == expected); %!test %! ## Test squeeze on 4D array %! w = ones (2, 1, 3, 1); %! x = 2 * ones (2, 1, 3, 1); %! y = 3 * ones (2, 1, 3, 1); %! z = 4 * ones (2, 1, 3, 1); %! q = quaternion (w, x, y, z); %! result = squeeze (q); %! expected = quaternion (squeeze(w), squeeze(x), squeeze(y), squeeze(z)); %! assert (size(result), [2, 3]); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/end.m0000644000000000000000000000006215116327650017160 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/end.m0000644000175000017500000000274715116327650016314 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## End indexing for quaternions. ## Used by Octave for "q(1:end)". ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function ret = end (q, k, n) ## error: end: no method for class double ## octave 3.6.4 raises an error for the following 4 variants: ## ret = end (q.w, k, n); ## ret = feval ("end", q.w, k, n); ## ret = feval (@end, q.w, k, n); ## ret = builtin ("end", q.w, k, n); if (n == 1) # q(idx), note that ndims (q.w) >= 2 ret = numel (q.w); else # q(idx1, idx2), q(idx1, idx2, idx3), ... ret = size (q.w, k); endif endfunction %!test %! w = eye (3); %! q = quaternion (w); %! assert (q(end).w, w(end)); %! assert (q(end,1).w, w(end,1)); %! assert (q(1,end).w, w(1,end)); quaternion-2.4.2/inst/@quaternion/PaxHeaders/transpose.m0000644000000000000000000000006215116327650020430 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/transpose.m0000644000175000017500000000332015116327650017550 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Transpose of a quaternion. Used by Octave for "q.'". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function a = transpose (a) if (nargin != 1) print_usage (); endif a.w = builtin ("transpose", a.w); a.x = builtin ("transpose", a.x); a.y = builtin ("transpose", a.y); a.z = builtin ("transpose", a.z); endfunction %!test %! ## Test transpose of row vector %! q = quaternion ([1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]); %! result = transpose (q); %! expected_w = [1; 2; 3]; %! expected_x = [4; 5; 6]; %! expected_y = [7; 8; 9]; %! expected_z = [10; 11; 12]; %! expected = quaternion (expected_w, expected_x, expected_y, expected_z); %! assert (result == expected); %!test %! ## Test transpose of matrix %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! result = q.'; %! expected = quaternion (w.', x.', y.', z.'); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/minus.m0000644000000000000000000000006215116327650017545 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/minus.m0000644000175000017500000000243615116327650016674 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Subtraction of two quaternions. Used by Octave for "q1 - q2". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = minus (a, b) if (nargin != 2) error ("quaternion: minus: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); w = a.w - b.w; x = a.x - b.x; y = a.y - b.y; z = a.z - b.z; q = quaternion (w, x, y, z); endfunction %!test %! a = quaternion (5, 6, 7, 8); %! b = quaternion (1, 2, 3, 4); %! result = a - b; %! expected = quaternion (4, 4, 4, 4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/le.m0000644000000000000000000000006215116327650017012 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/le.m0000644000175000017500000000227215116327650016137 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Less-than-or-equal-to operator for two quaternions. ## Used by Octave for "q1 <= q2". ## The ordering is lexicographic. ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = le (a, b) if (nargin != 2) error ("quaternion: le: this is a binary operator"); endif bool = ! gt (a, b); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a <= b, false); %! assert (b <= a, true); quaternion-2.4.2/inst/@quaternion/PaxHeaders/plus.m0000644000000000000000000000006215116327650017375 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/plus.m0000644000175000017500000000304615116327650016522 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Addition of two quaternions. Used by Octave for "q1 + q2". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = plus (a, b) if (nargin != 2) error ("quaternion: plus: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); w = a.w + b.w; x = a.x + b.x; y = a.y + b.y; z = a.z + b.z; q = quaternion (w, x, y, z); endfunction %!shared A, B, C, D %! Aw = [2, 6; 10, 14]; %! Ax = [3, 7; 11, 15]; %! Ay = [4, 8; 12, 16]; %! Az = [5, 9; 13, 17]; %! A = quaternion (Aw, Ax, Ay, Az); %! %! Bw = [1, 2; 3, 4]; %! Bx = [5, 6; 7, 8]; %! By = [9, 10; 11, 12]; %! Bz = [13, 14; 15, 16]; %! B = quaternion (Bw, Bx, By, Bz); %! %! C = A + B; %! %! Dw = Aw + Bw; %! Dx = Ax + Bx; %! Dy = Ay + By; %! Dz = Az + Bz; %! D = quaternion (Dw, Dx, Dy, Dz); %!assert (C == D); quaternion-2.4.2/inst/@quaternion/PaxHeaders/private0000644000000000000000000000013215116327664017634 xustar0030 mtime=1765388212.202950134 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/private/0000755000175000017500000000000015116327664017035 5ustar00nirnirquaternion-2.4.2/inst/@quaternion/private/PaxHeaders/normv.m0000644000000000000000000000006215116327650021225 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/private/normv.m0000644000175000017500000000176015116327650020353 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{normv} =} normv (@var{q}) ## Return norm of the vector part. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function ret = normv (a) ret = sqrt (a.x.^2 + a.y.^2 + a.z.^2); endfunction quaternion-2.4.2/inst/@quaternion/private/PaxHeaders/keys_vals.m0000644000000000000000000000006215116327650022064 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/private/keys_vals.m0000644000175000017500000000334115116327650021207 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{keys}, @var{vals}] =} keys_vals (@var{q}) ## Return the list of keys as well as the assignable values for a quaternion q. ## @end deftypefn ## Author: Lukas Reichlin ## Created: April 2014 ## Version: 0.1 function [keys, vals] = keys_vals (q) str = num2str (size (q), "%d "); str = regexprep (str, " ", "x"); ## cell vector of keys keys = {"w"; "x"; "y"; "z"; "s"; "v"}; ## cell vector of values vals = {sprintf("real-valued array of type '%s', dimensions (%s)", class (q.w), str); sprintf("real-valued array of type '%s', dimensions (%s)", class (q.x), str); sprintf("real-valued array of type '%s', dimensions (%s)", class (q.y), str); sprintf("real-valued array of type '%s', dimensions (%s)", class (q.z), str); sprintf("scalar part of type 'quaternion', dimensions (%s)", str); sprintf("vector part of type 'quaternion', dimensions (%s)", str)}; endfunction quaternion-2.4.2/inst/@quaternion/private/PaxHeaders/norm2.m0000644000000000000000000000006215116327650021121 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/private/norm2.m0000644000175000017500000000176715116327650020256 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{norm2} =} norm2 (@var{q}) ## Return squared norm of a quaternion. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function ret = norm2 (a) ret = a.w.^2 + a.x.^2 + a.y.^2 + a.z.^2; endfunction quaternion-2.4.2/inst/@quaternion/PaxHeaders/isnan.m0000644000000000000000000000006215116327650017522 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/isnan.m0000644000175000017500000000243015116327650016643 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isnan (@var{q}) ## Return a logical array which is true where the elements of ## @var{q} are NaN values and false where they are not. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = isnan (q) if (nargin != 1) print_usage (); endif bool = isnan (q.w) | isnan (q.x) | isnan (q.y) | isnan (q.z); endfunction %!test %! q = quaternion (NaN, 2, 3, 4); %! assert (isnan (q), true); %!test %! q = quaternion (1, 2, 3, 4); %! assert (isnan (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/vertcat.m0000644000000000000000000000006215116327650020062 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/vertcat.m0000644000175000017500000000351415116327650017207 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Vertical concatenation of quaternions. Used by Octave for "[q1; q2]". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function q = vertcat (varargin) ## Convert all inputs to quaternions, handling Octave 11 compatibility tmp_cell = cellfun (@quaternion, varargin, "UniformOutput", false); ## Extract components from each quaternion in the cell array w_cell = cellfun (@(q) q.w, tmp_cell, "UniformOutput", false); x_cell = cellfun (@(q) q.x, tmp_cell, "UniformOutput", false); y_cell = cellfun (@(q) q.y, tmp_cell, "UniformOutput", false); z_cell = cellfun (@(q) q.z, tmp_cell, "UniformOutput", false); ## Concatenate using built-in vertcat for numeric arrays (explicitly call builtin to avoid recursion) w = builtin ("vertcat", w_cell{:}); x = builtin ("vertcat", x_cell{:}); y = builtin ("vertcat", y_cell{:}); z = builtin ("vertcat", z_cell{:}); q = quaternion (w, x, y, z); endfunction %!test %! a = quaternion (1, 2, 3, 4); %! b = quaternion (5, 6, 7, 8); %! result = [a; b]; %! assert (size (result), [2, 1]); %! assert (result(1) == a); %! assert (result(2) == b); quaternion-2.4.2/inst/@quaternion/PaxHeaders/arg.m0000644000000000000000000000006215116327650017163 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/arg.m0000644000175000017500000000244315116327650016310 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{theta} =} arg (@var{q}) ## Compute the argument or phase of quaternion @var{q} in radians. ## @var{theta} is defined as @code{atan2 (sqrt (q.x.^2 + q.y.^2 + q.z.^2), q.w)}. ## The argument @var{theta} lies in the range (0, pi). ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function theta = arg (q) if (nargin != 1) print_usage (); endif theta = arg (complex (q.w, normv (q))); endfunction %!test %! q = quaternion (1, 0, 0, 0); %! result = arg (q); %! assert (result, 0, eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/uminus.m0000644000000000000000000000006215116327650017732 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/uminus.m0000644000175000017500000000223515116327650017056 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Unary minus of a quaternion. Used by Octave for "-q". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function a = uminus (a) if (nargin != 1) error ("quaternion: uminus: this is an unary operator"); endif a.w = -a.w; a.x = -a.x; a.y = -a.y; a.z = -a.z; endfunction %!test %! q = quaternion (1, 2, 3, 4); %! result = -q; %! expected = quaternion (-1, -2, -3, -4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/rdivide.m0000644000000000000000000000006215116327650020040 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/rdivide.m0000644000175000017500000000233715116327650017167 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Element-wise right division for quaternions. ## Used by Octave for ## ## @example ## @var{q1} ./ @var{q2} ## @end example ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = rdivide (a, b) if (nargin != 2) error ("quaternion: rdivide: this is a binary operator"); endif q = a .* b.^-1; endfunction %!test %! a = quaternion (4, 0, 0, 0); %! b = quaternion (2, 0, 0, 0); %! result = a ./ b; %! expected = quaternion (2, 0, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/tril.m0000644000000000000000000000006215116327650017364 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/tril.m0000644000175000017500000000500415116327650016505 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} tril (@var{q}) ## @deftypefnx {Function File} {@var{q} =} tril (@var{q}, @var{k}) ## @deftypefnx {Function File} {@var{q} =} tril (@var{q}, @var{k}, @var{'pack'}) ## Return a new quaternion matrix formed by extracting the lower ## triangular part of the quaternion @var{q}, and setting all ## other elements to zero. The second argument @var{k} is optional, ## and specifies how many diagonals above or below the main diagonal ## should also be included. Default value for @var{k} is zero. ## If the option "pack" is given as third argument, the extracted ## elements are not inserted into a matrix, but rather stacked ## column-wise one above other. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = tril (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("tril", q.w, varargin{:}); q.x = builtin ("tril", q.x, varargin{:}); q.y = builtin ("tril", q.y, varargin{:}); q.z = builtin ("tril", q.z, varargin{:}); endfunction %!test %! ## Test tril with no offset (main diagonal) %! w = [1, 2, 3; 4, 5, 6; 7, 8, 9]; %! x = [10, 11, 12; 13, 14, 15; 16, 17, 18]; %! y = [19, 20, 21; 22, 23, 24; 25, 26, 27]; %! z = [28, 29, 30; 31, 32, 33; 34, 35, 36]; %! q = quaternion (w, x, y, z); %! result = tril (q); %! expected = quaternion (tril(w), tril(x), tril(y), tril(z)); %! assert (result == expected); %!test %! ## Test tril with positive offset %! w = [1, 2, 3; 4, 5, 6; 7, 8, 9]; %! x = [10, 11, 12; 13, 14, 15; 16, 17, 18]; %! y = [19, 20, 21; 22, 23, 24; 25, 26, 27]; %! z = [28, 29, 30; 31, 32, 33; 34, 35, 36]; %! q = quaternion (w, x, y, z); %! result = tril (q, 1); %! expected = quaternion (tril(w, 1), tril(x, 1), tril(y, 1), tril(z, 1)); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/floor.m0000644000000000000000000000006215116327650017533 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/floor.m0000644000175000017500000000242615116327650016661 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} floor (@var{q}) ## Round quaternion @var{q} towards negative infinity. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = floor (q) if (nargin != 1) print_usage (); endif q.w = builtin ("floor", q.w); q.x = builtin ("floor", q.x); q.y = builtin ("floor", q.y); q.z = builtin ("floor", q.z); endfunction %!test %! q = quaternion (1.8, 2.3, 3.7, 4.1); %! result = floor (q); %! expected = quaternion (1, 2, 3, 4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/size_equal.m0000644000000000000000000000006215116327650020553 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/size_equal.m0000644000175000017500000000316615116327650017703 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} size_equal (@var{a}, @var{b}, @dots{}) ## Return true if quaternions (and matrices) @var{a}, @var{b}, @dots{} ## are of equal size and false otherwise. ## @end deftypefn ## Author: Lukas Reichlin ## Created: October 2012 ## Version: 0.1 function bool = size_equal (varargin) s = cellfun (@size, varargin, "uniformoutput", false); bool = (nargin == 1 || isequal (s{:})); # isequal errors out with only 1 argument, nargin==0 handled by built-in size_equal endfunction %!test %! a = quaternion (ones (2, 3), ones (2, 3), ones (2, 3), ones (2, 3)); %! b = quaternion (zeros (2, 3), zeros (2, 3), zeros (2, 3), zeros (2, 3)); %! assert (size_equal (a, b), true); %!test %! a = quaternion (ones (2, 3), ones (2, 3), ones (2, 3), ones (2, 3)); %! b = quaternion (zeros (3, 2), zeros (3, 2), zeros (3, 2), zeros (3, 2)); %! assert (size_equal (a, b), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/log.m0000644000000000000000000000006215116327650017173 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/log.m0000644000175000017500000000335215116327650016320 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qlog} =} log (@var{q}) ## Logarithmus naturalis of a quaternion. ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function q = log (q) if (nargin != 1) print_usage (); endif normq = abs (q); normv = normv (q); acossq = acos (q.w ./ normq); q.w = log (normq); q.x = (q.x ./ normv) .* acossq; q.y = (q.y ./ normv) .* acossq; q.z = (q.z ./ normv) .* acossq; ## FIXME: q = quaternion (2, 3, 4, 5) ## p = log (exp (q)) ## p.v is wrong, probably somehow related to acos ## NOTE: p = exp (log (q)) is calculated correctly ## NOTE: qtfm 1.9 returns the same "wrong" result endfunction %!shared A, B %! Aw = [2, 6, 10; 14, 18, 22]; %! Ax = [3, 7, 11; 15, 19, 23]; %! Ay = [4, 8, 12; 16, 20, 24]; %! Az = [5, 9, 13; 17, 21, 25]; %! A = quaternion (Aw, Ax, Ay, Az); %! %! B = exp (log (A)); %! %!assert (A.w, B.w, 1e-4); %!assert (A.x, B.x, 1e-4); %!assert (A.y, B.y, 1e-4); %!assert (A.z, B.z, 1e-4); quaternion-2.4.2/inst/@quaternion/PaxHeaders/isfinite.m0000644000000000000000000000006215116327650020224 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/isfinite.m0000644000175000017500000000246315116327650017353 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isfinite (@var{q}) ## Return a logical array which is true where the elements of ## @var{q} are finite values and false where they are not. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = isfinite (q) if (nargin != 1) print_usage (); endif bool = isfinite (q.w) & isfinite (q.x) & isfinite (q.y) & isfinite (q.z); endfunction %!test %! q = quaternion (1, 2, 3, 4); %! assert (isfinite (q), true); %!test %! q = quaternion (Inf, 2, 3, 4); %! assert (isfinite (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/mean.m0000644000000000000000000000006215116327650017332 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/mean.m0000644000175000017500000000504315116327650016456 0ustar00nirnir## Copyright (C) 2013 Willem Atsma ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} mean (@var{q}) ## @deftypefnx {Function File} {@var{q} =} mean (@var{q}, @var{dim}) ## @deftypefnx {Function File} {@var{q} =} mean (@var{q}, @var{opt}) ## @deftypefnx {Function File} {@var{q} =} mean (@var{q}, @var{dim}, @var{opt}) ## Compute the mean of the elements of the quaternion array @var{q}. ## ## @example ## mean (q) = mean (q.w) + mean (q.x)*i + mean (q.y)*j + mean (q.z)*k ## @end example ## ## See @code{help mean} for more information and a description of the ## parameters @var{dim} and @var{opt}. ## @end deftypefn ## Author: Willem Atsma ## Created: June 2013 ## Version: 0.1 function q = mean (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif w = builtin ("mean", q.w, varargin{:}); x = builtin ("mean", q.x, varargin{:}); y = builtin ("mean", q.y, varargin{:}); z = builtin ("mean", q.z, varargin{:}); q = quaternion (w, x, y, z); endfunction %!test %! ## Test mean along default dimension (columns) %! w = [1, 2; 3, 4]; %! x = [5, 6; 7, 8]; %! y = [9, 10; 11, 12]; %! z = [13, 14; 15, 16]; %! q = quaternion (w, x, y, z); %! result = mean (q); %! expected = quaternion (mean(w), mean(x), mean(y), mean(z)); %! assert (result == expected); %!test %! ## Test mean along dimension 2 (rows) %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! result = mean (q, 2); %! expected = quaternion (mean(w, 2), mean(x, 2), mean(y, 2), mean(z, 2)); %! assert (result == expected); %!test %! ## Test mean of vector %! q = quaternion ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]); %! result = mean (q); %! expected = quaternion (mean([1,2,3,4]), mean([5,6,7,8]), mean([9,10,11,12]), mean([13,14,15,16])); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/length.m0000644000000000000000000000006215116327650017673 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/length.m0000644000175000017500000000250615116327650017020 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{l} =} length (@var{q}) ## Return the "length" @var{l} of the quaternion array @var{q}. ## For quaternion matrices, the length is the number of rows or columns, ## whichever is greater (this odd definition is used for compatibility ## with @acronym{MATLAB}). ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function l = length (q) if (nargin != 1) print_usage (); endif l = length (q.w); endfunction %!test %! q = quaternion ([1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]); %! assert (length (q), 4); quaternion-2.4.2/inst/@quaternion/PaxHeaders/power.m0000644000000000000000000000006215116327650017546 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/power.m0000644000175000017500000000434615116327650016677 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## Copyright (c) 2011 Juan Pablo Carbajal ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Power operator of quaternions. Used by Octave for "q.^x". ## Exponent x can be scalar or of appropriate size. ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.4 function a = power (a, b) if (nargin != 2) error ("quaternion: power: this is a binary operator"); endif if (isa (b, "quaternion")) # exponent is a quaternion a = exp (log (a) .* b); # a could be real, but log doesn't care elseif (! isreal (b)) error ("quaternion:invalidArgument", "quaternion: power: invalid exponent"); elseif (b == -1) # special case for ldivide and rdivide norm2 = norm2 (a); # a is quaternion because b is not, a.w = a.w ./ norm2; # otherwise octave wouldn't call a.x = -a.x ./ norm2; # quaternion's power operator. a.y = -a.y ./ norm2; a.z = -a.z ./ norm2; else # exponent is real na = abs (a); nv = normv (a); th = acos (a.w ./ na); nab = na.^b; snt = sin (b.*th); a.w = nab .* cos (b.*th); a.x = (a.x ./ nv) .* nab .* snt; a.y = (a.y ./ nv) .* nab .* snt; a.z = (a.z ./ nv) .* nab .* snt; endif endfunction %!test %! q = quaternion (1, 1, 0, 0); %! result = q .^ 2; %! expected = quaternion (0, 2, 0, 0); %! assert (result.w, expected.w, 2*eps); %! assert (result.x, expected.x, 2*eps); %! assert (result.y, expected.y, 2*eps); %! assert (result.z, expected.z, 2*eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/subsref.m0000644000000000000000000000006215116327650020063 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/subsref.m0000644000175000017500000001123415116327650017206 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Subscripted reference for quaternions. Used by Octave for "q.w". ## ## @strong{Subscripts} ## @table @var ## @item q.w ## Return scalar part @var{w} of quaternion @var{q} as a built-in type. ## ## @item q.x, q.y, q.z ## Return component @var{x}, @var{y} or @var{z} of the vector part of ## quaternion @var{q} as a built-in type. ## ## @item q.s ## Return scalar part of quaternion @var{q}. The vector part of @var{q} ## is set to zero. ## ## @item q.v ## Return vector part of quaternion @var{q}. The scalar part of @var{q} ## is set to zero. ## ## @item q(@dots{}) ## Extract certain elements of quaternion array @var{q}, e.g. @code{q(3, 2:end)}. ## @end table ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.6 function ret = subsref (q, s) if (numel (s) == 0) ret = q; return; endif switch (s(1).type) case "." # q.w switch (tolower (s(1).subs)) case {"w", "e"} # scalar part, returned as built-in type ret = builtin ("subsref", q.w, s(2:end)); case {"x", "i"} ret = builtin ("subsref", q.x, s(2:end)); case {"y", "j"} ret = builtin ("subsref", q.y, s(2:end)); case {"z", "k"} ret = builtin ("subsref", q.z, s(2:end)); case "s" # scalar part, vector part set to zero sz = size (q.w); q.x = q.y = q.z = zeros (sz, class (q.w)); ret = subsref (q, s(2:end)); case "v" # vector part, scalar part set to zero sz = size (q.w); q.w = zeros (sz, class (q.w)); ret = subsref (q, s(2:end)); otherwise error ("quaternion: invalid subscript name '%s'", s(1).subs); endswitch case "()" # q(...) w = builtin ("subsref", q.w, s(1)); x = builtin ("subsref", q.x, s(1)); y = builtin ("subsref", q.y, s(1)); z = builtin ("subsref", q.z, s(1)); tmp = quaternion (w, x, y, z); ret = subsref (tmp, s(2:end)); otherwise error ("quaternion: invalid subscript type '%s'", s(1).type); endswitch endfunction %!test %! ## Test indexed reference with scalar %! q = quaternion ([1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]); %! q2 = q(2); %! assert (q2.w, 2); %! assert (q2.x, 5); %! assert (q2.y, 8); %! assert (q2.z, 11); %!test %! ## Test indexed reference with range %! q = quaternion ([1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]); %! q2 = q(2:4); %! assert (q2.w, [2, 3, 4]); %! assert (q2.x, [7, 8, 9]); %! assert (q2.y, [12, 13, 14]); %! assert (q2.z, [17, 18, 19]); %!test %! ## Test component extraction - q.w, q.x, q.y, q.z %! q = quaternion (1, 2, 3, 4); %! assert (q.w, 1); %! assert (q.x, 2); %! assert (q.y, 3); %! assert (q.z, 4); %!test %! ## Test scalar part extraction - q.s %! q = quaternion (1, 2, 3, 4); %! qs = q.s; %! assert (qs.w, 1); %! assert (qs.x, 0); %! assert (qs.y, 0); %! assert (qs.z, 0); %!test %! ## Test vector part extraction - q.v %! q = quaternion (1, 2, 3, 4); %! qv = q.v; %! assert (qv.w, 0); %! assert (qv.x, 2); %! assert (qv.y, 3); %! assert (qv.z, 4); %!test %! ## Test matrix indexed reference %! w = reshape(1:9, 3, 3); %! x = reshape(10:18, 3, 3); %! y = reshape(19:27, 3, 3); %! z = reshape(28:36, 3, 3); %! q = quaternion (w, x, y, z); %! q2 = q(2, 2); %! assert (q2.w, 5); %! assert (q2.x, 14); %! assert (q2.y, 23); %! assert (q2.z, 32); %!test %! ## Test matrix range reference %! w = reshape(1:9, 3, 3); %! x = reshape(10:18, 3, 3); %! y = reshape(19:27, 3, 3); %! z = reshape(28:36, 3, 3); %! q = quaternion (w, x, y, z); %! q2 = q(1:2, 2:3); %! assert (q2.w, [4, 7; 5, 8]); %! assert (q2.x, [13, 16; 14, 17]); %!test %! ## Test alternative component names (e, i, j, k) %! q = quaternion (1, 2, 3, 4); %! assert (q.e, 1); # e for scalar %! assert (q.i, 2); # i for x %! assert (q.j, 3); # j for y %! assert (q.k, 4); # k for z quaternion-2.4.2/inst/@quaternion/PaxHeaders/isempty.m0000644000000000000000000000006215116327650020104 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/isempty.m0000644000175000017500000000227315116327650017232 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isempty (@var{q}) ## Return true if quaternion @var{q} is empty and false otherwise. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = isempty (q) if (nargin != 1) print_usage (); endif bool = isempty (q.w); endfunction %!test %! q = quaternion ([]); %! assert (isempty (q), true); %!test %! q = quaternion (1, 2, 3, 4); %! assert (isempty (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/uplus.m0000644000000000000000000000006215116327650017562 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/uplus.m0000644000175000017500000000211515116327650016703 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Unary plus of a quaternion. Used by Octave for "+q". ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.2 function a = uplus (a) if (nargin != 1) error ("quaternion: uplus: this is an unary operator"); endif ## nothing to do here endfunction %!test %! q = quaternion (1, 2, 3, 4); %! result = +q; %! assert (result == q); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ldivide.m0000644000000000000000000000006215116327650020032 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ldivide.m0000644000175000017500000000235515116327650017161 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Element-wise left division for quaternions. ## Used by Octave for ## ## @example ## @var{q1} .@backslashchar{} @var{q2} ## @end example ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = ldivide (a, b) if (nargin != 2) error ("quaternion: ldivide: this is a binary operator"); endif q = a.^-1 .* b; endfunction %!test %! a = quaternion (2, 0, 0, 0); %! b = quaternion (4, 0, 0, 0); %! result = a .\ b; %! expected = quaternion (2, 0, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/isinf.m0000644000000000000000000000006215116327650017522 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/isinf.m0000644000175000017500000000242615116327650016650 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isinf (@var{q}) ## Return a logical array which is true where the elements of ## @var{q} are infinite and false where they are not. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = isinf (q) if (nargin != 1) print_usage (); endif bool = isinf (q.w) | isinf (q.x) | isinf (q.y) | isinf (q.z); endfunction %!test %! q = quaternion (Inf, 2, 3, 4); %! assert (isinf (q), true); %!test %! q = quaternion (1, 2, 3, 4); %! assert (isinf (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/get.m0000644000000000000000000000006215116327650017171 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/get.m0000644000175000017500000000454415116327650016322 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} get (@var{q}) ## @deftypefnx {Function File} {@var{value} =} get (@var{q}, @var{"key"}) ## @deftypefnx {Function File} {[@var{val1}, @var{val2}, @dots{}] =} get (@var{q}, @var{"key1"}, @var{"key2"}, @dots{}) ## Access key values of quaternion objects. ## ## @strong{Keys} ## @table @var ## @item w ## Return scalar part @var{w} of quaternion @var{q} as a built-in type. ## ## @item x, y, z ## Return component @var{x}, @var{y} or @var{z} of the vector part of ## quaternion @var{q} as a built-in type. ## ## @item s ## Return scalar part of quaternion @var{q}. The vector part of @var{q} ## is set to zero. ## ## @item v ## Return vector part of quaternion @var{q}. The scalar part of @var{q} ## is set to zero. ## @end table ## @end deftypefn ## Author: Lukas Reichlin ## Created: April 2014 ## Version: 0.1 function varargout = get (q, varargin) if (! isa (q, "quaternion")) error ("quaternion: get: first argument must be a quaternion"); endif if (! all (cellfun (@ischar, varargin))) error ("quaternion: get: key names must be strings"); endif if (nargin == 1) [keys, vals] = keys_vals (q); nrows = numel (keys); str = strjust (strvcat (keys), "right"); str = horzcat (repmat (" ", nrows, 1), str, repmat (": ", nrows, 1), strvcat (vals)); disp (str); else for k = 1 : (nargin-1) key = varargin{k}; idx = substruct (".", key); varargout{k} = subsref (q, idx); endfor endif endfunction %!test %! q = quaternion (1, 2, 3, 4); %! assert (get (q, "w"), 1); %! assert (get (q, "x"), 2); %! assert (get (q, "y"), 3); %! assert (get (q, "z"), 4); quaternion-2.4.2/inst/@quaternion/PaxHeaders/numel.m0000644000000000000000000000006215116327650017532 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/numel.m0000644000175000017500000000255515116327650016663 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{n} =} numel (@var{q}) ## @deftypefnx {Function File} {@var{n} =} numel (@var{q}, @var{idx1}, @var{idx2}, @dots{}) ## For internal use only, use @code{prod(size(q))} or @code{numel (q.w)} instead. ## For technical reasons, this method must return the number of elements which are ## returned from cs-list indexing, no matter whether it is called with one or more ## arguments. ## @end deftypefn ## Author: Lukas Reichlin ## Created: February 2015 ## Version: 0.1 function ret = numel (q, varargin) ret = builtin ("numel", q, varargin{:}); endfunction %!test %! assert (numel (quaternion (eye (3))), 1); quaternion-2.4.2/inst/@quaternion/PaxHeaders/display.m0000644000000000000000000000006215116327650020057 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/display.m0000644000175000017500000000313315116327650017201 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Display routine for quaternions. Used by Octave internally. ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function display (q) name = inputname (1); s = size (q); if (length (s) == 2 && all (s == 1)) # scalar quaternion w = num2str (q.w, 4); x = __num2str__ (q.x); y = __num2str__ (q.y); z = __num2str__ (q.z); disp ([name, " = ", w, x, "i" y, "j", z, "k"]); else # non-scalar quaternion disp ([name, ".w ="]); disp (q.w); disp (""); disp ([name, ".x ="]); disp (q.x); disp (""); disp ([name, ".y ="]); disp (q.y); disp (""); disp ([name, ".z ="]); disp (q.z); disp (""); endif endfunction function str = __num2str__ (num) if (num < 0) str = " - "; else str = " + "; endif str = [str, num2str(abs (num), 4)]; endfunction quaternion-2.4.2/inst/@quaternion/PaxHeaders/quaternion.m0000644000000000000000000000006215116327650020577 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/quaternion.m0000644000175000017500000000712715116327650017730 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} quaternion (@var{w}) ## @deftypefnx {Function File} {@var{q} =} quaternion (@var{x}, @var{y}, @var{z}) ## @deftypefnx {Function File} {@var{q} =} quaternion (@var{w}, @var{x}, @var{y}, @var{z}) ## Constructor for quaternions - create or convert to quaternion. ## ## @example ## q = w + x*i + y*j + z*k ## @end example ## ## Arguments @var{w}, @var{x}, @var{y} and @var{z} can be scalars, ## matrices or n-dimensional arrays, but they must be real-valued ## and of equal size. ## If scalar part @var{w} or components @var{x}, @var{y} and @var{z} ## of the vector part are not specified, zero matrices of appropriate ## size are assumed. ## ## @strong{Example} ## @example ## @group ## octave:1> q = quaternion (2) ## q = 2 + 0i + 0j + 0k ## ## octave:2> q = quaternion (3, 4, 5) ## q = 0 + 3i + 4j + 5k ## ## octave:3> q = quaternion (2, 3, 4, 5) ## q = 2 + 3i + 4j + 5k ## @end group ## @end example ## @example ## @group ## octave:4> w = [2, 6, 10; 14, 18, 22]; ## octave:5> x = [3, 7, 11; 15, 19, 23]; ## octave:6> y = [4, 8, 12; 16, 20, 24]; ## octave:7> z = [5, 9, 13; 17, 21, 25]; ## octave:8> q = quaternion (w, x, y, z) ## q.w = ## 2 6 10 ## 14 18 22 ## ## q.x = ## 3 7 11 ## 15 19 23 ## ## q.y = ## 4 8 12 ## 16 20 24 ## ## q.z = ## 5 9 13 ## 17 21 25 ## ## octave:9> ## @end group ## @end example ## ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.3 function q = quaternion (a, b, c, d) switch (nargin) case 1 if (isa (a, "quaternion")) # quaternion (q) q = a; return; elseif (isnumeric (a) && isreal (a)) # quaternion (w) b = c = d = zeros (size (a), class (a)); else print_usage (); endif case 3 # quaternion (x, y, z) d = c; c = b; b = a; a = zeros (size (a), class (a)); case 4 # quaternion (w, x, y, z) ## nothing to do here, just prevent case "otherwise" otherwise print_usage (); endswitch if (! (isnumeric (a) && isnumeric (b) && isnumeric (c) && isnumeric (d) && ... isreal (a) && isreal (b) && isreal (c) && isreal (d))) error ("quaternion: arguments must be real-valued scalars, matrices or n-dimensional arrays"); endif if (! size_equal (a, b, c, d)); error ("quaternion: arguments must have identical sizes"); endif q = class (struct ("w", a, "x", b, "y", c, "z", d), "quaternion"); endfunction %!test %! q = quaternion (1, 2, 3, 4); %! assert (q.w, 1); %! assert (q.x, 2); %! assert (q.y, 3); %! assert (q.z, 4); %!test %! q = quaternion (5); %! assert (q.w, 5); %! assert (q.x, 0); %! assert (q.y, 0); %! assert (q.z, 0); %!test %! q = quaternion (1, 2, 3); %! assert (q.w, 0); %! assert (q.x, 1); %! assert (q.y, 2); %! assert (q.z, 3); quaternion-2.4.2/inst/@quaternion/PaxHeaders/unit.m0000644000000000000000000000006215116327650017371 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/unit.m0000644000175000017500000000234715116327650016521 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qn} =} unit (@var{q}) ## Normalize quaternion to length 1 (unit quaternion). ## ## @example ## q = w + x*i + y*j + z*k ## unit (q) = q ./ sqrt (w.^2 + x.^2 + y.^2 + z.^2) ## @end example ## @end deftypefn ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.1 function q = unit (a) if (nargin != 1) print_usage (); endif q = a ./ abs (a); endfunction %!test %! q = quaternion (2, 3, 4, 5); %! result = unit (q); %! assert (abs (result), 1, eps); quaternion-2.4.2/inst/@quaternion/PaxHeaders/times.m0000644000000000000000000000006215116327650017533 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/times.m0000644000175000017500000000272015116327650016656 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Element-wise multiplication of two quaternions. Used by Octave for "q1 .* q2". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = times (a, b) if (nargin != 2) error ("quaternion: times: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); w = a.w .* b.w - a.x .* b.x - a.y .* b.y - a.z .* b.z; x = a.y .* b.z - a.z .* b.y + a.w .* b.x + a.x .* b.w; y = a.z .* b.x - a.x .* b.z + a.w .* b.y + a.y .* b.w; z = a.x .* b.y - a.y .* b.x + a.w .* b.z + a.z .* b.w; q = quaternion (w, x, y, z); endfunction %!test %! a = quaternion (1, 2, 0, 0); %! b = quaternion (1, 0, 2, 0); %! result = a .* b; %! expected = quaternion (1, 2, 2, 4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/full.m0000644000000000000000000000006215116327650017354 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/full.m0000644000175000017500000000354415116327650016504 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{fq} =} full (@var{sq}) ## Return a full storage quaternion representation @var{fq} ## from sparse or diagonal quaternion @var{sq}. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = full (q) if (nargin != 1) print_usage (); endif q.w = builtin ("full", q.w); q.x = builtin ("full", q.x); q.y = builtin ("full", q.y); q.z = builtin ("full", q.z); endfunction %!test %! ## Test full on sparse quaternion %! w = sparse ([1, 2; 3, 4]); %! x = sparse ([5, 6; 7, 8]); %! y = sparse ([9, 10; 11, 12]); %! z = sparse ([13, 14; 15, 16]); %! q = quaternion (w, x, y, z); %! result = full (q); %! expected = quaternion (full(w), full(x), full(y), full(z)); %! assert (result == expected); %! assert (issparse (q.w)); %! assert (! issparse (result.w)); %!test %! ## Test full on diagonal quaternion %! w = diag ([1, 2, 3]); %! x = diag ([4, 5, 6]); %! y = diag ([7, 8, 9]); %! z = diag ([10, 11, 12]); %! q = quaternion (w, x, y, z); %! result = full (q); %! expected = quaternion (full(w), full(x), full(y), full(z)); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ndims.m0000644000000000000000000000006215116327650017524 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ndims.m0000644000175000017500000000232415116327650016647 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{n} =} ndims (@var{q}) ## Return the number of dimensions of quaternion @var{q}. ## For any array, the result will always be larger than or equal to 2. ## Trailing singleton dimensions are not counted. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function n = ndims (q) if (nargin != 1) print_usage (); endif n = ndims (q.w); endfunction %!test %! assert (ndims (quaternion (ones (4, 1, 2, 1))), 3); quaternion-2.4.2/inst/@quaternion/PaxHeaders/isreal.m0000644000000000000000000000006215116327650017671 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/isreal.m0000644000175000017500000000250115116327650017011 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} isreal (@var{q}) ## Return true if the vector part of quaternion @var{q} is zero ## and false otherwise. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = isreal (q) if (nargin != 1) print_usage (); endif ## bool = all ((abs(q.x) < eps & abs(q.y) < eps & abs(q.z) < eps)(:)); bool = all ((q.x == 0 & q.y == 0 & q.z == 0)(:)); endfunction %!test %! q = quaternion (5, 0, 0, 0); %! assert (isreal (q), true); %!test %! q = quaternion (1, 2, 3, 4); %! assert (isreal (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/sparse.m0000644000000000000000000000006215116327650017707 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/sparse.m0000644000175000017500000000346115116327650017035 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{sq} =} sparse (@var{fq}) ## Return a sparse quaternion representation @var{sq} from ## full quaternion @var{fq}. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = sparse (q) if (nargin != 1) print_usage (); endif q.w = builtin ("sparse", q.w); q.x = builtin ("sparse", q.x); q.y = builtin ("sparse", q.y); q.z = builtin ("sparse", q.z); endfunction %!test %! ## Test sparse on full quaternion %! w = [1, 0, 0; 0, 2, 0; 0, 0, 3]; %! x = [4, 0, 0; 0, 5, 0; 0, 0, 6]; %! y = [7, 0, 0; 0, 8, 0; 0, 0, 9]; %! z = [10, 0, 0; 0, 11, 0; 0, 0, 12]; %! q = quaternion (w, x, y, z); %! result = sparse (q); %! expected = quaternion (sparse(w), sparse(x), sparse(y), sparse(z)); %! assert (result == expected); %! assert (! issparse (q.w)); %! assert (issparse (result.w)); %!test %! ## Test sparse then full round-trip %! w = [1, 2; 3, 4]; %! x = [5, 6; 7, 8]; %! y = [9, 10; 11, 12]; %! z = [13, 14; 15, 16]; %! q = quaternion (w, x, y, z); %! result = full (sparse (q)); %! assert (result == q); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ctranspose.m0000644000000000000000000000006215116327650020573 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ctranspose.m0000644000175000017500000000221615116327650017716 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Conjugate transpose of a quaternion. Used by Octave for "q'". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function a = ctranspose (a) if (nargin != 1) print_usage (); endif a = conj (transpose (a)); endfunction %!test %! q = quaternion ([1, 2], [3, 4], [5, 6], [7, 8]); %! result = q'; %! expected = quaternion ([1; 2], [-3; -4], [-5; -6], [-7; -8]); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/diff.m0000644000000000000000000000006215116327650017322 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/diff.m0000644000175000017500000000371215116327650016447 0ustar00nirnir## Copyright (c) 1998, 2000, 2005, 2007 Auburn University. ## Copyright (c) 2011 Juan Pablo Carbajal ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{qdot} =} diff (@var{q}, @var{omega}) ## Derivative of a quaternion. ## ## Let Q be a quaternion to transform a vector from a fixed frame to ## a rotating frame. If the rotating frame is rotating about the ## [x, y, z] axes at angular rates [wx, wy, wz], then the derivative ## of Q is given by ## ## @example ## Q' = diff(Q, omega) ## @end example ## ## If the passive convention is used (rotate the frame, not the vector), ## then ## ## @example ## Q' = diff(Q,-omega) ## @end example ## @end deftypefn ## Adapted from: qderiv by A. S. Hodel function qd = diff (q, Omega) if (nargin != 2) print_usage (); endif if (! isa (q, "quaternion") || ! isscalar (q.w)) error ("quaternion: first argument '%s' must be a scalar quaternion", inputname(1)); endif Omega = vec (Omega); if (length (Omega) != 3) error ("quaternion: second argument '%s' must be a length 3 vector", inputname(2)); endif qd = 0.5 * quaternion (Omega(1), Omega(2), Omega(3)) * q; endfunction %!shared q %! q = quaternion(3,1,0,0); %!assert(quaternion(0,0,0.5,1.5) == diff(q,[0 0 1])) %!assert(quaternion(0,0,2,1) == diff(q,[0 1 1])) quaternion-2.4.2/inst/@quaternion/PaxHeaders/horzcat.m0000644000000000000000000000006215116327650020064 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/horzcat.m0000644000175000017500000000336415116327650017214 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Horizontal concatenation of quaternions. Used by Octave for "[q1, q2]". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function q = horzcat (varargin) ## Convert all inputs to quaternions tmp_cell = cellfun (@quaternion, varargin, "UniformOutput", false); ## Extract components from each quaternion in the cell array w_cell = cellfun (@(q) q.w, tmp_cell, "UniformOutput", false); x_cell = cellfun (@(q) q.x, tmp_cell, "UniformOutput", false); y_cell = cellfun (@(q) q.y, tmp_cell, "UniformOutput", false); z_cell = cellfun (@(q) q.z, tmp_cell, "UniformOutput", false); ## Explicitly call builtin to avoid recursion w = builtin ("horzcat", w_cell{:}); x = builtin ("horzcat", x_cell{:}); y = builtin ("horzcat", y_cell{:}); z = builtin ("horzcat", z_cell{:}); q = quaternion (w, x, y, z); endfunction %!test %! a = quaternion (1, 2, 3, 4); %! b = quaternion (5, 6, 7, 8); %! result = [a, b]; %! assert (size (result), [1, 2]); %! assert (result(1) == a); %! assert (result(2) == b); quaternion-2.4.2/inst/@quaternion/PaxHeaders/fix.m0000644000000000000000000000006215116327650017200 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/fix.m0000644000175000017500000000237715116327650016333 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} fix (@var{q}) ## Round quaternion @var{q} towards zero. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = fix (q) if (nargin != 1) print_usage (); endif q.w = builtin ("fix", q.w); q.x = builtin ("fix", q.x); q.y = builtin ("fix", q.y); q.z = builtin ("fix", q.z); endfunction %!test %! q = quaternion (1.8, -2.3, 3.7, -4.1); %! result = fix (q); %! expected = quaternion (1, -2, 3, -4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/mpower.m0000644000000000000000000000006215116327650017723 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/mpower.m0000644000175000017500000000431515116327650017050 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Matrix power operator of quaternions. Used by Octave for "q^x". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = mpower (a, b) if (nargin != 2) error ("quaternion: mpower: this is a binary operator"); endif [r, c] = size (a); if (r != c) error ("quaternion: mpower: quaternion matrix must be square"); endif if (r == 1 && c == 1) # a scalar, b? q = a .^ b; # b could be a quaternion elseif (isnumeric (b) && isreal (b) && isscalar (b) && fix (b) == b) e = fix (abs (b)); switch (sign (b)) case -1 # q^-e a = inv (a); q = a; case 0 # q^0 q = eye (r); # alternative: q = quaternion (eye (r)) return; case 1; # q^e q = a; endswitch for k = 2 : e q *= a; # improvement?: q^8 = ((q^2)^2)^2, q^9 = (((q^2)^2)^2)*q endfor else error ("quaternion: mpower: case not implemented yet"); q = expm (logm (a) * b); # don't know whether this formula is correct endif ## TODO: - q1 ^ q2 ## - arrays endfunction %!test %! q = quaternion (1, 1, 0, 0); %! result = q ^ 2; %! expected = quaternion (0, 2, 0, 0); %! assert (result.w, expected.w, 1e-10); %! assert (result.x, expected.x, 1e-10); %! assert (result.y, expected.y, 1e-10); %! assert (result.z, expected.z, 1e-10); quaternion-2.4.2/inst/@quaternion/PaxHeaders/size.m0000644000000000000000000000006215116327650017364 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/size.m0000644000175000017500000000725715116327650016521 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{nvec} =} size (@var{q}) ## @deftypefnx {Function File} {@var{n} =} size (@var{q}, @var{dim}) ## @deftypefnx {Function File} {[@var{nx}, @var{ny}, @dots{}] =} size (@var{q}) ## Return size of quaternion arrays. ## ## @strong{Inputs} ## @table @var ## @item q ## Quaternion object. ## @item dim ## If given a second argument, @command{size} will return the size of the ## corresponding dimension. ## @end table ## ## @strong{Outputs} ## @table @var ## @item nvec ## Row vector. The first element is the number of rows and the second ## element the number of columns. If @var{q} is an n-dimensional array ## of quaternions, the n-th element of @var{nvec} corresponds to the ## size of the n-th dimension of @var{q}. ## @item n ## Scalar value. The size of the dimension @var{dim}. ## @item nx ## Number of rows. ## @item ny ## Number of columns. ## @item @dots{} ## Sizes of the 3rd to n-th dimensions. ## @end table ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function varargout = size (a, b) switch (nargout) case {0, 1} switch (nargin) case 1 # nvec = size (q) varargout{1} = builtin ("size", a.w); case 2 # n = size (q, dim) varargout{1} = builtin ("size", a.w, b); otherwise print_usage (); endswitch otherwise if (nargin == 1) # [nx, ny, ...] = size (q) varargout = num2cell (builtin ("size", a.w)); else print_usage (); endif endswitch endfunction %!test %! ## Scalar quaternion %! q = quaternion (2, 3, 4, 5); %! assert (size (q), [1, 1]); %! assert (size (q, 1), 1); %! assert (size (q, 2), 1); %! [r, c] = size (q); %! assert (r, 1); %! assert (c, 1); %!test %! ## Row vector quaternion %! q = quaternion ([1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]); %! assert (size (q), [1, 3]); %! assert (size (q, 1), 1); %! assert (size (q, 2), 3); %! [r, c] = size (q); %! assert (r, 1); %! assert (c, 3); %!test %! ## Column vector quaternion %! q = quaternion ([1; 2; 3], [4; 5; 6], [7; 8; 9], [10; 11; 12]); %! assert (size (q), [3, 1]); %! assert (size (q, 1), 3); %! assert (size (q, 2), 1); %! [r, c] = size (q); %! assert (r, 3); %! assert (c, 1); %!test %! ## Matrix quaternion %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! assert (size (q), [2, 3]); %! assert (size (q, 1), 2); %! assert (size (q, 2), 3); %! [r, c] = size (q); %! assert (r, 2); %! assert (c, 3); %!test %! ## 3D array quaternion %! w = ones (2, 3, 4); %! x = 2 * ones (2, 3, 4); %! y = 3 * ones (2, 3, 4); %! z = 4 * ones (2, 3, 4); %! q = quaternion (w, x, y, z); %! assert (size (q), [2, 3, 4]); %! assert (size (q, 1), 2); %! assert (size (q, 2), 3); %! assert (size (q, 3), 4); %! [r, c, d] = size (q); %! assert (r, 2); %! assert (c, 3); %! assert (d, 4); quaternion-2.4.2/inst/@quaternion/PaxHeaders/diag.m0000644000000000000000000000006215116327650017316 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/diag.m0000644000175000017500000000365115116327650016445 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} diag (@var{v}) ## @deftypefnx {Function File} {@var{q} =} diag (@var{v}, @var{k}) ## Return a diagonal quaternion matrix with quaternion vector V on diagonal K. ## The second argument is optional. If it is positive, ## the vector is placed on the K-th super-diagonal. ## If it is negative, it is placed on the -K-th sub-diagonal. ## The default value of K is 0, and the vector is placed ## on the main diagonal. ## Given a matrix argument, instead of a vector, @command{diag} ## extracts the @var{K}-th diagonal of the matrix. ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.3 function q = diag (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("diag", q.w, varargin{:}); q.x = builtin ("diag", q.x, varargin{:}); q.y = builtin ("diag", q.y, varargin{:}); q.z = builtin ("diag", q.z, varargin{:}); endfunction %!shared R, S, T, U %! Q = quaternion (2, 3, 4, 5); %! R = diag ([Q, Q, Q]); %! W = diag ([2, 2, 2]); %! X = diag ([3, 3, 3]); %! Y = diag ([4, 4, 4]); %! Z = diag ([5, 5, 5]); %! S = quaternion (W, X, Y, Z); %! T = diag (R); %! U = [Q; Q; Q]; %!assert (R == S); %!assert (T == U); quaternion-2.4.2/inst/@quaternion/PaxHeaders/lt.m0000644000000000000000000000006215116327650017031 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/lt.m0000644000175000017500000000260715116327650016160 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Less-than operator for two quaternions. ## Used by Octave for "q1 < q2". ## The ordering is lexicographic. ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = lt (a, b) if (nargin != 2) error ("quaternion: lt: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); bool = (a.w < b.w) ... | (a.w == b.w & a.x < b.x) ... | (a.w == b.w & a.x == b.x & a.y < b.y) ... | (a.w == b.w & a.x == b.x & a.y == b.y & a.z < b.z); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a < b, false); %! assert (b < a, true); quaternion-2.4.2/inst/@quaternion/PaxHeaders/cast.m0000644000000000000000000000006215116327650017344 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/cast.m0000644000175000017500000000376415116327650016500 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} cast (@var{q}, @var{'type'}) ## Convert the components of quaternion @var{q} to data type @var{type}. ## Valid types are int8, uint8, int16, uint16, int32, uint32, int64, ## uint64, double, single and logical. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function qret = cast (q, typ) if (nargin != 2 || ! ischar (typ)) # q is always a quaternion, no need to test print_usage (); endif if (! any (strcmp (typ, {"int8"; "uint8"; "int16"; "uint16"; "int32"; "uint32"; "int64"; "uint64"; "double"; "single"; "logical"}))) error ("quaternion: cast: type name '%s' is not a built-in type", typ); endif ## NOTE: Without strcmp, cast could be used to apply any function to the ## components of a quaternion. Shall I create such a method with ## a different name? w = feval (typ, q.w); x = feval (typ, q.x); y = feval (typ, q.y); z = feval (typ, q.z); qret = quaternion (w, x, y, z); endfunction %!test %! q = quaternion (1.0, 2.0, 3.0, 4.0); %! result = cast (q, "int32"); %! assert (result.w, int32 (1)); %! assert (result.x, int32 (2)); %! assert (result.y, int32 (3)); %! assert (result.z, int32 (4)); quaternion-2.4.2/inst/@quaternion/PaxHeaders/triu.m0000644000000000000000000000006215116327650017375 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/triu.m0000644000175000017500000000501115116327650016514 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} triu (@var{q}) ## @deftypefnx {Function File} {@var{q} =} triu (@var{q}, @var{k}) ## @deftypefnx {Function File} {@var{q} =} triu (@var{q}, @var{k}, @var{'pack'}) ## Return a new quaternion matrix formed by extracting the upper ## triangular part of the quaternion @var{q}, and setting all ## other elements to zero. The second argument @var{k} is optional, ## and specifies how many diagonals above or below the main diagonal ## should also be included. Default value for @var{k} is zero. ## If the option "pack" is given as third argument, the extracted ## elements are not inserted into a matrix, but rather stacked ## column-wise one above other. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = triu (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("triu", q.w, varargin{:}); q.x = builtin ("triu", q.x, varargin{:}); q.y = builtin ("triu", q.y, varargin{:}); q.z = builtin ("triu", q.z, varargin{:}); endfunction %!test %! ## Test triu with no offset (main diagonal) %! w = [1, 2, 3; 4, 5, 6; 7, 8, 9]; %! x = [10, 11, 12; 13, 14, 15; 16, 17, 18]; %! y = [19, 20, 21; 22, 23, 24; 25, 26, 27]; %! z = [28, 29, 30; 31, 32, 33; 34, 35, 36]; %! q = quaternion (w, x, y, z); %! result = triu (q); %! expected = quaternion (triu(w), triu(x), triu(y), triu(z)); %! assert (result == expected); %!test %! ## Test triu with negative offset %! w = [1, 2, 3; 4, 5, 6; 7, 8, 9]; %! x = [10, 11, 12; 13, 14, 15; 16, 17, 18]; %! y = [19, 20, 21; 22, 23, 24; 25, 26, 27]; %! z = [28, 29, 30; 31, 32, 33; 34, 35, 36]; %! q = quaternion (w, x, y, z); %! result = triu (q, -1); %! expected = quaternion (triu(w, -1), triu(x, -1), triu(y, -1), triu(z, -1)); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/set.m0000644000000000000000000000006215116327650017205 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/set.m0000644000175000017500000000614515116327650016335 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {} set (@var{q}) ## @deftypefnx {Function File} {} set (@var{q}, @var{"key"}, @var{value}, @dots{}) ## @deftypefnx {Function File} {@var{qret} =} set (@var{q}, @var{"key"}, @var{value}, @dots{}) ## Set or modify properties of quaternion objects. ## If no return argument @var{qret} is specified, the modified quaternion object is stored ## in input argument @var{q}. @command{set} can handle multiple keys in one call: ## @code{set (q, 'key1', val1, 'key2', val2, 'key3', val3)}. ## @code{set (q)} prints a list of the object's key names. ## ## @strong{Keys} ## @table @var ## @item w ## Assign real-valued array @var{val} to scalar part @var{w} of quaternion @var{q}. ## ## @item x, y, z ## Assign real-valued array @var{val} to component @var{x}, @var{y} or @var{z} ## of the vector part of quaternion @var{q}. ## ## @item s ## Assign scalar part of quaternion @var{val} to scalar part of quaternion @var{q}. ## The vector part of @var{q} is left untouched. ## ## @item v ## Assign vector part of quaternion @var{val} to vector part of quaternion @var{q}. ## The scalar part of @var{q} is left untouched. ## @end table ## @end deftypefn ## Author: Lukas Reichlin ## Created: April 2014 ## Version: 0.1 function qret = set (q, varargin) if (! isa (q, "quaternion")) error ("quaternion: set: first argument must be a quaternion"); endif if (nargin == 1) # set (q) [keys, vals] = keys_vals (q); nrows = numel (keys); str = strjust (strvcat (keys), "right"); str = horzcat (repmat (" ", nrows, 1), str, repmat (": ", nrows, 1), strvcat (vals)); disp (str); if (nargout != 0) qret = q; endif else # set (q, "key", val, ...) if (rem (nargin-1, 2)) error ("quaternion: set: keys and values must come in pairs"); endif if (! all (cellfun (@ischar, varargin(1:2:end)))) error ("quaternion: set: key names must be strings"); endif for k = 1 : 2: (nargin-1) key = varargin{k}; val = varargin{k+1}; idx = substruct (".", key); q = subsasgn (q, idx, val); endfor if (nargout == 0) # set (q, "key1", val1, ...) assignin ("caller", inputname (1), q); else # q = set (q, "key1", val1, ...) qret = q; endif endif endfunction %!test %! q = quaternion (1, 2, 3, 4); %! q2 = set (q, "w", 10); %! assert (q2.w, 10); %! assert (q2.x, 2); quaternion-2.4.2/inst/@quaternion/PaxHeaders/mrdivide.m0000644000000000000000000000006215116327650020215 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/mrdivide.m0000644000175000017500000000233215116327650017337 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Matrix right division for quaternions. ## Used by Octave for ## ## @example ## @var{q1} / @var{q2} ## @end example ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = mrdivide (a, b) if (nargin != 2) error ("quaternion: mrdivide: this is a binary operator"); endif q = a * inv (b); endfunction %!test %! a = quaternion (4, 0, 0, 0); %! b = quaternion (2, 0, 0, 0); %! result = a / b; %! expected = quaternion (2, 0, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/round.m0000644000000000000000000000006215116327650017541 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/round.m0000644000175000017500000000245315116327650016667 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} round (@var{q}) ## Round the components of quaternion @var{q} towards the nearest integers. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = round (q) if (nargin != 1) print_usage (); endif q.w = builtin ("round", q.w); q.x = builtin ("round", q.x); q.y = builtin ("round", q.y); q.z = builtin ("round", q.z); endfunction %!test %! q = quaternion (1.4, 2.6, 3.5, 4.2); %! result = round (q); %! expected = quaternion (1, 3, 4, 4); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/eq.m0000644000000000000000000000006215116327650017017 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/eq.m0000644000175000017500000000233715116327650016146 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Equal to operator for two quaternions. Used by Octave for "q1 == q2". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.4 function bool = eq (a, b) if (nargin != 2) error ("quaternion: eq: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); bool = (a.w == b.w) & (a.x == b.x) & (a.y == b.y) & (a.z == b.z); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a == a, true); %! assert (a == b, false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ispure.m0000644000000000000000000000006215116327650017721 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ispure.m0000644000175000017500000000232115116327650017041 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{bool} =} ispure (@var{q}) ## Return true if scalar part of quaternion is zero, otherwise return false. ## @end deftypefn ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.1 function bool = ispure (a) if (nargin != 1) print_usage (); endif bool = all ((abs (a.w) < eps)(:)); endfunction %!test %! q = quaternion (0, 1, 2, 3); %! assert (ispure (q), true); %!test %! q = quaternion (1, 2, 3, 4); %! assert (ispure (q), false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/subsasgn.m0000644000000000000000000000006215116327650020237 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/subsasgn.m0000644000175000017500000001360415116327650017365 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Subscripted assignment for quaternions. ## Used by Octave for "q.key = value". ## ## @strong{Subscripts} ## @table @var ## @item q.w ## Assign real-valued array @var{val} to scalar part @var{w} of quaternion @var{q}. ## ## @item q.x, q.y, q.z ## Assign real-valued array @var{val} to component @var{x}, @var{y} or @var{z} ## of the vector part of quaternion @var{q}. ## ## @item q.s ## Assign scalar part of quaternion @var{val} to scalar part of quaternion @var{q}. ## The vector part of @var{q} is left untouched. ## ## @item q.v ## Assign vector part of quaternion @var{val} to vector part of quaternion @var{q}. ## The scalar part of @var{q} is left untouched. ## ## @item q(@dots{}) ## Assign @var{val} to certain elements of quaternion array @var{q}, e.g. @code{q(3, 2:end) = val}. ## @end table ## Author: Lukas Reichlin ## Created: November 2011 ## Version: 0.3 function q = subsasgn (q, idx, val) switch (idx(1).type) case "()" # q(...) = val ## Always use component-wise assignment val = quaternion (val); w = builtin ("subsasgn", q.w, idx, val.w); x = builtin ("subsasgn", q.x, idx, val.x); y = builtin ("subsasgn", q.y, idx, val.y); z = builtin ("subsasgn", q.z, idx, val.z); q = quaternion (w, x, y, z); case "." # q.w = val if (isa (val, "quaternion")) ref_size = size (subsref (q.w, idx(2:end))); val_size = size (val.w); if (! isequal (ref_size, val_size)) error ("quaternion: subsasgn: invalid argument size (%s), require dimensions (%s)", ... regexprep (num2str (val_size, "%d "), " ", "x"), ... regexprep (num2str (ref_size, "%d "), " ", "x")); endif switch (tolower (idx(1).subs)) case "s" q.w = builtin ("subsasgn", q.w, idx(2:end), val.w); case "v" q.x = builtin ("subsasgn", q.x, idx(2:end), val.x); q.y = builtin ("subsasgn", q.y, idx(2:end), val.y); q.z = builtin ("subsasgn", q.z, idx(2:end), val.z); otherwise error ("quaternion: subsasgn: invalid subscript name '%s'", idx(1).subs); endswitch elseif (isnumeric (val) && isreal (val)) ref_size = size (subsref (q.w, idx(2:end))); val_size = size (val); if (! isequal (ref_size, val_size)) error ("quaternion: subsasgn: invalid argument size (%s), require dimensions (%s)", ... regexprep (num2str (val_size, "%d "), " ", "x"), ... regexprep (num2str (ref_size, "%d "), " ", "x")); endif switch (tolower (idx(1).subs)) case {"w", "e"} q.w = builtin ("subsasgn", q.w, idx(2:end), val); case {"x", "i"} q.x = builtin ("subsasgn", q.x, idx(2:end), val); case {"y", "j"} q.y = builtin ("subsasgn", q.y, idx(2:end), val); case {"z", "k"} q.z = builtin ("subsasgn", q.z, idx(2:end), val); otherwise error ("quaternion: subsasgn: invalid subscript name '%s'", idx(1).subs); endswitch else error ("quaternion: subsasgn: invalid argument type, require real-valued array"); endif otherwise error ("quaternion: subsasgn: invalid subscript type '%s'", idx(1).type); endswitch endfunction %!test %! ## Test indexed assignment with scalar %! q = quaternion ([1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]); %! q(2) = quaternion (0, 1, 2, 3); %! assert (q.w, [1, 0, 3]); %! assert (q.x, [4, 1, 6]); %! assert (q.y, [7, 2, 9]); %! assert (q.z, [10, 3, 12]); %!test %! ## Test indexed assignment with range %! q = quaternion (ones(1, 5), 2*ones(1, 5), 3*ones(1, 5), 4*ones(1, 5)); %! q(2:4) = quaternion ([10, 20, 30], [11, 21, 31], [12, 22, 32], [13, 23, 33]); %! assert (q.w, [1, 10, 20, 30, 1]); %! assert (q.x, [2, 11, 21, 31, 2]); %!test %! ## Test component assignment - q.w %! q = quaternion (1, 2, 3, 4); %! q.w = 10; %! assert (q.w, 10); %! assert (q.x, 2); %! assert (q.y, 3); %! assert (q.z, 4); %!test %! ## Test component assignment - q.x, q.y, q.z %! q = quaternion (1, 2, 3, 4); %! q.x = 20; %! q.y = 30; %! q.z = 40; %! assert (q.w, 1); %! assert (q.x, 20); %! assert (q.y, 30); %! assert (q.z, 40); %!test %! ## Test scalar part assignment - q.s %! q = quaternion (1, 2, 3, 4); %! q.s = quaternion (10); %! assert (q.w, 10); %! assert (q.x, 2); %! assert (q.y, 3); %! assert (q.z, 4); %!test %! ## Test vector part assignment - q.v %! q = quaternion (1, 2, 3, 4); %! q.v = quaternion (0, 20, 30, 40); %! assert (q.w, 1); %! assert (q.x, 20); %! assert (q.y, 30); %! assert (q.z, 40); %!test %! ## Test matrix indexed assignment %! w = ones(3, 3); %! x = 2*ones(3, 3); %! y = 3*ones(3, 3); %! z = 4*ones(3, 3); %! q = quaternion (w, x, y, z); %! q(2, 2) = quaternion (10, 20, 30, 40); %! assert (q.w(2, 2), 10); %! assert (q.x(2, 2), 20); %! assert (q.y(2, 2), 30); %! assert (q.z(2, 2), 40); %!test %! ## Test assignment with mixed quaternion and zeros %! q = quaternion (1, 2, 3, 4); %! c = [q; zeros(2, 1)]; %! c(2) = quaternion (5, 6, 7, 8); %! assert (c.w, [1; 5; 0]); %! assert (c.x, [2; 6; 0]); quaternion-2.4.2/inst/@quaternion/PaxHeaders/mtimes.m0000644000000000000000000000006215116327650017710 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/mtimes.m0000644000175000017500000000263115116327650017034 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Matrix multiplication of two quaternions. Used by Octave for "q1 * q2". ## Author: Lukas Reichlin ## Created: May 2010 ## Version: 0.2 function q = mtimes (a, b) if (nargin != 2) error ("quaternion: mtimes: this is a binary operator"); endif a = quaternion (a); b = quaternion (b); w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z; x = a.y*b.z - a.z*b.y + a.w*b.x + a.x*b.w; y = a.z*b.x - a.x*b.z + a.w*b.y + a.y*b.w; z = a.x*b.y - a.y*b.x + a.w*b.z + a.z*b.w; q = quaternion (w, x, y, z); endfunction %!test %! a = quaternion (1, 0, 0, 0); %! b = quaternion (0, 1, 0, 0); %! result = a * b; %! expected = quaternion (0, 1, 0, 0); %! assert (result == expected); quaternion-2.4.2/inst/@quaternion/PaxHeaders/ge.m0000644000000000000000000000006215116327650017005 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/ge.m0000644000175000017500000000227515116327650016135 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## Greater-than-or-equal-to operator for two quaternions. ## Used by Octave for "q1 >= q2". ## The ordering is lexicographic. ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function bool = ge (a, b) if (nargin != 2) error ("quaternion: ge: this is a binary operator"); endif bool = ! lt (a, b); endfunction %!test %! a = quaternion (2, 3, 4, 5); %! b = quaternion (2, -3, 4, 5); %! assert (a >= b, true); %! assert (b >= a, false); quaternion-2.4.2/inst/@quaternion/PaxHeaders/cumsum.m0000644000000000000000000000006215116327650017723 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/inst/@quaternion/cumsum.m0000644000175000017500000000460715116327650017054 0ustar00nirnir## Copyright (C) 2010-2016 Lukas F. Reichlin ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{q} =} cumsum (@var{q}) ## @deftypefnx {Function File} {@var{q} =} cumsum (@var{q}, @var{dim}) ## @deftypefnx {Function File} {@var{q} =} cumsum (@dots{}, @var{'native'}) ## @deftypefnx {Function File} {@var{q} =} cumsum (@dots{}, @var{'double'}) ## @deftypefnx {Function File} {@var{q} =} cumsum (@dots{}, @var{'extra'}) ## Cumulative sum of elements along dimension @var{dim}. If @var{dim} is omitted, ## it defaults to the first non-singleton dimension. ## See @code{help cumsum} for more information. ## @end deftypefn ## Author: Lukas Reichlin ## Created: December 2013 ## Version: 0.1 function q = cumsum (q, varargin) if (! isa (q, "quaternion")) print_usage (); endif q.w = builtin ("cumsum", q.w, varargin{:}); q.x = builtin ("cumsum", q.x, varargin{:}); q.y = builtin ("cumsum", q.y, varargin{:}); q.z = builtin ("cumsum", q.z, varargin{:}); endfunction %!test %! ## Test cumsum along default dimension (columns) %! w = [1, 2; 3, 4]; %! x = [5, 6; 7, 8]; %! y = [9, 10; 11, 12]; %! z = [13, 14; 15, 16]; %! q = quaternion (w, x, y, z); %! result = cumsum (q); %! expected_w = cumsum (w); %! expected_x = cumsum (x); %! expected_y = cumsum (y); %! expected_z = cumsum (z); %! expected = quaternion (expected_w, expected_x, expected_y, expected_z); %! assert (result == expected); %!test %! ## Test cumsum along dimension 2 (rows) %! w = [1, 2, 3; 4, 5, 6]; %! x = [7, 8, 9; 10, 11, 12]; %! y = [13, 14, 15; 16, 17, 18]; %! z = [19, 20, 21; 22, 23, 24]; %! q = quaternion (w, x, y, z); %! result = cumsum (q, 2); %! expected = quaternion (cumsum(w, 2), cumsum(x, 2), cumsum(y, 2), cumsum(z, 2)); %! assert (result == expected); quaternion-2.4.2/PaxHeaders/devel0000644000000000000000000000012615116327664014022 xustar0026 mtime=1765388212.18895 30 atime=1765388212.227950374 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/0000755000175000017500000000000015116327664013220 5ustar00nirnirquaternion-2.4.2/devel/PaxHeaders/max_katsev.m0000644000000000000000000000006215116327650016411 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/max_katsev.m0000644000175000017500000000027615116327650015540 0ustar00nirnir[ax, an] = q2rot (rot2q ([0, 1, 0], 6)) %{ ax = 0 1 0 an = 2.8584 %} r = an + pi % r=6 [ax2, an2] = q2rot (rot2q ([0, 1, 0], an)) [ax, an] = q2rot (rot2q ([0, 1, 0], -pi/2)) quaternion-2.4.2/devel/PaxHeaders/makefile_quaternion.m0000644000000000000000000000006215116327650020271 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/makefile_quaternion.m0000644000175000017500000000130015116327650017405 0ustar00nirnir## ============================================================================== ## Developer Makefile for OCT-files ## ============================================================================== ## USAGE: * fetch quaternion_oo from Octave-Forge by svn ## * add quaternion_oo/inst, quaternion_oo/src and quaternion_oo/devel ## to your Octave path ## * run makefile_quaternion ## ============================================================================== homedir = pwd (); develdir = fileparts (which ("makefile_quaternion")); srcdir = [develdir, "/../src"]; cd (srcdir); system ("make clean"); system ("make -j1 all"); system ("rm *.o"); system ("rm *.d"); cd (homedir);quaternion-2.4.2/devel/PaxHeaders/q2.m0000644000000000000000000000006215116327650014571 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/q2.m0000644000175000017500000000015415116327650013713 0ustar00nirnirfunction q = q2 if (nargin != 0) print_usage (); endif q = quaternion (0, 0, 1, 0); endfunctionquaternion-2.4.2/devel/PaxHeaders/q3.m0000644000000000000000000000006215116327650014572 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/q3.m0000644000175000017500000000015415116327650013714 0ustar00nirnirfunction q = q3 if (nargin != 0) print_usage (); endif q = quaternion (0, 0, 0, 1); endfunctionquaternion-2.4.2/devel/PaxHeaders/q1.m0000644000000000000000000000006215116327650014570 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/q1.m0000644000175000017500000000015415116327650013712 0ustar00nirnirfunction q = q1 if (nargin != 0) print_usage (); endif q = quaternion (0, 1, 0, 0); endfunctionquaternion-2.4.2/devel/PaxHeaders/test_eq.m0000644000000000000000000000006215116327650015713 xustar0020 atime=1765388200 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/test_eq.m0000644000175000017500000000026615116327650015041 0ustar00nirnira = quaternion (2, 3, 4, 5) b = quaternion (2, -3, 4, 5) a < b a > b a <= b a >= b a == b a != b c = complex (2, 3) d = complex (2, -3) c < d c > d c <= d c >= d c == d c != d quaternion-2.4.2/devel/PaxHeaders/pdfdoc0000644000000000000000000000013115116327664015255 xustar0029 mtime=1765388212.18694998 30 atime=1765388212.228950384 30 ctime=1765388212.227950374 quaternion-2.4.2/devel/pdfdoc/0000755000175000017500000000000015116327664014457 5ustar00nirnirquaternion-2.4.2/devel/pdfdoc/PaxHeaders/collect_texinfo_strings.m0000644000000000000000000000006215116327650022440 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/pdfdoc/collect_texinfo_strings.m0000644000175000017500000000246015116327650021564 0ustar00nirnir% pack_name = "generate_html" % pack_name = "control" pack_name = "quaternion" % Load Packages pkg load "generate_html" pkg ("load", pack_name); % Get list of functions list = pkg ("describe", pack_name); %list % Open output file fid = fopen ("functions.texi", "w"); for k = 1:numel (list {1}.provides) group = list {1}.provides{k}; functions = group.functions; % fprintf (fid, '@section %s\n', group.category); fprintf (fid, '@chapter %s\n', group.category); for k=1:numel(functions) [TEXT, FORMAT] = get_help_text (functions{k}); fun = functions{k}; if (fun(1) == "@") % fprintf (fid, '@subsection @%s\n', fun); fprintf (fid, '@section @%s\n', fun); if (strncmp (fun, "@quaternion/", 12)) fprintf (fid, '@findex %s\n', fun(13:end)); else error ("collect_texinfo_strings: unknown class"); endif else % fprintf (fid, '@subsection %s\n', fun); fprintf (fid, '@section %s\n', fun); fprintf (fid, '@findex %s\n', fun); endif fprintf (fid,TEXT); end end fclose(fid); quaternion-2.4.2/devel/pdfdoc/PaxHeaders/quaternion.tex0000644000000000000000000000006215116327650020237 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/pdfdoc/quaternion.tex0000644000175000017500000000660115116327650017364 0ustar00nirnir\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename quaternion.info @settitle @thischapter @c use chapter name instead of title in the header of even pages @c @settitle Octave Quaternion Package @afourpaper @set VERSION 2.4.0 @finalout @c @afourwide @c %**end of header @c The following macro is used for the on-line help system, but we don't @c want lots of `See also: foo, bar, and baz' strings cluttering the @c printed manual (that information should be in the supporting text for @c each group of functions and variables). @macro seealso {args} @iftex @vskip 2pt @end iftex @ifnottex @c Texinfo @sp should work but in practice produces ugly results for HTML. @c A simple blank line produces the correct behavior. @c @sp 1 @end ifnottex @noindent @strong{See also:} \args\. @end macro @c %*** Start of TITLEPAGE @titlepage @title quaternion @value{VERSION} @subtitle Quaternion Package for GNU Octave @author Lukas F. Reichlin @author Juan Pablo Carbajal @page @vskip 0pt plus 1filll Copyright @copyright{} 2010-2015, Lukas F. Reichlin @email{lukas.reichlin@@gmail.com} This manual is generated automatically from the texinfo help strings of the package's functions. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the same conditions as for modified versions. @page @paragraphindent 0 @chapheading Preface The @acronym{GNU} Octave quaternion package from version 2 onwards was developed by Lukas F. Reichlin with important contributions by Juan Pablo Carbajal. This new package is intended as a replacement for quaternion-1.0.0 by A. Scottedward Hodel. It is loosely based on ideas from the Quaternion Toolbox for Matlab by Steve Sangwine and Nicolas Le Bihan with a special focus on code simplicity and vectorization. Its main features are: @itemize @item Matrices and n-dimensional arrays of quaternions. @item Overloaded operators due to the use of classes introduced with Octave 3.2. @item Operator semantics similar to Octave's built-in complex numbers. @item Fully vectorized code for crunching large quaternion arrays in a speedy manner. @end itemize @sp 5 @subheading Using the help function Some functions of the quaternion package are listed with the somewhat cryptic prefix @code{@@quaternion/}. This prefix is only needed to view the help text of the function, e.g. @w{@code{help norm}} shows the built-in function while @w{@code{help @@quaternion/norm}} shows the overloaded function for quaternions. Note that there are quaternion functions like @code{unit} that have no built-in equivalent. When just using the function, the leading @code{@@quaternion/} must @strong{not} be typed. Octave selects the right function automatically. So one can type @w{@code{norm (q)}} and @w{@code{norm (matrix)}} regardless of the class of the argument. @end titlepage @c %*** End of TITLEPAGE @headings double @contents @c @chapter Function Reference @include functions.texi @end @node Function Index @unnumbered Function Index @printindex fn @bye quaternion-2.4.2/devel/pdfdoc/PaxHeaders/info_generate_manual.txt0000644000000000000000000000006215116327650022233 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/pdfdoc/info_generate_manual.txt0000644000175000017500000000073715116327650021364 0ustar00nirnir* Check that "pkg list" lists the packages generate_html and quaternion. * Run collect_texinfo_strings within Octave. This script collects the Texinfo strings from all functions listed in the package's INDEX file and writes them to the file functions.texi. Don't edit the file functions.texi since your changes will be lost by the next run. * Adapt version number in quaternion.tex * Run quaternion.tex pdftex quaternion.tex q Alternatively: Run generate_quaternion_pdf quaternion-2.4.2/devel/PaxHeaders/PROJECTS0000644000000000000000000000006215116327650015245 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/PROJECTS0000644000175000017500000000255015116327650014371 0ustar00nirnir
Quaternion PROJECTS                                       -*- text -*-
===================

grep FIXME and/or TODO for more information


-------
General:
-------
  
  * See if LaTEX code from Scottedward Hodel's quaternion.ps document is available.
    Update it to use the commands from quaternion-2.0.0.

  * Secret Wish: Reimplement package completely in C++ similar to the sparsersb package ;-)
  
  * Support q = 2 + 3qi + 4qj + 5qk instead of q = 2 + 3*qi + 4*qj + 5*qk, similar to
    to complex numbers where it is possible to write c = 2 + 3i.
    I guess that this is not possible with m-files.  If we're lucky, it is possible
    using oct-files.  But I fear that it requires modifications to Octave's code itself.
    
--------
Features:
--------
  
  * Implement mpower.
  
  * Add functionality of qderiv and qtrans from quaternion-1.0.0.
  
  * Overload more functions, e.g. trigonometric functions

------
Always:
------

  * Squash bugs.

  * Write/improve documentation.  If you implement a feature without documentation,
    nobody besides you will ever use it!  Don't waste your time :-)
 
  * Add description of each input and output argument to texinfo strings of
    functions on the INDEX list.

  * Add tests.

  * Test the quaternion package on different platforms.

  * Compare results to those from other toolboxes like QTFM.

quaternion-2.4.2/devel/PaxHeaders/RELEASE_PACKAGE0000644000000000000000000000006215116327650016207 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/RELEASE_PACKAGE0000644000175000017500000000434115116327650015333 0ustar00nirnir===================================================================================== Prepare quaternion-2.x.y Package for Release ===================================================================================== USAGE: * adapt all paths to your machine * update version number in the commands below * adapt version number and release date in DESCRIPTION * update NEWS * adapt version number and year in quaternion.tex * run m-file generate_quaternion_pdf * copy-paste entire block at once to the terminal * follow instructions on TODO: * create a nice shell script for this task ===================================================================================== cd mkdir ~/octave/__TEMP__ cd ~/quaternion hg archive ~/octave/__TEMP__/quaternion cd ~/quaternion/devel/pdfdoc cp quaternion.pdf ~/octave/__TEMP__/quaternion/doc/ cp quaternion.tex ~/octave/__TEMP__/quaternion/doc/ cp functions.texi ~/octave/__TEMP__/quaternion/doc/ rm -R ~/octave/__TEMP__/quaternion/doc/placeholder.txt rm -R ~/octave/__TEMP__/quaternion/devel rm -R ~/octave/__TEMP__/quaternion/.hg_archival.txt rm -R ~/octave/__TEMP__/quaternion/.hgtags rm -R ~/octave/__TEMP__/quaternion/.hgignore cd ~/octave/__TEMP__ grep -i version quaternion/DESCRIPTION tar czf quaternion-2.4.0.tar.gz quaternion/ md5 quaternion-2.4.0.tar.gz md5 quaternion-2.4.0.tar.gz > md5_quaternion_pkg.txt uuencode quaternion-2.4.0.tar.gz < quaternion-2.4.0.tar.gz > quaternion-2.4.0.tar.gz.uue octave -q --eval \ "pkg install -auto quaternion-2.4.0.tar.gz" octave -q --eval \ "pkg load generate_html; generate_package_html ('quaternion', 'quaternion-html', 'octave-forge')" tar czf quaternion-html.tar.gz quaternion-html md5 quaternion-html.tar.gz md5 quaternion-html.tar.gz > md5_quaternion_html.txt uuencode quaternion-html.tar.gz < quaternion-html.tar.gz > quaternion-html.tar.gz.uue cd ===================================================================================== Aftermath ===================================================================================== rm -R ~/octave/__TEMP__ rm -R ~/octave/quaternion-2.4.0 ===================================================================================== quaternion-2.4.2/devel/PaxHeaders/q0.m0000644000000000000000000000006215116327650014567 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/q0.m0000644000175000017500000000015415116327650013711 0ustar00nirnirfunction q = q0 if (nargin != 0) print_usage (); endif q = quaternion (1, 0, 0, 0); endfunctionquaternion-2.4.2/devel/PaxHeaders/RV9_Quaternions.txt0000644000000000000000000000006215116327650017642 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/RV9_Quaternions.txt0000644000175000017500000001243215116327650016766 0ustar00nirnir%% Copyright (c) 2011 Juan Pablo Carbajal %% %% This program is free software: you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by %% the Free Software Foundation, either version 3 of the License, or %% any later version. %% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program. If not, see . === Robotics Toolbox Port to Octave === http://petercorke.com/Robotics_Toolbox.html With the objective of porting the robotics toolbox version 9 to octave forge we list the classes relate to quaternions. The idea is to see when this class has been fully ported, that is: For a method x of the quaternion class, there is a method y in the quaterions_oo package that 1.Method y produces output isomorphic to output of x. 2.Method y receives input isomorphic to input of method y. When the method y exist such that fullfils 1. and 2.; we say there is an equivalent method in the packages quaternions_oo. If additonally the method y in the quaternions_oo package has the same name, then we say that the method x exists in the package. The naming of the methods is not important, since the Robotics Toolbox for octave will have a wrapper class quaternion. This class will emulate the API. object.method(args) using the trick used here [ http://octave.svn.sf.net/viewvc/octave/trunk/octave-forge/main/geometry/inst/io/%40svg/subsref.m?revision=8974&view=markup ] = Marking convention = In the [] field of each method/operator/property add e - There is an isomorphic method (equivalent). x - There is an isomorphic method with the same name (exist). * - There is an exact equal method in the package (same input, output and name). b+ - Benchmarked, slower than current method in quaternions_oo. b- - Benchmarked, faster than current c - There is a method with the same name but not isomorphic (conflict). Example 1: A method qc = qconj(q) exist in quaternions_oo that calculates the inverse of a quaternion. Then we mark inv as follows [e] inv - Example 2: A method [h a] = dosomething(q) from in quaternions_oo to calculate something. The method [h] = somethingtodo(q) from Robotics toolbox to calculate the same. [e] somethingtodo Since the first argument is the same. The same holds ff [a h] = dosomething(q). Since we need just to swap output arguemnts. - Example 3: A method [h] = dosomething(q) from in quaternions_oo to calculate something. The method [h a] = somethingtodo(q) from Robotics toolbox to calculate the same. [ ] somethingtodo Since we need to check how to calculate the output a. - Example 4: A method [h] = dosomething(q) from in quaternions_oo to calculate something. The method [h a] = somethingtodo(q) from Robotics toolbox to calculate the same. And you benchmarked the methods givin a positive result for the quaternions_oo. [b+] somethingtodo The b flag indicates that there is a point of comparision but the methods may not be equivalent. - Example 4: A method [h] = dosomething(q) from in quaternions_oo to calculate something. The method [h] = dosomething(q) from Robotics toolbox to calculate the same. And you benchmarked the methods givin a positive result for the robotics toolbox. [*b-] dosomething just concatenate flags. We hope not to run into the c tag. == Quaternion == DONE Q = Quaternion() is the identitity quaternion 1<0,0,0> representing a null rotation. DONE Q = Quaternion(Q1) is a copy of the quaternion Q1 DONE Q = Quaternion([S V1 V2 V3]) is a quaternion formed by specifying directly its 4 elements DONE Q = Quaternion(S) is a quaternion formed from the scalar S and zero vector part: S<0,0,0> DONE Q = Quaternion(V) is a pure quaternion with the specified vector part: 0 DONE Q = Quaternion(TH, V) is a unit quaternion corresponding to rotation of TH about the vector V. DONE Q = Quaternion(R) is a unit quaternion corresponding to the orthonormal rotation matrix R. DONE Q = Quaternion(T) is a unit quaternion equivalent to the rotational = methods = DONE [c] inv return inverse of quaterion DONE [e] norm: Wraps abs from quaternions_oo DONE [x] dot derivative of quaternion with angular velocity w DONE [c] display DONE [] q2tr DONE [*] unit return unit quaternion [] plot same options as trplot() [] interp interpolation (slerp) between q and q2, 0<=s<=1 [] scale interpolation (slerp) between identity and q, 0<=s<=1 = Operators = DONE [*] q+q2 return elementwise sum of quaternions DONE [*] q-q2 return elementwise difference of quaternions DONE [*] q*q2 return quaternion product DONE [*] q/q2 return q*q2.inv [*] q*v rotate vector by quaternion, v is 3x1 DONE [*] q^n return q to power n (real) = Properties (read only)= DONE [] s real part DONE [] v vector part DONE [] R 3x3 rotation matrix DONE [] T 4x4 homogeneous transform matrix quaternion-2.4.2/devel/PaxHeaders/bug_octave.m0000644000000000000000000000006215116327650016365 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/bug_octave.m0000644000175000017500000000132615116327650015511 0ustar00nirnir% requires the quaternion package q = quaternion (eye (3)) % works as expected a = horzcat (q, eye (3)) % fails because of Octave (version 3.6.4 on Mac OS X) % results a and b should be exactly the same size (q) % somehow Octave thinks q is 1x1 instead of 3x3 on the next line b = [q, eye(3)] % error: horizontal dimensions mismatch (1x1 vs 3x3) % error: called from: % error: /Users/lukas/bug_octave.m at line 8, column 3 % fails correctly because of quaternion package c = [q, eye(1)] % error: horzcat: cat: dimension mismatch % error: called from: % error: /Users/lukas/quaternion/inst/@quaternion/horzcat.m at line 27, column 5 % This bug seems to be solved in Octave 3.8.1 % http://savannah.gnu.org/bugs/?42234 quaternion-2.4.2/devel/PaxHeaders/demoml.m0000644000000000000000000000006215116327650015524 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/demoml.m0000644000175000017500000000027415116327650014651 0ustar00nirnirq = rot2q ([0, 0, 1], pi/4) [vv, theta] = q2rot (q) x = quaternion (0, 1, 1, 0) % nicht normiert % s x y z rx = q * x * conj (q) % q x q^-1 [vv, theta] = q2rot (rx) quaternion-2.4.2/devel/PaxHeaders/q4.m0000644000000000000000000000006215116327650014573 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/q4.m0000644000175000017500000000015415116327650013715 0ustar00nirnirfunction q = q4 if (nargin != 0) print_usage (); endif q = quaternion (1, 0, 0, 0); endfunctionquaternion-2.4.2/devel/PaxHeaders/q_2x3.m0000644000000000000000000000006215116327650015203 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/q_2x3.m0000644000175000017500000000022115116327650014320 0ustar00nirnirw = [2, 6, 10; 14, 18, 22]; x = [3, 7, 11; 15, 19, 23]; y = [4, 8, 12; 16, 20, 24]; z = [5, 9, 13; 17, 21, 25]; q = quaternion (w, x, y, z) quaternion-2.4.2/devel/PaxHeaders/q_2x2.m0000644000000000000000000000006215116327650015202 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/q_2x2.m0000644000175000017500000000016115116327650014322 0ustar00nirnirw = [2, 6; 10, 14]; x = [3, 7; 11, 15]; y = [4, 8; 12, 16]; z = [5, 9; 13, 17]; q = quaternion (w, x, y, z) quaternion-2.4.2/devel/PaxHeaders/test_numel.m0000644000000000000000000000006215116327650016426 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/test_numel.m0000644000175000017500000000032515116327650015550 0ustar00nirnirtest_quaternion q_2x3; a = q; q_2x2; b = q; [a, b; b, a] a(2,2) = 1 % a(2,2).z = 1 a.z(2,2) = 1 a.s = a a.s = a.v a.w(:,2:end) = b.w % a.w(:,2:end) = b.w(1,1) % a(:,2:end).w = b(1,1).w a(:,2:end) = b quaternion-2.4.2/devel/PaxHeaders/quaternion_arrays.m0000644000000000000000000000006215116327650020015 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/quaternion_arrays.m0000644000175000017500000000102615116327650017136 0ustar00nirniri = ones (3, 3); w = 2*i; x = 3*i; y = 4*i; z = 5*i; q = quaternion (w, x, y, z) q .* conj (q) %{ octave:1> quaternion_matrices q.w = 2 2 2 2 2 2 2 2 2 q.x = 3 3 3 3 3 3 3 3 3 q.y = 4 4 4 4 4 4 4 4 4 q.z = 5 5 5 5 5 5 5 5 5 ans.w = 54 54 54 54 54 54 54 54 54 ans.x = 0 0 0 0 0 0 0 0 0 ans.y = 0 0 0 0 0 0 0 0 0 ans.z = 0 0 0 0 0 0 0 0 0 octave:2> %}quaternion-2.4.2/devel/PaxHeaders/qbug.m0000644000000000000000000000006215116327650015205 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/qbug.m0000644000175000017500000000005515116327650014327 0ustar00nirnirq = quaternion (2, 3, 4, 5) diag ([q, q, q])quaternion-2.4.2/devel/PaxHeaders/generate_quaternion_pdf.m0000644000000000000000000000006215116327650021137 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/generate_quaternion_pdf.m0000644000175000017500000000042515116327650020262 0ustar00nirnirhomedir = pwd (); develdir = fileparts (which ("generate_quaternion_pdf")); pdfdir = [develdir, "/pdfdoc"]; cd (pdfdir); collect_texinfo_strings for i = 1:5 system ("pdftex -interaction batchmode quaternion.tex"); system ("texindex quaternion.fn"); endfor cd (homedir); quaternion-2.4.2/devel/PaxHeaders/INFO0000644000000000000000000000006215116327650014547 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/devel/INFO0000644000175000017500000000027315116327650013673 0ustar00nirnirWith the current Makefile, the folder "devel" and its content is ignored by "pkg install". The folder is intended for draft code and other stuff which is not suitable for "normal" users.quaternion-2.4.2/PaxHeaders/NEWS0000644000000000000000000000006215116327650013471 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/NEWS0000644000175000017500000001662115116327650012621 0ustar00nirnirSummary of important user-visible changes for releases of the quaternion package =============================================================================== quaternion-2.4.2 Release Date: 2025-12-10 Release Manager: Nir Krakauer =============================================================================== ** Update for robustness and support of new Octave versions: -- Remove src/is_real_array.cc, using isreal() instead. -- Make function names / method resolution more robust by calling builtin(). -- Fix "cellfun()" usage to be compatible with Octave 11+. -- Add tests, and remove inst/test_quaternion.m, using oruntests() instead. (bugs #59163, #67784) =============================================================================== quaternion-2.4.1 Release Date: 2025-11-24 Release Manager: Nir Krakauer =============================================================================== ** Update is_real_array to run in newer versions of Octave (bug #59163) ** The quaternion package now depends on Octave version 4.4.0 or beyond. =============================================================================== quaternion-2.4.0 Release Date: 2015-03-21 Release Manager: Lukas Reichlin =============================================================================== ** q2rot -- Vectorized code to support the input of multiple quaternions. -- Return axis as a column vector. -- Add test. ** rot2q -- Support for multiple rotation angles (vectorized code). -- Improved error messages. -- Add test. ** The following functions are new: rotm2q ** The following functions are now overloaded for quaternions: mean numel (Thanks to Willem Atsma for all the changes above) ** The quaternion package now depends on Octave version 3.8.0 or beyond. ** In order to comply with modified Octave Forge rules, the package no longer auto-loads by default. See "help pkg" for details on auto-loading. =============================================================================== quaternion-2.2.2 Release Date: 2014-07-20 Release Manager: Lukas Reichlin =============================================================================== ** q2rot Fixed bug #42666. The function no longer errors out. The bug has been introduced with the changes in quaternion-2.2.1. (Thanks to Kjell Andersen) ** The following functions are now overloaded for quaternions: repmat =============================================================================== quaternion-2.2.1 Release Date: 2014-05-05 Release Manager: Lukas Reichlin =============================================================================== ** The following functions are now overloaded for quaternions: get set While they offer no new editing features compared to subscripted assignment and reference, they can display the types and dimensions of the quaternion's components if called with one argument: get (q) set (q) ** subsasgn, subsref -- Improved documentation. -- Support assignment of scalar and vector part from other quaternions: q1.v = q2 # assign components x, y and z, leave w untouched =============================================================================== quaternion-2.2.0 Release Date: 2014-01-04 Release Manager: Lukas Reichlin =============================================================================== ** eq Changed operator semantics of "==" to match those of complex numbers and other built-in types. Quaternion arrays are now compared element-wise. The old behavior can be restored by the expression bool = size_equal (a, b) && all (eq (a, b)(:)) ** end "end" indexing for quaternions works now as expected. ** The following functions are now overloaded for quaternions: arg isempty reshape cast isfinite round ceil isinf sparse cumsum isnan squeeze fix isreal sum floor length tril full ndims triu ** The following operators are now overloaded for quaternions: ge (>=) le (<=) ne (!=, ~=) gt (>) lt (<) Since there is no ordering that makes quaternions an ordered field, several definitions are possible. The ordering chosen here is the lexicographic one. ** quaternion -- Allow logicals as quaternion components. -- When called with one or three arguments, fill missing vector or scalar part with zeros of the same class as the given arguments. Before, always doubles were used. =============================================================================== quaternion-2.0.3 Release Date: 2013-10-28 Release Manager: Lukas Reichlin =============================================================================== ** Compatibility to GNU Octave 3.8 Replaced line continuation marker "\" by "..." to avoid deprecated syntax warning. ** q2rot -- The rotation angle now lies in the interval [0, 2*pi]. -- Fixed bug #39521. (Thanks to Juan Pablo Carbajal and Max Katsev) http://savannah.gnu.org/bugs/?39521 =============================================================================== quaternion-2.0.2 Release Date: 2012-10-25 Release Manager: Lukas Reichlin =============================================================================== ** eq -- Fix typo bug which gave false positives for the k-component. -- Avoid error if arguments are non-conformant. ** size_equal Add overloaded method because the built-in function gives false positives for quaternions. ** ldivide, mldivide, mpower Show error message if the number of input arguments is not 2. =============================================================================== quaternion-2.0.1 Release Date: 2012-10-14 Release Manager: Lukas Reichlin =============================================================================== ** inv Support for the inversion of quaternion matrices. Right and left division operators (/ and \) profit from this change and support quaternion matrices as well. ** Check number of arguments when operators are called by their function names, e.g. plus (q1, q2, q3). Function plus supports now more than two arguments. ** doc/quaternion.pdf Revised PDF manual. There is now a function index at the end of the manual. ** The TeX-files quaternion.tex and functions.texi for generating quaternion.pdf are included in the doc folder, next to quaternion.pdf. Note that functions.texi is generated automatically by the scripts in the quaternion/devel folder and the package generate_html. They are not included in the quaternion package and can be found on the OctaveForge SVN server. =============================================================================== quaternion-2.0.0 Release Date: 2012-03-28 Release Manager: Lukas Reichlin =============================================================================== ** First official release. Its main features are: -- Matrices and n-dimensional arrays of quaternions. -- Overloaded operators due to the use of classes. -- Operator semantics similar to Octave’s built-in complex numbers. -- Vectorized code for crunching large quaternion arrays in a speedy manner. =============================================================================== quaternion-2.4.2/PaxHeaders/COPYING0000644000000000000000000000006215116327650014025 xustar0020 atime=1765388200 30 ctime=1765388212.228950384 quaternion-2.4.2/COPYING0000644000175000017500000010451315116327650013153 0ustar00nirnir GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read .