rot(V,theta)

Version 1.0.0.0 (1.79 KB) by Tianxiao
Returns the 3D rotation matrix about an arbitary vector
353 Downloads
Updated 18 Apr 2016

View License

This function returns the 3D rotation matrix about an arbitary vector V passing the origin.
This may serves as an extension to the matlab built in funciton : rotx, roty and rotz.
This can also be extended for V not going through origin by simple translation
Input:
V: 3 by 1 or 1 by 3 arbitrary rotation vector, it does not need to be normalized
theta:The rotation angle is positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the V towards the origin.
Output:
R: 3 by 3 rotation matrix
To use R on a column vector v: R*v
To use R on a row vector w: w*R'
Glenn Murray's step by step approach

(1) Translate space so that the rotation axis passes through the origin.
(2) Rotate space about the z axis so that the rotation axis lies in the xz plane.
(3) Rotate space about the y axis so that the rotation axis lies along the z axis.
(4) Perform the desired rotation by θ about the z axis.
(5) Apply the inverse of step (3).
(6) Apply the inverse of step (2).
(7) Apply the inverse of step (1).

Glenn Murray's online article :
http://inside.mines.edu/fs_home/gmurray/ArbitraryAxisRotation/

Example:
Rotate pi/3 about x-axis
rot([1,0,0],pi/3)
=

1.0000 0 0
0 0.5000 -0.8660
0 0.8660 0.5000

By Tianxiao Jiang
Unversity of Houston
jtxinnocence@gmail.com

Cite As

Tianxiao (2024). rot(V,theta) (https://www.mathworks.com/matlabcentral/fileexchange/56610-rot-v-theta), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on 3-D Scene Control in Help Center and MATLAB Answers
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Format adjustment