Skip to content
Snippets Groups Projects
Commit 07ea1166 authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Combine offset input arguments to a single translation vector and change...

Combine offset input arguments to a single translation vector and change variable name for the rotation/orientation of the geometries
parent a966eca0
No related branches found
No related tags found
1 merge request!5Update geometry generation functions
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
% Author: Achilles Kappis % Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com % e-mail: axilleaz@protonmail.com
% %
% Date: 18/09/2024 (DD/MM/YYYY) % Date: 20/09/2024 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -43,16 +43,15 @@ ...@@ -43,16 +43,15 @@
% geometry the argument is ignored. % geometry the argument is ignored.
% [Default: 10 * ones(3, 1)]. % [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]. % rot [numeric] (Optional): This is a real vector holding the rotation for
% % the geometry in degrees, along each Cartesian
% zOff [numeric] (Optional): Z-axis offset. [Default: 0]. % axis. The rotations are performed clockwise.
% % [Default: zeros(3, 1)].
% 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)].
% %
% -------------------------------------------------- % --------------------------------------------------
% Output % Output
...@@ -81,11 +80,11 @@ ...@@ -81,11 +80,11 @@
% setup is one dimensional. % 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 % Check for number of arguments
% ==================================================== % ====================================================
narginchk(1, 7); narginchk(1, 5);
nargoutchk(0, 2); nargoutchk(0, 2);
% ==================================================== % ====================================================
...@@ -97,7 +96,7 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o ...@@ -97,7 +96,7 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
% Validate optional arguments % Validate optional arguments
if nargin > 1 && ~isempty(geoDim) && ~strcmpi(gType, "Single") 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 if numel(geoDim) > 3 || numel(geoDim) == 2
error("The dimensions argument must be either a scalar or a vector with three elements"); 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 ...@@ -130,28 +129,16 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
nSens = 10 * ones(3, 1); nSens = 10 * ones(3, 1);
end end
if nargin > 3 && ~isempty(xOff) if nargin > 3 && ~isempty(trans)
validateattributes(xOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "X-offset", 4); validateattributes(trans, "numeric", {'vector', 'real', 'nonnan', 'finite', 'nonempty', 'numel', 3}, mfilename, "Translation of the geometry", 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);
else else
zOff = 0; trans = zeros(3, 1);
end end
if nargin > 6 && ~isempty(orient) && ~strcmpi(gType, "Single") if nargin > 4 && ~isempty(rot) && ~strcmpi(gType, "Single")
validateattributes(orient, {'numeric'}, {'vector', 'nonempty', 'nonnan', 'finite', 'real', 'numel', 3}, mfilename, "Geometry rotation around the Cartesian axes", 7); validateattributes(rot, {'numeric'}, {'vector', 'nonempty', 'nonnan', 'finite', 'real', 'numel', 3}, mfilename, "Geometry rotation around the Cartesian axes", 5);
else else
orient = zeros(3, 1); rot = zeros(3, 1);
end end
...@@ -195,10 +182,10 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o ...@@ -195,10 +182,10 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, xOff, yOff, zOff, o
end end
% Rotate % Rotate
vPos = vPos * rotMat3d(-orient(1), -orient(2), -orient(3), "Degs"); vPos = vPos * rotMat3d(-rot(1), -rot(2), -rot(3), "Degs");
% Translate % Translate
vPos = vPos + [xOff, yOff, zOff]; vPos = vPos + trans(:).';
% For "Cube" geometry provide the coordinates in a "mesh format" % For "Cube" geometry provide the coordinates in a "mesh format"
if nargout > 1 && strcmpi(gType, "Cube") if nargout > 1 && strcmpi(gType, "Cube")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment