⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mtimes.html

📁 Robot tool box - provides many functions that are useful in robotics including such things as kinem
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head>  <title>Description of mtimes</title>  <meta name="keywords" content="mtimes">  <meta name="description" content="MTIMES Multiply two quaternion objects">  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">  <meta name="robots" content="index, follow">  <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> &gt;  <a href="#">@quaternion</a> &gt; mtimes.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td><td align="right"><a href="index.html">Index for ./@quaternion&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>mtimes</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>MTIMES Multiply two quaternion objects</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>function qp = mtimes(q1, q2) </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment">MTIMES Multiply two quaternion objects Invoked by the * operator, handle two cases: q1*q2    standard quaternion multiplication q1*v    rotate vector v by quaternion q1*s    multiply vector v by scalar</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"><li><a href="double.html" class="code" title="function v = double(q)">double</a>	DOUBLE Convert a quaternion object to a 4-element vector</li><li><a href="inv.html" class="code" title="function qi = inv(q)">inv</a>	INV Invert a unit-quaternion</li><li><a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>	QUATERNION Constructor for quaternion objects</li></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"></ul><!-- crossreference --><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <span class="comment">%MTIMES Multiply two quaternion objects</span>0002 <span class="comment">%</span>0003 <span class="comment">% Invoked by the * operator, handle two cases:</span>0004 <span class="comment">%</span>0005 <span class="comment">% q1*q2    standard quaternion multiplication</span>0006 <span class="comment">% q1*v    rotate vector v by quaternion</span>0007 <span class="comment">% q1*s    multiply vector v by scalar</span>0008 0009 <span class="comment">% Copyright (C) 1999-2008, by Peter I. Corke</span>0010 <span class="comment">%</span>0011 <span class="comment">% This file is part of The Robotics Toolbox for Matlab (RTB).</span>0012 <span class="comment">%</span>0013 <span class="comment">% RTB is free software: you can redistribute it and/or modify</span>0014 <span class="comment">% it under the terms of the GNU Lesser General Public License as published by</span>0015 <span class="comment">% the Free Software Foundation, either version 3 of the License, or</span>0016 <span class="comment">% (at your option) any later version.</span>0017 <span class="comment">%</span>0018 <span class="comment">% RTB is distributed in the hope that it will be useful,</span>0019 <span class="comment">% but WITHOUT ANY WARRANTY; without even the implied warranty of</span>0020 <span class="comment">% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>0021 <span class="comment">% GNU Lesser General Public License for more details.</span>0022 <span class="comment">%</span>0023 <span class="comment">% You should have received a copy of the GNU Leser General Public License</span>0024 <span class="comment">% along with RTB.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>0025 0026 <a name="_sub0" href="#_subfunctions" class="code">function qp = mtimes(q1, q2)</a>0027 0028     <span class="keyword">if</span> isa(q1, <span class="string">'quaternion'</span>) &amp; isa(q2, <span class="string">'quaternion'</span>)0029     <span class="comment">%QQMUL    Multiply unit-quaternion by unit-quaternion</span>0030     <span class="comment">%</span>0031     <span class="comment">%    QQ = qqmul(Q1, Q2)</span>0032     <span class="comment">%</span>0033     <span class="comment">%    Return a product of unit-quaternions.</span>0034     <span class="comment">%</span>0035     <span class="comment">%    See also: TR2Q</span>0036 0037     <span class="comment">%    Copyright (C) 1993 Peter Corke</span>0038 0039         <span class="comment">% decompose into scalar and vector components</span>0040         s1 = q1.s;    v1 = q1.v;0041         s2 = q2.s;    v2 = q2.v;0042 0043         <span class="comment">% form the product</span>0044         qp = <a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>([s1*s2-v1*v2' s1*v2+s2*v1+cross(v1,v2)]);0045 0046     <span class="keyword">elseif</span> isa(q1, <span class="string">'quaternion'</span>) &amp; isa(q2, <span class="string">'double'</span>),0047 0048     <span class="comment">%QVMUL    Multiply vector by unit-quaternion</span>0049     <span class="comment">%</span>0050     <span class="comment">%    VT = qvmul(Q, V)</span>0051     <span class="comment">%</span>0052     <span class="comment">%    Rotate the vector V by the unit-quaternion Q.</span>0053     <span class="comment">%</span>0054     <span class="comment">%    See also: QQMUL, QINV</span>0055 0056     <span class="comment">%    Copyright (C) 1993 Peter Corke</span>0057 0058     <span class="comment">% MOD HISTORY</span>0059     <span class="comment">%    fixed error in q-v product, added inv(q1) on RHS</span>0060 0061         <span class="keyword">if</span> length(q2) == 3,0062             qp = q1 * <a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>([0 q2(:)']) * <a href="inv.html" class="code" title="function qi = inv(q)">inv</a>(q1);0063             qp = qp.v;0064         <span class="keyword">elseif</span> length(q2) == 1,0065             qp = <a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>( <a href="double.html" class="code" title="function v = double(q)">double</a>(q1)*q2);0066         <span class="keyword">else</span>0067             error(<span class="string">'quaternion-vector product: must be a 3-vector or scalar'</span>);0068         <span class="keyword">end</span>0069 0070     <span class="keyword">elseif</span> isa(q2, <span class="string">'quaternion'</span>) &amp; isa(q1, <span class="string">'double'</span>),0071         <span class="keyword">if</span> length(q1) == 3,0072             qp = q2 * <a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>([0 q1(:)']) * <a href="inv.html" class="code" title="function qi = inv(q)">inv</a>(q2);0073             qp = qp.v;0074         <span class="keyword">elseif</span> length(q1) == 1,0075             qp = <a href="quaternion.html" class="code" title="function q = quaternion(a1, a2)">quaternion</a>( <a href="double.html" class="code" title="function v = double(q)">double</a>(q2)*q1);0076         <span class="keyword">else</span>0077             error(<span class="string">'quaternion-vector product: must be a 3-vector or scalar'</span>);0078         <span class="keyword">end</span>0079     <span class="keyword">end</span></pre></div><hr><address>Generated on Sun 15-Feb-2009 18:09:29 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -