From: <par...@us...> - 2011-11-19 21:21:49
|
Revision: 9143 http://octave.svn.sourceforge.net/octave/?rev=9143&view=rev Author: paramaniac Date: 2011-11-19 21:21:42 +0000 (Sat, 19 Nov 2011) Log Message: ----------- quaternion_oo: move files, add header Added Paths: ----------- trunk/octave-forge/extra/quaternion_oo/inst/q2rot.m trunk/octave-forge/extra/quaternion_oo/inst/rot2q.m Removed Paths: ------------- trunk/octave-forge/extra/quaternion_oo/devel/q2rot.m trunk/octave-forge/extra/quaternion_oo/devel/rot2q.m Deleted: trunk/octave-forge/extra/quaternion_oo/devel/q2rot.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/devel/q2rot.m 2011-11-19 21:07:44 UTC (rev 9142) +++ trunk/octave-forge/extra/quaternion_oo/devel/q2rot.m 2011-11-19 21:21:42 UTC (rev 9143) @@ -1,31 +0,0 @@ -function [vv, theta] = q2rot (q) - - if (nargin != 1 || nargout != 2) - print_usage (); - endif - - if (abs (norm (q) - 1) > 1e-12) - warning ("quaternion: ||q||=%e, setting=1 for vv, theta", norm (q)); - q = unit (q); - endif - - s = q.s; - x = q.x; - y = q.y; - z = q.z; - - theta = acos (s) * 2; - - if (abs (theta) > pi) - theta = theta - sign (theta) * pi; - endif - - sin_th_2 = norm ([x, y, z]); - - if (sin_th_2 != 0) - vv = [x, y, z] / sin_th_2; - else - vv = [x, y, z]; - endif - -endfunction \ No newline at end of file Deleted: trunk/octave-forge/extra/quaternion_oo/devel/rot2q.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/devel/rot2q.m 2011-11-19 21:07:44 UTC (rev 9142) +++ trunk/octave-forge/extra/quaternion_oo/devel/rot2q.m 2011-11-19 21:21:42 UTC (rev 9143) @@ -1,33 +0,0 @@ -function q = rot2q (vv, theta) - - if (nargin != 2 || nargout != 1) - print_usage (); - endif - - if (! isvector (vv) || length (vv) != 3) - error ("vv must be a length three vector"); - endif - - if (! isscalar (theta)) - error ("theta must be a scalar"); - endif - - if (norm (vv) == 0) - error ("quaternion: vv is zero"); - endif - - if (abs (norm (vv) - 1) > 1e-12) - warning ("quaternion: ||vv|| != 1, normalizing") - vv = vv / norm (vv); - endif - - if (abs (theta) > 2*pi) - warning ("quaternion: |theta| > 2 pi, normalizing") - theta = rem (theta, 2*pi); - endif - - vv = vv * sin (theta / 2); - d = cos (theta / 2); - q = quaternion (d, vv(1), vv(2), vv(3)); - -endfunction \ No newline at end of file Copied: trunk/octave-forge/extra/quaternion_oo/inst/q2rot.m (from rev 9138, trunk/octave-forge/extra/quaternion_oo/devel/q2rot.m) =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/q2rot.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/q2rot.m 2011-11-19 21:21:42 UTC (rev 9143) @@ -0,0 +1,55 @@ +## Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Auburn University +## Copyright (C) 2010, 2011 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 -*- +## TODO + +## Adapted from: quaternion by A. S. Hodel <a.s...@en...> +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2010 +## Version: 0.1 + +function [vv, theta] = q2rot (q) + + if (nargin != 1 || nargout != 2) + print_usage (); + endif + + if (abs (norm (q) - 1) > 1e-12) + warning ("quaternion: ||q||=%e, setting=1 for vv, theta", norm (q)); + q = unit (q); + endif + + s = q.s; + x = q.x; + y = q.y; + z = q.z; + + theta = acos (s) * 2; + + if (abs (theta) > pi) + theta = theta - sign (theta) * pi; + endif + + sin_th_2 = norm ([x, y, z]); + + if (sin_th_2 != 0) + vv = [x, y, z] / sin_th_2; + else + vv = [x, y, z]; + endif + +endfunction \ No newline at end of file Copied: trunk/octave-forge/extra/quaternion_oo/inst/rot2q.m (from rev 9138, trunk/octave-forge/extra/quaternion_oo/devel/rot2q.m) =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/rot2q.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/rot2q.m 2011-11-19 21:21:42 UTC (rev 9143) @@ -0,0 +1,57 @@ +## Copyright (C) 1998, 1999, 2000, 2002, 2005, 2006, 2007 Auburn University +## Copyright (C) 2010, 2011 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 -*- +## TODO + +## Adapted from: quaternion by A. S. Hodel <a.s...@en...> +## Author: Lukas Reichlin <luk...@gm...> +## Created: May 2010 +## Version: 0.1 + +function q = rot2q (vv, theta) + + if (nargin != 2 || nargout != 1) + print_usage (); + endif + + if (! isvector (vv) || length (vv) != 3) + error ("vv must be a length three vector"); + endif + + if (! isscalar (theta)) + error ("theta must be a scalar"); + endif + + if (norm (vv) == 0) + error ("quaternion: vv is zero"); + endif + + if (abs (norm (vv) - 1) > 1e-12) + warning ("quaternion: ||vv|| != 1, normalizing") + vv = vv / norm (vv); + endif + + if (abs (theta) > 2*pi) + warning ("quaternion: |theta| > 2 pi, normalizing") + theta = rem (theta, 2*pi); + endif + + vv = vv * sin (theta / 2); + d = cos (theta / 2); + q = quaternion (d, vv(1), vv(2), vv(3)); + +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. |