diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c36569c5adf3bd2c8601efb7d2b2c1cca1fee78..f77ffd995af7211a362aadb3b40a50bc518a9ff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### v0.2.5 ### +**Utilities - Geometries**\ +\* Combine translation offsets to a single vector input argument for the `rcvGeo()` MATLAB function.\ +\* Combine translation offsets to a single vector input argument for th `virtMicGeo()` MATLAB function.\ + + ### v0.2.4 ### **Virtual Sensing**\ \* Corrected time-domain observation filter calculations.\ diff --git a/README.md b/README.md index 8a3cb464712ce6e3f6322573fa503d59f17db195..f50c20acb4b575f586b0a7d0524126538d508d20 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ The project is licensed under the ***MIT License***, which is a rather unrestric ## Versioning ## -The project uses [semantic versioning](https://semver.org/) and the current version is **v0.2.4**. +The project uses [semantic versioning](https://semver.org/) and the current version is **v0.2.5**. #### **Important** diff --git a/Utilities/Geometries/MATLAB/Functions/rcvGeo.m b/Utilities/Geometries/MATLAB/Functions/rcvGeo.m index f7c7bb7427f2874674e08f9b1990ad49129584b4..ade8e9f7e206202445a15db4cc99aa502edffd19 100644 --- a/Utilities/Geometries/MATLAB/Functions/rcvGeo.m +++ b/Utilities/Geometries/MATLAB/Functions/rcvGeo.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 30/07/2024 (DD/MM/YYYY) +% Date: 20/09/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -45,14 +45,10 @@ % respective output variables are % empty. [Default: 0.05]. % -% xOff [numeric] (Optional): An offset along the x-axis of the microphone -% configuration. [Default: 0]. -% -% yOff [numeric] (Optional): An offset along the y-axis of the microphone -% configuration. [Default: 0]. -% -% zOff [numeric] (Optional): An offset along the z-axis of the microphone -% configuration. [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)]. % % -------------------------------------------------- % Output @@ -222,11 +218,11 @@ % - Dependencies: rotMat3d() to rotate the configurations % % -------------------------------------------------- -function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triangleVec, boxVec, box2DVec, tetVec] = rcvGeo(gType, nSens, elemDist, dmaElemDist, xOff, yOff, zOff) +function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triangleVec, boxVec, box2DVec, tetVec] = rcvGeo(gType, nSens, elemDist, dmaElemDist, trans) % ==================================================== % Check for number of arguments % ==================================================== - narginchk(1, 7); + narginchk(1, 5); nargoutchk(0, 11); % ==================================================== @@ -237,22 +233,10 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triangleV validatestring(gType, ["Single", "ULA", "UCA", "Log"], mfilename, "Geometry type", 1); % Validate optional arguments - if nargin > 6 && ~isempty(zOff) - validateattributes(zOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "Z offset of the microphone setup", 7); - else - zOff = 0; - end - - if nargin > 5 && ~isempty(yOff) - validateattributes(yOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "Y offset of the microphone setup", 6); - else - yOff = 0; - end - - if nargin > 4 && ~isempty(xOff) - validateattributes(xOff, "numeric", {'scalar', 'real', 'nonnan', 'finite'}, mfilename, "X offset of the microphone setup", 5); + if nargin > 4 && ~isempty(trans) + validateattributes(trans, "numeric", {'vector', 'real', 'nonnan', 'finite', 'nonempty', 'numel', 3}, mfilename, "The translation of the the geometry", 7); else - xOff = 0; + trans = zeros(3, 1); end if nargin > 3 && ~isempty(dmaElemDist) @@ -303,7 +287,7 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triangleV % Translate if nargout > 0 - omniPos = omniPos + [xOff, yOff, zOff]; + omniPos = omniPos + trans(:).'; end return; end @@ -408,29 +392,12 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triangleV % ==================================================== % Translate geometries % ==================================================== - if nargout > 0 - omniPos = omniPos + [xOff, yOff, zOff]; - end - - if nargout > 1 - fig8Pos = fig8Pos + [xOff, yOff, zOff]; - end - - if nargout > 2 - triPos = triPos + [xOff, yOff, zOff]; - end - - if nargout > 3 - boxPos = boxPos + [xOff, yOff, zOff]; - end - - if nargout > 4 - box2DPos = box2DPos + [xOff, yOff, zOff]; - end - - if nargout > 5 - tetPos = tetPos + [xOff, yOff, zOff]; - end + omniPos = omniPos + trans(:).'; + fig8Pos = fig8Pos + trans(:).'; + triPos = triPos + trans(:).'; + boxPos = boxPos + trans(:).'; + box2DPos = box2DPos + trans(:).'; + tetPos = tetPos + trans(:).'; % Provide a Nx3 "Figure-of-Eight" matrix if nargout > 6 diff --git a/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m b/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m index b6947bea4181865388d190d9d660bc204e60f0d9..3078cc4e5e9778981ebca8442d2c56adb9315e8d 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")