Home > arte3.2.0 > lib > qRot.m

qRot

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function Q = qRot(theta, axis)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   Q = QROT(THETA, AXIS)
   Returns a quaternion corresponding to a rotation of theta over axis u.
   where u can be: 'i', 'j', or 'k' for rotations over the X, Y and Z axes
   respectively.
   
   See also QPROD, T2QUATERNION, QUATERNION2T.

   Author: Arturo Gil. Universidad Miguel Hernández de Elche. email:
   arturo.gil@umh.es date:   21/04/2012
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %   Q = QROT(THETA, AXIS)
0003 %   Returns a quaternion corresponding to a rotation of theta over axis u.
0004 %   where u can be: 'i', 'j', or 'k' for rotations over the X, Y and Z axes
0005 %   respectively.
0006 %
0007 %   See also QPROD, T2QUATERNION, QUATERNION2T.
0008 %
0009 %   Author: Arturo Gil. Universidad Miguel Hernández de Elche. email:
0010 %   arturo.gil@umh.es date:   21/04/2012
0011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0012 
0013 % Copyright (C) 2012, by Arturo Gil Aparicio
0014 %
0015 % This file is part of ARTE (A Robotics Toolbox for Education).
0016 %
0017 % ARTE is free software: you can redistribute it and/or modify
0018 % it under the terms of the GNU Lesser General Public License as published by
0019 % the Free Software Foundation, either version 3 of the License, or
0020 % (at your option) any later version.
0021 %
0022 % ARTE is distributed in the hope that it will be useful,
0023 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0024 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0025 % GNU Lesser General Public License for more details.
0026 %
0027 % You should have received a copy of the GNU Leser General Public License
0028 % along with ARTE.  If not, see <http://www.gnu.org/licenses/>.
0029 function Q = qRot(theta, axis)
0030 
0031 switch axis
0032     case 'i'
0033         Q = [cos(theta/2) sin(theta/2) 0 0];
0034     case 'j'
0035         Q = [cos(theta/2) 0 sin(theta/2) 0];
0036     case 'k'
0037         Q = [cos(theta/2) 0 0 sin(theta/2)];
0038     otherwise
0039         disp('Please: select i, j or k')
0040         Q = [1 0 0 0];
0041 end

Generated on Fri 03-Jan-2014 12:20:01 by m2html © 2005