Skip to content
Snippets Groups Projects
Verified Commit 2238e009 authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

refact: implement rotation matrices

The functions rotx, roty, rotz are not built-in of MATLAB (wtf). Instead
they come from a very expensive toolbox. As none other function of this
toolbox are needed, the functions are reimplemented manually for Rotare
to remove that useless dependency.
parent 83427a00
No related branches found
No related tags found
No related merge requests found
function rotMat = rotx(angleDeg)
% ROTX Rotation matrix about X-axis
% -----
%
% Syntax:
% rotMat = rotx(angleDeg) returns the rotation matrix that rotates
% a point of an angle `angleDeg` (in degrees) around the X-axis.
%
% Inputs:
% angleDeg: Angle of rotation, [deg]
%
% Outputs:
% rotMat : 3x3 matrix for the rotation around X-axis
%
% See also: roty, rotz.
%
% <a href="https://gitlab.uliege.be/rotare/documentation">Complete documentation (online)</a>
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022-2023 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
% Repo: https://gitlab.uliege.be/rotare/rotare
% Docs: https://gitlab.uliege.be/rotare/documentation
% Issues: https://gitlab.uliege.be/rotare/rotare/-/issues
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
validateattributes(angleDeg, {'numeric'}, {'scalar'}, mfilename(), 'angleDeg', 1);
rotMat = [1, 0, 0
0, cosd(angleDeg), -sind(angleDeg)
0, sind(angleDeg), cosd(angleDeg)];
end
function rotMat = roty(angleDeg)
% ROTY Rotation matrix about Y-axis
% -----
%
% Syntax:
% rotMat = roty(angleDeg) returns the rotation matrix that rotates
% a point of an angle `angleDeg` (in degrees) around the Y-axis.
%
% Inputs:
% angleDeg: Angle of rotation, [deg]
%
% Outputs:
% rotMat : 3x3 matrix for the rotation around Y-axis
%
% See also: rotx, rotz.
%
% <a href="https://gitlab.uliege.be/rotare/documentation">Complete documentation (online)</a>
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022-2023 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
% Repo: https://gitlab.uliege.be/rotare/rotare
% Docs: https://gitlab.uliege.be/rotare/documentation
% Issues: https://gitlab.uliege.be/rotare/rotare/-/issues
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
validateattributes(angleDeg, {'numeric'}, {'scalar'}, mfilename(), 'angleDeg', 1);
rotMat = [cosd(angleDeg), 0, sind(angleDeg)
0, 1, 0
-sind(angleDeg), 0, cosd(angleDeg)];
end
function rotMat = rotz(angleDeg)
% ROTZ Rotation matrix about Z-axis
% -----
%
% Syntax:
% rotMat = rotz(angleDeg) returns the rotation matrix that rotates
% a point of an angle `angleDeg` (in degrees) around the Z-axis.
%
% Inputs:
% angleDeg: Angle of rotation, [deg]
%
% Outputs:
% rotMat : 3x3 matrix for the rotation around Z-axis
%
% See also: rotx, roty.
%
% <a href="https://gitlab.uliege.be/rotare/documentation">Complete documentation (online)</a>
% ----------------------------------------------------------------------------------------------
% (c) Copyright 2022-2023 University of Liege
% Author: Thomas Lambert <t.lambert@uliege.be>
% ULiege - Aeroelasticity and Experimental Aerodynamics
% MIT License
% Repo: https://gitlab.uliege.be/rotare/rotare
% Docs: https://gitlab.uliege.be/rotare/documentation
% Issues: https://gitlab.uliege.be/rotare/rotare/-/issues
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
validateattributes(angleDeg, {'numeric'}, {'scalar'}, mfilename(), 'angleDeg', 1);
rotMat = [cosd(angleDeg), -sind(angleDeg), 0
sind(angleDeg), cosd(angleDeg), 0
0, 0, 1];
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment