📄 tr2angvec.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 tr2angvec</title> <meta name="keywords" content="tr2angvec"> <meta name="description" content="TR2ANGVEC Convert to angle/vector form"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="m2html © 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> > <a href="index.html">.</a> > tr2angvec.m</div><!--<table width="100%"><tr><td align="left"><a href="./index.html"><img alt="<" border="0" src="./left.png"> Master index</a></td><td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="./right.png"></a></td></tr></table>--><h1>tr2angvec</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="./up.png"></a></h2><div class="box"><strong>TR2ANGVEC Convert to angle/vector form</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 [theta, v] = tr2angvec(t) </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">TR2ANGVEC Convert to angle/vector form [THETA V] = TR2ANGVEC(M) Returns a vector/angle representation of the pose corresponding to M, either a rotation matrix or the rotation part of a homogeneous transform. This is a rotation of THETA about the vector V. See also: <a href="angvec2r.html" class="code" title="function R = angvec2r(theta, k)">ANGVEC2R</a>, <a href="angvec2tr.html" class="code" title="function T = angvec2tr(theta, k)">ANGVEC2TR</a></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="unit.html" class="code" title="function u = unit(v)">unit</a> UNIT Unitize a vector</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">%TR2ANGVEC Convert to angle/vector form</span>0002 <span class="comment">%</span>0003 <span class="comment">% [THETA V] = TR2ANGVEC(M)</span>0004 <span class="comment">%</span>0005 <span class="comment">% Returns a vector/angle representation of the pose corresponding to M, either a rotation</span>0006 <span class="comment">% matrix or the rotation part of a homogeneous transform.</span>0007 <span class="comment">% This is a rotation of THETA about the vector V.</span>0008 <span class="comment">%</span>0009 <span class="comment">% See also: ANGVEC2R, ANGVEC2TR</span>0010 0011 <span class="comment">% Copyright (C) 1993-2008, by Peter I. Corke</span>0012 <span class="comment">%</span>0013 <span class="comment">% This file is part of The Robotics Toolbox for Matlab (RTB).</span>0014 <span class="comment">%</span>0015 <span class="comment">% RTB is free software: you can redistribute it and/or modify</span>0016 <span class="comment">% it under the terms of the GNU Lesser General Public License as published by</span>0017 <span class="comment">% the Free Software Foundation, either version 3 of the License, or</span>0018 <span class="comment">% (at your option) any later version.</span>0019 <span class="comment">%</span>0020 <span class="comment">% RTB is distributed in the hope that it will be useful,</span>0021 <span class="comment">% but WITHOUT ANY WARRANTY; without even the implied warranty of</span>0022 <span class="comment">% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>0023 <span class="comment">% GNU Lesser General Public License for more details.</span>0024 <span class="comment">%</span>0025 <span class="comment">% You should have received a copy of the GNU Leser General Public License</span>0026 <span class="comment">% along with RTB. If not, see <http://www.gnu.org/licenses/>.</span>0027 0028 <a name="_sub0" href="#_subfunctions" class="code">function [theta, v] = tr2angvec(t)</a>0029 0030 qs = sqrt(trace(t)+1)/2.0;0031 qs0032 kx = t(3,2) - t(2,3); <span class="comment">% Oz - Ay</span>0033 ky = t(1,3) - t(3,1); <span class="comment">% Ax - Nz</span>0034 kz = t(2,1) - t(1,2); <span class="comment">% Ny - Ox</span>0035 0036 <span class="keyword">if</span> (t(1,1) >= t(2,2)) & (t(1,1) >= t(3,3)) 0037 kx1 = t(1,1) - t(2,2) - t(3,3) + 1; <span class="comment">% Nx - Oy - Az + 1</span>0038 ky1 = t(2,1) + t(1,2); <span class="comment">% Ny + Ox</span>0039 kz1 = t(3,1) + t(1,3); <span class="comment">% Nz + Ax</span>0040 add = (kx >= 0);0041 <span class="keyword">elseif</span> (t(2,2) >= t(3,3))0042 kx1 = t(2,1) + t(1,2); <span class="comment">% Ny + Ox</span>0043 ky1 = t(2,2) - t(1,1) - t(3,3) + 1; <span class="comment">% Oy - Nx - Az + 1</span>0044 kz1 = t(3,2) + t(2,3); <span class="comment">% Oz + Ay</span>0045 add = (ky >= 0);0046 <span class="keyword">else</span>0047 kx1 = t(3,1) + t(1,3); <span class="comment">% Nz + Ax</span>0048 ky1 = t(3,2) + t(2,3); <span class="comment">% Oz + Ay</span>0049 kz1 = t(3,3) - t(1,1) - t(2,2) + 1; <span class="comment">% Az - Nx - Oy + 1</span>0050 add = (kz >= 0);0051 <span class="keyword">end</span>0052 0053 <span class="keyword">if</span> add0054 kx = kx + kx1;0055 ky = ky + ky1;0056 kz = kz + kz1;0057 <span class="keyword">else</span>0058 kx = kx - kx1;0059 ky = ky - ky1;0060 kz = kz - kz1;0061 <span class="keyword">end</span>0062 v = <a href="unit.html" class="code" title="function u = unit(v)">unit</a>([kx ky kz]);0063 theta = 2*acos(qs);0064 0065 <span class="keyword">if</span> nargout == 00066 fprintf(<span class="string">'Rotation: %f rad x [%f %f %f]\n'</span>, theta, v(1), v(2), v(3));0067 <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> © 2003</address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -