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

📄 rotationmat3d.mht

📁 输入一个旋转角度
💻 MHT
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject: 
Date: Mon, 25 May 2009 16:51:15 +0800
MIME-Version: 1.0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.mathworks.com/matlabcentral/fx_files/23417/1/rotationmat3D.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.5726" name=3DGENERATOR></HEAD>
<BODY><PRE>function R=3D rotationmat3D(r,Axis)
%function R=3D rotationmat3D(radians,Axis)
%
% creates a rotation matrix such that R * x=20
% operates on x by rotating x around the origin r radians around line
% connecting the origin to the point "Axis"
%
% example:
% rotate around a random direction a random amount and then back
% the result should be an Identity matrix
%
%r =3D rand(4,1);
%rotationmat3D(r(1),[r(2),r(3),r(4)]) * =
rotationmat3D(-r(1),[r(2),r(3),r(4)])
%
% example2:=20
% rotate around z axis 45 degrees
% Rtest =3D rotationmat3D(pi/4,[0 0 1])
%
%Bileschi 2009

if nargin =3D=3D 1
   if(length(rotX) =3D=3D 3)
      rotY =3D rotX(2);
      rotZ =3D rotZ(3);
      rotX =3D rotX(1);
   end
end

% useful intermediates
L =3D norm(Axis);
if (L &lt; eps)
   error('axis direction must be non-zero vector');
end
Axis =3D Axis / L;
L =3D 1;
u =3D Axis(1);
v =3D Axis(2);
w =3D Axis(3);
u2 =3D u^2;
v2 =3D v^2;
w2 =3D w^2;
c =3D cos(r);
s =3D sin(r);
%storage
R =3D nan(3);
%fill
R(1,1) =3D  u2 + (v2 + w2)*c;
R(1,2) =3D u*v*(1-c) - w*s;
R(1,3) =3D u*w*(1-c) + v*s;
R(2,1) =3D u*v*(1-c) + w*s;
R(2,2) =3D v2 + (u2+w2)*c;
R(2,3) =3D v*w*(1-c) - u*s;
R(3,1) =3D u*w*(1-c) - v*s;
R(3,2) =3D v*w*(1-c)+u*s;
R(3,3) =3D w2 + (u2+v2)*c;
</PRE></BODY></HTML>

⌨️ 快捷键说明

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