changeset 8908:819d8bd98031 octave-forge

robotics. Adding quaternion methods eq mpower power minus plus mtimes mrdivide
author jpicarbajal
date Mon, 14 Nov 2011 16:54:18 +0000
parents aee6fd8e754b
children d10aaaae0bad
files extra/robotics/inst/@Quaternion/eq.m extra/robotics/inst/@Quaternion/minus.m extra/robotics/inst/@Quaternion/mpower.m extra/robotics/inst/@Quaternion/mrdivide.m extra/robotics/inst/@Quaternion/mtimes.m extra/robotics/inst/@Quaternion/plus.m extra/robotics/inst/@Quaternion/power.m
diffstat 7 files changed, 180 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/eq.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,26 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{tf} = } eq (@var{a}, @var{b})
+%% Equal to operator for two Quaternions. Used by Octave for "a == b"
+%%
+%% @end deftypefn
+
+function flg = eq (a, b)
+
+  flg = a.q_wrap == b.q_wrap;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/minus.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,26 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{c} = } minus (@var{a}, @var{b})
+%% Subtraction of two quaternions. Used by Octave for "a - b"
+%%
+%% @end deftypefn
+
+function a = minus (a, b)
+
+  a.q_wrap = a.q_wrap - b.q_wrap;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/mpower.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,25 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{qn} = } mpower (@var{q}, @var{n})
+%% power operator of quaternions.  Used by Octave for "q.^n".
+%% @end deftypefn
+
+function a = mpower (a, b)
+
+  a.q_wrap = a.q_wrap.^b;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/mrdivide.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,26 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{c} = } mrdivide (@var{a}, @var{b})
+%% Matrix right division for quaternions. Used by Octave for "a / b"
+%%
+%% @end deftypefn
+
+function a = mrdivide (a, b)
+
+  a.q_wrap = a.q_wrap * inv (b.q_wrap);
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/mtimes.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,26 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{c} = } mtimes (@var{a}, @var{b})
+%%
+%% @end deftypefn
+
+
+function a = mtimes (a, b)
+
+  a.q_wrap = a.q_wrap * b.q_wrap;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/plus.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,26 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{c} = } plus (@var{a}, @var{b})
+%% Addition of two Quaternions. Used by Octave for "a + b"
+%%
+%% @end deftypefn
+
+function a = plus (a, b)
+
+  a.q_wrap = a.q_wrap + b.q_wrap;
+
+endfunction
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/robotics/inst/@Quaternion/power.m	Mon Nov 14 16:54:18 2011 +0000
@@ -0,0 +1,25 @@
+%% Copyright (c) 2011 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
+%%
+%%    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 <http://www.gnu.org/licenses/>.
+
+%% -*- texinfo -*-
+%% @deftypefn {Function File} {@var{qn} = } power (@var{q}, @var{n})
+%% power operator of quaternions.  Used by Octave for "q.^n".
+%% @end deftypefn
+
+function a = power (a, b)
+
+  a.q_wrap = a.q_wrap.^b;
+
+endfunction