From: <par...@us...> - 2010-05-17 18:17:53
|
Revision: 7318 http://octave.svn.sourceforge.net/octave/?rev=7318&view=rev Author: paramaniac Date: 2010-05-17 18:17:46 +0000 (Mon, 17 May 2010) Log Message: ----------- quaternion_oo: add some operators Modified Paths: -------------- trunk/octave-forge/extra/quaternion_oo/INDEX Added Paths: ----------- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/inv.m trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mldivide.m trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mrdivide.m Modified: trunk/octave-forge/extra/quaternion_oo/INDEX =================================================================== --- trunk/octave-forge/extra/quaternion_oo/INDEX 2010-05-17 00:45:25 UTC (rev 7317) +++ trunk/octave-forge/extra/quaternion_oo/INDEX 2010-05-17 18:17:46 UTC (rev 7318) @@ -10,6 +10,9 @@ @quaternion/uminus @quaternion/times @quaternion/mtimes + @quaternion/inv + @quaternion/mldivide + @quaternion/mrdivide @quaternion/transpose @quaternion/ctranspose @quaternion/horzcat Added: trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/inv.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/inv.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/inv.m 2010-05-17 18:17:46 UTC (rev 7318) @@ -0,0 +1,43 @@ +## Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{qinv} =} inv (@var{q}) +## Return inverse of a quaternion. +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2010 +## Version: 0.1 + + +function a = inv (a) + + if (nargin != 1) + print_usage (); + endif + + if (! isscalar (a.w)) + error ("quaternion: inv: implemented for scalar quaternions only"); + endif + + norm2 = a.w*a.w + a.x*a.x + a.y*a.y + a.z*a.z; + + a.w = a.w / norm2; + a.x = -a.x / norm2; + a.y = -a.y / norm2; + a.z = -a.z / norm2; + +endfunction \ No newline at end of file Added: trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mldivide.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mldivide.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mldivide.m 2010-05-17 18:17:46 UTC (rev 7318) @@ -0,0 +1,28 @@ +## Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Matrix left division for quaternions. Used by Octave for "q1 \ q2" + +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2010 +## Version: 0.1 + + +function q = mldivide (a, b) + + q = inv (a) * b; + +endfunction \ No newline at end of file Added: trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mrdivide.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mrdivide.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/mrdivide.m 2010-05-17 18:17:46 UTC (rev 7318) @@ -0,0 +1,28 @@ +## Copyright (C) 2010 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 <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## Matrix right division for quaternions. Used by Octave for "q1 / q2" + +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2010 +## Version: 0.1 + + +function q = mrdivide (a, b) + + q = a * inv (b); + +endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |