Home > voicebox > qrdivide.m

qrdivide

PURPOSE ^

QRDIVIDE divdes two real quaternions q=[q1,q2]

SYNOPSIS ^

function q=qrdivide(q1,q2)

DESCRIPTION ^

QRDIVIDE divdes two real quaternions q=[q1,q2]

 Inputs:

     q1(4,1), q2(4,1)  Two real quaternions in the form [r, i, j, k]' where i^2=j^2=k^2=ijk=-1

 Outputs: 

     q(4,1)   Quotient of q1/q2 such that q1=q*q2.
              Note that q*q2 ~= q2*q since quaternion multiplication does not commute.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function q=qrdivide(q1,q2)
0002 %QRDIVIDE divdes two real quaternions q=[q1,q2]
0003 %
0004 % Inputs:
0005 %
0006 %     q1(4,1), q2(4,1)  Two real quaternions in the form [r, i, j, k]' where i^2=j^2=k^2=ijk=-1
0007 %
0008 % Outputs:
0009 %
0010 %     q(4,1)   Quotient of q1/q2 such that q1=q*q2.
0011 %              Note that q*q2 ~= q2*q since quaternion multiplication does not commute.
0012 
0013 %      Copyright (C) Mike Brookes 2000-2008
0014 %      Version: $Id: qrdivide.m 713 2011-10-16 14:45:43Z dmb $
0015 %
0016 %   VOICEBOX is a MATLAB toolbox for speech processing.
0017 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0018 %
0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0020 %   This program is free software; you can redistribute it and/or modify
0021 %   it under the terms of the GNU General Public License as published by
0022 %   the Free Software Foundation; either version 2 of the License, or
0023 %   (at your option) any later version.
0024 %
0025 %   This program is distributed in the hope that it will be useful,
0026 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0027 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0028 %   GNU General Public License for more details.
0029 %
0030 %   You can obtain a copy of the GNU General Public License from
0031 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0032 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0034 persistent a b c d
0035 if isempty(a)
0036     a=[5 8 9 10 15 13];
0037     b=[6 7 11 12 14 16];
0038     c=[1 2 3 4 6 7 11 12 16 14];
0039     d=[1 2 3 4 5 8 9 10 13 15];
0040 end
0041 if nargin<2
0042     %    just take the inverse of the only input argument
0043     q=q1/(q1'*q1);
0044     q(2:4)=-q(2:4);
0045 else
0046     %    invert q2 and do a multiply
0047     q=q2/(q2'*q2);
0048     q(2:4)=-q(2:4);
0049     t=q1*q.';
0050     s=zeros(4,4);
0051     s(a)=-t(b);
0052     s(c)=t(d);
0053     q=sum(s,2);
0054 end
0055

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003