From 2238e00981e1466033ce4a565420cd1e1500502e Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Thu, 14 Dec 2023 10:57:04 +0100
Subject: [PATCH] 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.
---
 src/utils/rotx.m | 35 +++++++++++++++++++++++++++++++++++
 src/utils/roty.m | 35 +++++++++++++++++++++++++++++++++++
 src/utils/rotz.m | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 src/utils/rotx.m
 create mode 100644 src/utils/roty.m
 create mode 100644 src/utils/rotz.m

diff --git a/src/utils/rotx.m b/src/utils/rotx.m
new file mode 100644
index 0000000..e1d2216
--- /dev/null
+++ b/src/utils/rotx.m
@@ -0,0 +1,35 @@
+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
diff --git a/src/utils/roty.m b/src/utils/roty.m
new file mode 100644
index 0000000..a33e77d
--- /dev/null
+++ b/src/utils/roty.m
@@ -0,0 +1,35 @@
+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
diff --git a/src/utils/rotz.m b/src/utils/rotz.m
new file mode 100644
index 0000000..11b19be
--- /dev/null
+++ b/src/utils/rotz.m
@@ -0,0 +1,35 @@
+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
-- 
GitLab