From 07ea1166416a7d4385c2cee114d5626f81d8f2b3 Mon Sep 17 00:00:00 2001
From: ZaellixA <axilleaz@protonmail.com>
Date: Fri, 20 Sep 2024 14:15:24 +0100
Subject: [PATCH] Combine offset input arguments to a single translation vector
 and change variable name for the rotation/orientation of the geometries

---
 .../Geometries/MATLAB/Functions/virtMicGeo.m  | 53 +++++++------------
 1 file changed, 20 insertions(+), 33 deletions(-)

diff --git a/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m b/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m
index b6947be..3078cc4 100644
--- a/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m
+++ b/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m
@@ -3,7 +3,7 @@
 % Author: Achilles Kappis
 % e-mail: axilleaz@protonmail.com
 %
-% Date: 18/09/2024 (DD/MM/YYYY)
+% Date: 20/09/2024 (DD/MM/YYYY)
 %
 % Copyright: MIT
 % --------------------------------------------------
@@ -43,16 +43,15 @@
 %                              geometry the argument is ignored.
 %                              [Default: 10 * ones(3, 1)].
 % 
-% xOff [numeric] (Optional): X-axis offset. [Default: 0].
+% trans [numeric] (Optional): This is a real vector with three elements,
+%                             representing the translation of the geometry
+%                             along the Cartesian axes.
+%                             [Default: zeros(3, 1)].
 % 
-% yOff [numeric] (Optional): Y-axis offset. [Default: 0].
-% 
-% zOff [numeric] (Optional): Z-axis offset. [Default: 0].
-% 
-% orient [numeric] (Optional): This is a real vector holding the rotation
-%                              for the geometry in degrees, along each
-%                              Cartesian axis. The rotations are performed
-%                              clockwise. [Default: zeros(3, 1)].
+% rot [numeric] (Optional): This is a real vector holding the rotation for
+%                           the geometry in degrees, along each Cartesian
+%                           axis. The rotations are performed clockwise.
+%                           [Default: zeros(3, 1)].
 % 
 % --------------------------------------------------
 % Output
@@ -81,11 +80,11 @@
 %   setup is one dimensional.
 % 
 % --------------------------------------------------
-function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, orient)
+function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, trans, rot)
     % ====================================================
     % Check for number of arguments
     % ====================================================
-    narginchk(1, 7);
+    narginchk(1, 5);
     nargoutchk(0, 2);
 
     % ====================================================
@@ -97,7 +96,7 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
 
     % Validate optional arguments
     if nargin > 1 && ~isempty(geoDim) && ~strcmpi(gType, "Single")
-        validateattributes(geoDim, "numeric", {'vector', 'real', 'nonnan', 'finite', 'nonempty', 'positive'}, mfilename, "Geometry dimensions", 2);
+        validateattributes(geoDim, "numeric", {'vector', 'real', 'nonnan', 'finite', 'nonempty', 'nonnegative'}, mfilename, "Geometry dimensions", 2);
         
         if numel(geoDim) > 3 || numel(geoDim) == 2
             error("The dimensions argument must be either a scalar or a vector with three elements");
@@ -130,28 +129,16 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
         nSens = 10 * ones(3, 1);
     end
 
-    if nargin > 3 && ~isempty(xOff)
-        validateattributes(xOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "X-offset", 4);
-    else
-        xOff = 0;
-    end
-
-    if nargin > 4 && ~isempty(yOff)
-        validateattributes(yOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "Y-offset", 5);
-    else
-        yOff = 0;
-    end
-
-    if nargin > 5 && ~isempty(zOff)
-        validateattributes(zOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "Z-offset", 6);
+    if nargin > 3 && ~isempty(trans)
+        validateattributes(trans, "numeric", {'vector', 'real', 'nonnan', 'finite', 'nonempty', 'numel', 3}, mfilename, "Translation of the geometry", 4);
     else
-        zOff = 0;
+        trans = zeros(3, 1);
     end
 
-    if nargin > 6 && ~isempty(orient) && ~strcmpi(gType, "Single")
-        validateattributes(orient, {'numeric'}, {'vector', 'nonempty', 'nonnan', 'finite', 'real', 'numel', 3}, mfilename, "Geometry rotation around the Cartesian axes", 7);
+    if nargin > 4 && ~isempty(rot) && ~strcmpi(gType, "Single")
+        validateattributes(rot, {'numeric'}, {'vector', 'nonempty', 'nonnan', 'finite', 'real', 'numel', 3}, mfilename, "Geometry rotation around the Cartesian axes", 5);
     else
-        orient = zeros(3, 1);
+        rot = zeros(3, 1);
     end
 
 
@@ -195,10 +182,10 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
     end
 
     % Rotate
-    vPos = vPos * rotMat3d(-orient(1), -orient(2), -orient(3), "Degs");
+    vPos = vPos * rotMat3d(-rot(1), -rot(2), -rot(3), "Degs");
 
     % Translate
-    vPos = vPos + [xOff, yOff, zOff];
+    vPos = vPos + trans(:).';
 
     % For "Cube" geometry provide the coordinates in a "mesh format"
     if nargout > 1 && strcmpi(gType, "Cube")
-- 
GitLab