diff --git a/CHANGELOG.md b/CHANGELOG.md index f1ca7b5e3a12a19741b089e91ba002f11142e48e..97777090da02f277081e07409d6324b69cf09fb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +### v0.3.3 ### +**Utilities - Generic**\ +\* Change the interface of `rotMat3d()`, so that the last argument is a boolean (`logical` in MATLAB), declaring whether the given angles are in degrees (if false, the angles are treated as radians). This is a **backwards incompatible** change.\ +\* The following functions are changed internally to apply the changes in `rotMat3d()`: + - `rcvGeo()` + - `srcGeo()` + - `virtMicGeo()` + +------------------------------------------- + + ### v0.3.2 ### **Signal Processing - Generic**\ \+ Add option to use negative delay values with the `winSincFracDel()` function. diff --git a/README.md b/README.md index ebfbdb5b133d31b2cf27b1c82c084c45c81a5745..1586033c44afc05f7d241cce3c3abe2c95d7bd8b 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,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.3.2**. The project hasn't reached v1.0.0 yet so changes that break backwards compatibility may (and have been) introduced in any version update. For information about the changes in each version consult the [CHANGELOG](https://gitlab.com/in-nova/in-nova/-/blob/main/CHANGELOG.md?ref_type=heads). +The project uses [semantic versioning](https://semver.org/) and the current version is **v0.3.3**. The project hasn't reached v1.0.0 yet so changes that break backwards compatibility may (and have been) introduced in any version update. For information about the changes in each version consult the [CHANGELOG](https://gitlab.com/in-nova/in-nova/-/blob/main/CHANGELOG.md?ref_type=heads). #### **Important** diff --git a/Signal Processing/Array Processing/MATLAB/Functions/arrManTD.m b/Signal Processing/Array Processing/MATLAB/Functions/arrManTD.m new file mode 100644 index 0000000000000000000000000000000000000000..81d5499878b1c8568441127becc34ad1fe67987c --- /dev/null +++ b/Signal Processing/Array Processing/MATLAB/Functions/arrManTD.m @@ -0,0 +1,189 @@ +%% Time-domain array manifold (steering vector) +% -------------------------------------------------- +% Author: Achilles Kappis +% e-mail: axilleaz@protonmail.com +% +% Date: 02/11/2024 (DD/MM/YYYY) +% +% Copyright: MIT +% -------------------------------------------------- +% Functionality: Calculate the time-domain equivalent of the array manifold +% (steering vector) of an arbitrary array. +% -------------------------------------------------- +% Input +% +% mPos [numeric]: The positions of the sensors in Cartesian coordinates. +% This must be an 3xM matrix where M denotes the number of +% sensors and for each sensor the coordinates are in +% [x; y; z] format. +% +% dirs [numeric]: These are the directions for which the array manifold +% will be calculated. This must be an 2xN matrix where N is +% the number of directions and for each direction the +% azimuth and elevation/inclination is given. The values +% must be provided in radians. The directions must be +% pointing towards the incoming plane waves and not towards +% the array/origin. +% +% filtLen [numeric]: This argument represents the length of the DMA filter +% if this function is used in the context of time-domain +% DMA filter design. In general, defines the number of +% rows the output array will have per direction. +% +% delLen [numeric] (Optional): The length of the (fractional) delay +% filters used to calculate the "array +% manifold" in samples. If this value is not +% large enough to accommodate the largest +% delay between the point of reference of +% the array (see notes) and the most distant +% sensor, the length of the filters is set +% automatically to that number (internal to +% the "winSincFracDel()" function - see +% dependencies). [Default: 16]. +% +% delWin [char/string/numeric] (Optional): The window that will be applied +% to the (fractional) delay +% filter. This can be +% "Rectangular", "Hann", "Hamming" +% or a positive scalar +% corresponding to the Kaiser +% alpha parameter. The string/char +% values are not case-sensitive. +% [Default: 3]. +% +% fs [numeric] (Optional): The sampling rate in Hz. This value is used to +% calculate the final length of the filters in the +% returned "array manifold" matrix (the number of +% columns) and "delLen" in case it is not +% provided. For the number of columns in the +% returned "array manifold" see the output +% arguments. [Default: 8e3]. +% +% c [numeric] (Optional): The speed of sound in m/s. [Default: 343]. +% +% -------------------------------------------------- +% Output +% +% am [numeric]: This is an LxKxMxN array, where L is equal to "filtLen", K +% is equal to filtLen + delLen + ceil(2 * max(abs(del))) +% where "del" is the delay between the sensors and the centre +% of mass of the array. M is the number of sensors and N is +% the number of directions. +% +% maxDel [numeric]: The maximum delay from the centre of mass to the +% sensors. +% +% amMtx [numeric]: This is an LMxKxN array, where LM is equal to L * M. +% This corresponds to the "vectorised" version of "am" +% with the "am" of each sensor stacked under each other. +% +% -------------------------------------------------- +% Notes +% +% - The point of reference for the array is its centre of mass and it is +% calculated internally with dimensions equal to the mean of each +% dimension over all the sensor positions. +% +% - The implementation is based on "First-Order Differential Microphone +% Arrays from a Time-Domain Broadband Perspective" by Buchris, Cohen and +% Benesty. +% +% - Dependencies: * winSincFracDel() to calculate the fractional delay +% filters. +% -------------------------------------------------- +function [am, maxDel, amMtx] = arrManTD(mPos, dirs, filtLen, delLen, delWin, fs, c) + % ==================================================== + % Check for number of arguments + % ==================================================== + narginchk(3, 7); + nargoutchk(0, 3); + + % ==================================================== + % Validate input arguments + % ==================================================== + % Validate mandatory arguments + validateattributes(mPos, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 3}, mfilename, "Position of sensors", 1); + validateattributes(dirs, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 2}, mfilename, "Directions of interest", 2); + validateattributes(filtLen, "numeric", {'scalar', 'finite', 'nonnan', 'nonempty', 'positive', 'real'}, mfilename, "Number of rows of the 'array manifold'", 3); + + % Optional arguments + if nargin > 3 && ~isempty(delLen) + validateattributes(delLen, "numeric", {'scalar', 'finite', 'nonnan', 'nonempty', 'positive', 'real'}, mfilename, "The length of the delay filters", 4); + else + delLen = 16; + end + + if nargin < 5 || (nargin > 4 && isempty(delWin)) + delWin = 3; + end + + if nargin > 5 && ~isempty(fs) + validateattributes(fs, "numeric", {'scalar', 'nonempty', 'nonnan', 'finite', 'positive', 'real'}, mfilename, "Sampling rate", 6); + else + fs = 8e3; + end + + if nargin > 6 && ~isempty(c) + validateattributes(c, "numeric", {'scalar', 'finite', 'nonempty', 'nonnan', 'positive', 'real'}, mfilename, "Speed of sound", 7); + else + c = 343; + end + + + % ============================================= + % Calculate delays and filters + % ============================================= + % Set the centre of mass to the origin + mPos = mPos - mean(mPos, 2); + + % Get Cartesian coordinates of unit vectors pointing in angle directions + [x, y, z] = sph2cart(dirs(1, :), dirs(2, :), ones(size(dirs(1, :)))); + + % Calculate each sensor's delay with respect to the centre of mass in samples + del = -[x; y; z].' * fs * mPos/c; + + % Calculate the total length of the filters + maxDel = max(abs(del), [], "all"); + delLen = ceil(delLen + 2 * maxDel); + + % Get the delay filters + for angIdx = size(del, 1):-1:1 + for mIdx = size(del, 2):-1:1 + h(:, mIdx, angIdx) = winSincFracDel(del(angIdx, mIdx), delLen, delWin); + end + end + + + % ============================================= + % Form Sylvester matrices + % ============================================= + % Turn warnings about the generation of Toeplitz matrices off + w = warning("off", "MATLAB:toeplitz:DiagonalConflict"); + + try + % Generate Sylvester matrices for each mic and angle + for angIdx = size(h, 3):-1:1 + for mIdx = size(h, 2):-1:1 + am(:, :, mIdx, angIdx) = toeplitz([h(:, mIdx, angIdx); zeros(filtLen - 1, 1)], zeros(filtLen, 1)).'; + end + end + catch + % Make sure to turn the warnings on again if an error occurs + warning(w.state, w.identifier); + end + + % Reset the warnings state + warning(w.state, w.identifier); + + + % ============================================= + % Return additional output arguments + % ============================================= + if nargout > 1 + maxDel = ceil(maxDel); + end + + if nargout > 2 + amMtx = reshape(permute(am, [1, 3, 2, 4]), [], size(am, 2), size(am, 4)); + end +end \ No newline at end of file diff --git a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDMA.m b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m similarity index 82% rename from Signal Processing/Array Processing/MATLAB/Functions/firstOrderDMA.m rename to Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m index fdcd0781e759d54e9c7f976eb29338ba224bf55b..f31cdb6109f79086f2ed2996f168a1a64cbe1c9b 100644 --- a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDMA.m +++ b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 29/09/2024 (DD/MM/YYYY) +% Date: 05/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -13,19 +13,18 @@ % Input % % input [numeric]: The input to the array. 3D array/matrix with dimensions -% IxMxF, where I is the number of measurments (or length -% of signals), M represents the number of microphones and -% must be even and F is the number of frequencies of -% interest. Each pair microphone is treated as a first +% MxIxF, where M represents the number of microphones and +% must be even, I is the number of measurments (or number +% of sources), and F is the number of frequencies of +% interest. Each microphone pair is treated as a first % order DMA. % % freq [numeric]: The frequencies of interest. A vector with number of % elements matching the third dimension of the "input" % parameter. % -% pos [numeric]: The position vectors of the DMA elements. This must be a -% 3xM matrix whose rows will represent the Cartesian -% coordinates and the columns the DMA elements. +% d [numeric]: The inter-element distance of the microphone pairs. This +% must be a real scalar. % % pPattern [string/char/numeric] (Optional): The sought out beam-pattern. % It can be either a string (or @@ -54,28 +53,24 @@ % -------------------------------------------------- % Output % +% h [numeric]: This 2xF filter is the filter that results in the +% beam-pattern of interest and F is the number of frequencies. +% % output [numeric]: The output of the array. It has the same dimensions as % the "input" parameter except for the second dimension % which is equal to M/2. % -% h [numeric]: This 2xF filter is the filter that results in the -% beam-pattern of interest and F is the number of frequencies. -% % -------------------------------------------------- % Notes % % -------------------------------------------------- -function [output, h] = firstOrderDMA(input, freq, d, pPattern, beta) +function [h, output] = firstOrderDma(input, freq, d, pPattern, beta) % ==================================================== % Check for number of arguments % ==================================================== narginchk(3, 5); - nargoutchk(0, 4); + nargoutchk(0, 2); - % If no output arguments bail (no need to calculate) - if nargout == 0 - return; - end % ==================================================== % Validate input arguments @@ -148,19 +143,21 @@ function [output, h] = firstOrderDMA(input, freq, d, pPattern, beta) % Calculate filter(s) for freqIdx = length(freq):-1:1 - arrManMat = [arrMan(0, d, freq(freqIdx), 343), arrMan(pPattern, d, freq(freqIdx), 343)]; - h(:, freqIdx) = (arrManMat')\[1; beta]; + arrManLocMtx = [arrManLoc(0, d, freq(freqIdx), 343), arrManLoc(pPattern, d, freq(freqIdx), 343)]; + h(:, freqIdx) = (arrManLocMtx')\[1; beta]; end % ==================================================== % Calculate array output % ==================================================== - % Go through the frequencies - for freqIdx = length(freq):-1:1 - for pairIdx = size(input, 1)/2:-1:1 - % Multiply the array filter with the input - output(:, pairIdx, freqIdx) = h(:, freqIdx)' * input(:, pairIdx * 2 - 1:pairIdx * 2, freqIdx); + if nargout > 1 + % Go through the frequencies + for freqIdx = length(freq):-1:1 + for pairIdx = size(input, 1)/2:-1:1 + % Multiply the array filter with the input + output(pairIdx, :, freqIdx) = h(:, freqIdx)' * input(pairIdx * 2 - 1:pairIdx * 2, :, freqIdx); + end end end end @@ -168,7 +165,7 @@ end %% Utility functions % Calculate the array manifold -function arrMan = arrMan(phi, d, freq, c) +function am = arrManLoc(phi, d, freq, c) k = -2j * pi * freq * cos(phi)/c; - arrMan = [exp(k * (-d/2)); exp(k * (d/2))]; + am = [exp(k * (-d/2)); exp(k * (d/2))]; end \ No newline at end of file diff --git a/Signal Processing/Generic/MATLAB/Functions/winSincFracDel.m b/Signal Processing/Generic/MATLAB/Functions/winSincFracDel.m index 06dcabd40037e6b79405f5a1082557c319c370bc..88a13ba5a6301d92ea36cd2972b1321988fb9da6 100644 --- a/Signal Processing/Generic/MATLAB/Functions/winSincFracDel.m +++ b/Signal Processing/Generic/MATLAB/Functions/winSincFracDel.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 05/10/2024 (DD/MM/YYYY) +% Date: 21/10/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -86,7 +86,6 @@ function [sincFilt, causDel, dSig] = winSincFracDel(del, len, winFun, sig, sigLe % Validate input arguments % ==================================================== % Validate mandatory arguments - % validateattributes(del, "numeric", {'scalar', 'real', 'nonnegative', 'nonnan', 'nonempty', 'finite'}, mfilename, "Delay in samples", 1); validateattributes(del, "numeric", {'scalar', 'real', 'nonnan', 'nonempty', 'finite'}, mfilename, "Delay in samples", 1); % Validate optional arguments @@ -175,11 +174,10 @@ function [sincFilt, causDel, dSig] = winSincFracDel(del, len, winFun, sig, sigLe sincFilt = sincFilt(:); % Add the integral delay - % sincFilt = [zeros(1, fix(del)), sincFilt(1:end - fix(del))]; if del >= 0 sincFilt = [zeros(fix(del), 1); sincFilt(1:end - fix(del))]; else - sincFilt = [sincFilt(abs(floor(del)):end); zeros(abs(floor(del)), 1)]; + sincFilt = [sincFilt(abs(floor(del)):end); zeros(abs(fix(del)), 1)]; end diff --git a/Signal Processing/Measurements/MATLAB/Functions/invSweep.m b/Signal Processing/Measurements/MATLAB/Functions/invSweep.m index 82a8bd369dac4f7673b7cab18f5f026d92a6465a..5acaaf77f254e443290fda552d146fe76e65aaf7 100755 --- a/Signal Processing/Measurements/MATLAB/Functions/invSweep.m +++ b/Signal Processing/Measurements/MATLAB/Functions/invSweep.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 21/09/2024 (DD/MM/YYYY) +% Date: 07/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -150,7 +150,7 @@ function [invFiltFd, fr, ir, causIr, invFiltTd] = invSweep(rec, ref, equalise, r end else if ~isnan(fs) - causIrLen = floor(causIrLen * fs); + causIrLen = floor(size(rec, 1) * fs); else causIrLen = size(rec, 1); end diff --git a/Utilities/Generic/MATLAB/Functions/getColour.m b/Utilities/Generic/MATLAB/Functions/getColour.m index 5ae50ca2ebe368e63dcf88cc4d98a5d703a81ede..ef7cd2eb43834e35ebf1e06c147345b0af1e9017 100644 --- a/Utilities/Generic/MATLAB/Functions/getColour.m +++ b/Utilities/Generic/MATLAB/Functions/getColour.m @@ -3,9 +3,9 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 07/03/2024 (DD/MM/YYYY) +% Date: 10/11/2024 (DD/MM/YYYY) % -% Copyright: Unlicenced +% Copyright: MIT % -------------------------------------------------- % Functionality: Get MATLAB's colours in RGB array % -------------------------------------------------- @@ -13,12 +13,13 @@ % % colour [numeric/string]: The colour to be returned. Numerical values % correspond to "blue", "orange", "yellow", -% "purple", "green", "mustard" and "grey" from 1 -% to 7. Values other than those will result in an -% error. Decimal values will be rounded to the -% nearest integer. The string values accepted are -% those corresponding to the numerical values and -% are not case sensitive. +% "purple", "green", "mustard", "grey", and a +% "kind of burgundy" from 1 to 8. Values other +% than those will result in an error. Decimal +% values will be rounded to the nearest integer. +% The string values accepted are those +% corresponding to the numerical values and are +% not case sensitive. % % -------------------------------------------------- % Output @@ -69,6 +70,8 @@ function rgb = getColour(colour) rgb = rgb(3 * end/4, :); elseif (colour == 7 || strcmpi(colour, "grey")) rgb = [0.5, 0.5, 0.5]; + elseif (colour == 8) || strcmpi(colour, "burgundy") + rgb = [0.5, 0.1, 0.2]; else error("Colour must be either a number from 1 to 4 or one of: 'blue', 'orange', 'yellow', 'purple'") end \ No newline at end of file diff --git a/Utilities/Generic/MATLAB/Functions/rotMat3d.m b/Utilities/Generic/MATLAB/Functions/rotMat3d.m index c4f9d2f2cec1124b71af61fdda5752be2dd054f9..ed0ee2efe67fb48fa0e8b24139498899849ccf56 100644 --- a/Utilities/Generic/MATLAB/Functions/rotMat3d.m +++ b/Utilities/Generic/MATLAB/Functions/rotMat3d.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 28/09/2024 (DD/MM/YYYY) +% Date: 14/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -27,11 +27,10 @@ % the rotation matrix and "v" a vector to % be rotated). [Default: "xyz"]. % -% radDeg [chat/string] (Optional): This value declares if the provided -% angles are in radians or degrees. It can -% have one of the following values and is -% not case sensitive: "Degs", "Degrees", -% "Rads", "Radians". [Default: "Rads"]. +% deg [logical] (Optional): This value declares if the provided angles are +% in radians or degrees. If it is true, the +% values are treated as degrees. +% [Default: false]. % -------------------------------------------------- % Output % @@ -49,7 +48,7 @@ % Notes % % -------------------------------------------------- -function [rotMat, xRotMat, yRotMat, zRotMat] = rotMat3d(xAng, yAng, zAng, rotSeq, radDeg) +function [rotMat, xRotMat, yRotMat, zRotMat] = rotMat3d(xAng, yAng, zAng, rotOrd, deg) % ==================================================== % Check for number of arguments % ==================================================== @@ -75,25 +74,24 @@ function [rotMat, xRotMat, yRotMat, zRotMat] = rotMat3d(xAng, yAng, zAng, rotSeq zAng = 0; end - if nargin > 4 && ~isempty(rotSeq) - validateattributes(rotSeq, {'char', 'string'}, {'scalartext'}, mfilename, "The sequence of the rotations", 4); - validatestring(rotSeq, join(perms(["x", "y", "z"]), ""), mfilename, "The sequence of the rotations", 4); + if nargin > 4 && ~isempty(rotOrd) + validateattributes(rotOrd, {'char', 'string'}, {'scalartext'}, mfilename, "The sequence of the rotations", 4); + validatestring(rotOrd, join(perms(["x", "y", "z"]), ""), mfilename, "The sequence of the rotations", 4); else - rotSeq = "xyz"; + rotOrd = "xyz"; end - if nargin > 4 && ~isempty(radDeg) - validateattributes(radDeg, {'char', 'string'}, {'scalartext'}, mfilename, "The 'type' of the provided angle values (radians or degrees)", 5); - validatestring(radDeg, ["Rads", "Radians", "Degs", "Degrees"], mfilename, "The 'type' of the provided angle values (radians or degrees)", 5); + if nargin > 4 && ~isempty(deg) + validateattributes(deg, "logical", {'scalar', 'nonempty', 'binary', 'real', 'finite', 'nonnan'}, mfilename, "Flag declaring whether the provided angle values are in degrees", 5); else - radDeg = "Rads"; + deg = false; end % ==================================================== % Pre-process angle values % ==================================================== - if sum(strcmpi(radDeg, ["Degs", "Degrees"])) > 0 + if deg xAng = deg2rad(xAng); yAng = deg2rad(yAng); zAng = deg2rad(zAng); @@ -121,8 +119,8 @@ function [rotMat, xRotMat, yRotMat, zRotMat] = rotMat3d(xAng, yAng, zAng, rotSeq % Create rotation matrix based on the sequency provided rotMat = cat(3, xRotMat, yRotMat, zRotMat); - rotSeq = split(rotSeq, ""); rotSeq(rotSeq == "") = []; - [~, idx] = sort(rotSeq); [~, idx] = sort(idx, "descend"); + rotOrd = split(rotOrd, ""); rotOrd(rotOrd == "") = []; + [~, idx] = sort(rotOrd); [~, idx] = sort(idx, "descend"); rotMat = rotMat(:, :, idx(1)) * rotMat(:, :, idx(2)) * rotMat(:, :, idx(3)); end diff --git a/Utilities/Geometries/MATLAB/Functions/rcvGeo.m b/Utilities/Geometries/MATLAB/Functions/rcvGeo.m index a9f4d80cfc86e9f74318d55995cecb8d0d7739fe..514a470cbd0ae7022b070cebf85a5820f9ca16bf 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: 29/09/2024 (DD/MM/YYYY) +% Date: 14/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -339,7 +339,7 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triVec, b end % Rotate and position - tetPos(:, measPosIdx, :) = omniPos(:, measPosIdx) + rotMat3d(0, 0, tetRot, [], "Degs") * tmpPos; + tetPos(:, measPosIdx, :) = omniPos(:, measPosIdx) + rotMat3d(0, 0, tetRot, [], true) * tmpPos; end case "uca" % Get the angle of the positions on the circle @@ -347,10 +347,10 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triVec, b % Rotate and position tetrahedrals for measPosIdx = numel(az):-1:1 - tetPos(:, measPosIdx, :) = omniPos(:, measPosIdx) + rotMat3d(0, 0, az(measPosIdx), [], "Degs") * tmpPos; + tetPos(:, measPosIdx, :) = omniPos(:, measPosIdx) + rotMat3d(0, 0, az(measPosIdx), [], true) * tmpPos; end case "single" - tetPos = omniPos + rotMat3d(30, 30, 0, [], "Degs") * tmpPos; + tetPos = omniPos + rotMat3d(30, 30, 0, [], true) * tmpPos; end end @@ -358,32 +358,32 @@ function [omniPos, fig8Pos, triPos, boxPos, box2DPos, tetPos, fig8Vec, triVec, b % Translate and rotate geometries % ==================================================== for mIdx = size(omniPos, 3):-1:1 - omniPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * omniPos(:, :, mIdx) + trans(:); + omniPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * omniPos(:, :, mIdx) + trans(:); end if exist("fig8Pos", "var") for mIdx = size(fig8Pos, 3):-1:1 - fig8Pos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * fig8Pos(:, :, mIdx) + trans(:); + fig8Pos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * fig8Pos(:, :, mIdx) + trans(:); end for mIdx = size(triPos, 3):-1:1 - triPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * triPos(:, :, mIdx) + trans(:); + triPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * triPos(:, :, mIdx) + trans(:); end for mIdx = size(boxPos, 4):-1:1 for mmIdx = size(boxPos, 3):-1:1 - boxPos(:, :, mmIdx, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * boxPos(:, :, mmIdx, mIdx) + trans(:); + boxPos(:, :, mmIdx, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * boxPos(:, :, mmIdx, mIdx) + trans(:); end end for mIdx = size(box2DPos, 4):-1:1 for mmIdx = size(box2DPos, 3):-1:1 - box2DPos(:, :, mmIdx, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * box2DPos(:, :, mmIdx, mIdx) + trans(:); + box2DPos(:, :, mmIdx, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * box2DPos(:, :, mmIdx, mIdx) + trans(:); end end for mIdx = size(tetPos, 3):-1:1 - tetPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * tetPos(:, :, mIdx) + trans(:); + tetPos(:, :, mIdx) = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * tetPos(:, :, mIdx) + trans(:); end % ==================================================== diff --git a/Utilities/Geometries/MATLAB/Functions/srcGeo.m b/Utilities/Geometries/MATLAB/Functions/srcGeo.m index b4be6e5643b07c065268bb84454191ac53b5b036..c89fcb2695b649343ba7f7897146ef8ceb0568a0 100644 --- a/Utilities/Geometries/MATLAB/Functions/srcGeo.m +++ b/Utilities/Geometries/MATLAB/Functions/srcGeo.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 29/09/2024 (DD/MM/YYYY) +% Date: 14/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -195,11 +195,11 @@ function [sPos, Q, domIdx] = srcGeo(gType, srcLen, originDist, ang, nSrc, azim, if nSrc ~= 0 switch lower(gType) case {"anti-causal", "anticausal"} - sPos = rotMat3d(0, 0, 180, [], "Degs") * sPos; % Rotate 180 degrees (anti-clockwise) + sPos = rotMat3d(0, 0, 180, [], true) * sPos; % Rotate 180 degrees (anti-clockwise) case "side" - sPos = rotMat3d(0, 0, 90, [], "Degs") * sPos; % Rotate 90 degrees (anti-clockwise) + sPos = rotMat3d(0, 0, 90, [], true) * sPos; % Rotate 90 degrees (anti-clockwise) case "diagonal" - sPos = rotMat3d(0, 0, -90 + ang, [], "Degs") * sPos; % Rotate specified degrees (anti-clockwise) + sPos = rotMat3d(0, 0, -90 + ang, [], true) * sPos; % Rotate specified degrees (anti-clockwise) end end domIdx = []; diff --git a/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m b/Utilities/Geometries/MATLAB/Functions/virtMicGeo.m index c347a97177a89f2180725bf16d779fc44e89971b..3159cfe3cd25b39bb2489b4711c30a9be8fb87a3 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: 10/10/2024 (DD/MM/YYYY) +% Date: 14/11/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -194,7 +194,7 @@ function [vPos, vPosMesh] = virtMicGeo(gType, geoDim, nSens, trans, rot, rotOrd) end % Rotate and translate - vPos = rotMat3d(rot(1), rot(2), rot(3), rotOrd, "Degs") * vPos + trans(:); + vPos = rotMat3d(rot(1), rot(2), rot(3), rotOrd, true) * vPos + trans(:); % For "Cube" geometry provide the coordinates in a "mesh format" if nargout > 1 && strcmpi(gType, "Cube")