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

📄 qinterp.m

📁 Robot tool box - provides many functions that are useful in robotics including such things as kinem
💻 M
字号:
%QINTERP Interpolate rotations expressed by quaternion objects%%	QI = qinterp(Q1, Q2, R)%% Return a unit-quaternion that interpolates between Q1 and Q2 as R moves% from 0 to 1.  This is a spherical linear interpolation (slerp) that can% be interpretted as interpolation along a great circle arc on a sphere.%% If r is a vector, QI, is a cell array of quaternions, each element% corresponding to sequential elements of R.%% See also: CTRAJ, QUATERNION.% Copyright (C) 1999-2008, by Peter I. Corke%% This file is part of The Robotics Toolbox for Matlab (RTB).% % RTB is free software: you can redistribute it and/or modify% it under the terms of the GNU Lesser General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.% % RTB 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 Lesser General Public License for more details.% % You should have received a copy of the GNU Leser General Public License% along with RTB.  If not, see <http://www.gnu.org/licenses/>.function q = qinterp(Q1, Q2, r)	q1 = double(Q1);	q2 = double(Q2);	if (r<0) | (r>1),		error('R out of range');	end	theta = acos(q1*q2');	q = {};	count = 1;	if length(r) == 1,		if theta == 0,			q = Q1;		else			q = quaternion( (sin((1-r)*theta) * q1 + sin(r*theta) * q2) / sin(theta) );		end	else		for R=r(:)',			if theta == 0,				qq = Q1;			else				qq = quaternion( (sin((1-R)*theta) * q1 + sin(R*theta) * q2) / sin(theta) );			end			q{count} = qq;			count = count + 1;		end	end

⌨️ 快捷键说明

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