EulerRotationMatrix​(RotationAxis, Angle, AngleUnits, DebugFlag)

版本 1.2 (5.0 KB) 作者: Sugato
Matrix Utilities: Euler Rotation Matrices
141.0 次下载
更新时间 2017/8/12

查看许可证

Function Description:
This function returns a 3x3 ROTATION MATRIX (R). It can accept angle inputs in both "degree" and "radian" for any of the three axes (x,y,z).

AUTHOR: Sugato Ray | Created on: 11-AUG-2017 | ray.sugato[at]gmail.com

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PLEASE ACKNOWLEDGE THE AUTHOR IF YOU USE THIS CODE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

INPUT:
rotationAxis = 'x' or, 'y' or, 'z'. ; Default: 'z'
Angle = angle of rotation (Numeric input only) ; Default: 0
AngleUnits = 'D' for Degrees or, 'R' for Radians ; Default: 'D'
DebugFlag = 1 (true) or, 0 (false) ; Default: 0

Note: DebugFlag = 1 enables printing Rotation Matrix (R) on Console.

OUTPUT:
R = Rotation matrix about the axis of rotation

EXAMPLE:
R = EulerRotationMatrix(rotationAxis, Angle, AngleUnits, DebugFlag);
R = EulerRotationMatrix('x', 60, 'D'); % Rotate by 60 degs about x-axis
R = EulerRotationMatrix('z', pi/3, 'R'); % Rotate by pi/3 rads about z-axis

Alternative approach: Define a function handle

RotZ = @(ang) EulerRotationMatrix('z',ang,'D',1);
RotZ(60);

RotY = @(ang) EulerRotationMatrix('y',ang,'D',1);
RotY(60);

RotX = @(ang) EulerRotationMatrix('x',ang,'D',1);
RotX(60);

Test the value of RotX(60) against the following result:

Rx = [1,0,0; 0, cosd(60), -sind(60); 0, sind(60), cosd(60)]

引用格式

Sugato (2024). EulerRotationMatrix(RotationAxis, Angle, AngleUnits, DebugFlag) (https://www.mathworks.com/matlabcentral/fileexchange/64087-eulerrotationmatrix-rotationaxis-angle-angleunits-debugflag), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2016a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Motion Modeling and Coordinate Systems 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.2

Updated summary
Updated function description.

1.1.0.0

11-AUG-2017 | Version: 1.1 | Changed function name to EulerRotationMatrix. And updated function description.

1.0.0.0

Some minor changes made.

Updated function description.