Be the first to rate this file! 85 downloads (last 30 days) File Size: 1.13 KB File ID: #23417

Compute 3D rotation matrix

by Stanley

 

24 Mar 2009

No BSD License  

Simplifies computation of 3D rotation matrices.

Download Now | Watch this File

File Information
Description

Given input:
r: angle to rotate, in rads
Axis: axis of rotation, defined as a 3point which connects to the origin.

Output:
3x3 Matrix R such that for an arbitrary point v, Rv is the point corresponding to v rotated around the Axis.

% example:
% rotate around a random direction a random amount and then back
% the result should be an Identity matrix

r = rand(4,1);
rotationmat3D(r(1),[r(2),r(3),r(4)]) * rotationmat3D(-r(1),[r(2),r(3),r(4)])

ans =

    1.0000 0.0000 0.0000
    0.0000 1.0000 0
    0.0000 0 1.0000

%
% example2:
% rotate around z axis 45 degrees
 Rtest = rotationmat3D(pi/4,[0 0 1])
Rtest =

    0.7071 -0.7071 0
    0.7071 0.7071 0
         0 0 1.0000

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
geometry Stanley 25 Mar 2009 16:02:22
3d Stanley 25 Mar 2009 16:02:22
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com