diff --git a/applications/SphericalHarmonics/ita_isht.m b/applications/SphericalHarmonics/ita_isht.m deleted file mode 100644 index 797bce77d111fae665046fd57cafd0d7b4034f39..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_isht.m +++ /dev/null @@ -1,29 +0,0 @@ -function acData = ita_isht(acDataSH, gridData) -%ITA_ISHT - performs an inverse Spherical Harmonic transform on spherical data struct - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% Author: Martin Pollow -- Email: mpo@akustik.rwth-aachen.de -% Created: 03-Dec-2008 - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -acData = cell(size(acDataSH)); - -for n = 1:numel(acDataSH) - acData{n}.header = acDataSH{n}.header; - % TODO: neue EInheit - if isfield(acDataSH{n},'dat_SH') - oldFieldname = 'dat_SH'; - newFieldname = 'dat'; - elseif isfield(acDataSH{n},'spk_SH') - oldFieldname = 'spk_SH'; - newFieldname = 'spk'; - end - - acData{n}.(newFieldname) = ita_sph_ISHT(acDataSH{n}.(oldFieldname), gridData); -end \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_plot_SH.m b/applications/SphericalHarmonics/ita_plot_SH.m deleted file mode 100644 index 1e55587529500657e0d34d5553f94fbdb8126c11..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_plot_SH.m +++ /dev/null @@ -1,60 +0,0 @@ -function ita_plot_SH(coefs, sampling, varargin) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -global sPlotPoints; - -if nargin == 0, error; end; -if nargin > 1 - % check if is a plot grid - if ~isa(sampling,'itaCoordinates') - varargin = [{sampling} varargin]; - else - sPlotPoints = sampling; - end -end - -% create sampling for plot if necessary -if isempty(sPlotPoints) - sPlotPoints = ita_sph_sampling_equiangular(31); -end - -paraStruct = ita_sph_plot_parser(varargin); -% plottype = paraStruct.type; - -% convert to given spatial grid -data = ita_sph_ISHT(coefs, sPlotPoints); - -% call spatial plot function -[hFig, hSurf] = ita_sph_plot_spatial(data, sPlotPoints, varargin{:}); - -% now check if to plot dots also -colorSize = size(paraStruct.dotColor); -if colorSize(2) ~= 3 - % there must be color dots given - % so plot them on the sphere - radiusBalloon = abs(ita_sph_functionvalue(coefs, paraStruct.dotSampling)); - if strcmpi(paraStruct.type,'dB') - radiusBalloon = 20*log10(radiusBalloon); - end - % now set the radii - dotSampling_modifiedR = itaSamplingSph(paraStruct.dotSampling); - dotSampling_modifiedR.r = radiusBalloon; - - [magn, color, colorMap] = ita_sph_plot_type(paraStruct.dotColor, paraStruct.type); - - % set caxis - cminmax = caxis; - cmin = cminmax(1); - cmax = cminmax(2); - cmin = min(cmin, min(color)); - cmax = max(cmax, max(color)); - - ita_plot_dots(dotSampling_modifiedR, 'dotColor', color,'caxis', [cmin cmax]); -end - diff --git a/applications/SphericalHarmonics/ita_plot_balloon.m b/applications/SphericalHarmonics/ita_plot_balloon.m deleted file mode 100644 index 89e1d880f4e09fa555492228f801f0249eb6c5b8..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_plot_balloon.m +++ /dev/null @@ -1,141 +0,0 @@ -function [hFig, hSurf] = ita_plot_balloon(spatial_data, sampling, varargin) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% function [hFig, hSurf] = ita_sph_plot_spatial(data, sampling, varargin) -%ITA_SPH_PLOT_SPATIAL - plots a spatial spherical function (and sampling points) -% function ita_sph_plot_spatial(data, varargin) -% -% the optional parameter 'type' can be: -% 'complex' : radius is magnitude, color is phase -% 'sphere' : plots magnitude as color on unit sphere -% 'magnitude' : radius and color is magnitude -% 'spherephase' : plots phase as color on unit sphere -% -% the optional GeometryPoints and pointData give the information about -% spherical sampling points -% GeometryPoints.theta: vector of theta values -% GeometryPoints.phi: vector of phi values -% data: vector of sampling values -% -% type: default 'magnitude' -% GeometryPoints & pointData: default [] -% axes: outer/inner, different 'design' (default: outer) -% fontsize: default 12, for axis annotations - - -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 03.09.2008 -% Modified: 14.01.2009 - mpe - parameter-structure: -% Complete rewrite: July-09 - mpo - -% if nargin < 2 -% sampling = data; -% data = ones(size(sampling)); -% -% end - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -global sPlotPoints - -if nargin == 0, error; end; -if nargin > 1 - % check if is a plot grid - if ~isa(sampling,'itaCoordinates') - varargin = [{sampling} varargin]; - else - sPlotPoints = sampling; - end -end - -if isempty(sPlotPoints) - % use default: 64 x 64 equiangular grid (nmax = 31) - sPlotPoints = ita_sph_sampling_equiangular(31); -end - -paraStruct = ita_sph_plot_parser(varargin); -type = paraStruct.type; - -% get the values for the plot -[magn, color, colorMap] = ita_sph_plot_type(spatial_data,type); - -% reshape for use in plot -% sizeGrid = size(sampling.weights); -dim = sPlotPoints.dim; -magn = reshape(magn,dim); -color = reshape(color,dim); -theta = reshape(sPlotPoints.theta,dim); -phi = reshape(sPlotPoints.phi,dim); - -% add one vertical line of values to get a closed balloon -theta = theta(:,[1:end 1]); -phi = phi(:,[1:end 1]); -magn = magn(:,[1:end 1]); -color = color(:,[1:end 1]); - -% plot the balloon -[X,Y,Z] = sph2cart(phi, pi/2 - theta, magn); -% hFig = figure; -hFig = gcf; -set(hFig, 'renderer', 'opengl') -hSurf = surf(X,Y,Z,color, 'EdgeAlpha', paraStruct.edgealpha, 'FaceAlpha', paraStruct.facealpha); -colorbar; -colormap(colorMap); - -% set axes limits -maxMagn = max(max(magn)); -if maxMagn > 0 - xlim([-maxMagn maxMagn]); - ylim([-maxMagn maxMagn]); - zlim([-maxMagn maxMagn]); -end -daspect([1 1 1]); -axis vis3d - -% set colorbar settings -if ismember(type, {'complex','spherephase'}) - caxis([0 2*pi]); -else - caxis([0 maxMagn]); -end - -grid on; -% bigger and fatter fonts -set(gca, 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); -% set background color to white -set(gcf, 'Color', 'w'); -% view(90,0); -% view(3); -% view(0,90); -rotate3d; -xlabel('x'); -ylabel('y'); -zlabel('z'); - -switch paraStruct.axes - case 'inner'% alternative Achsen: - hold on; - maxim = max([max(max(abs(X))) max(max(abs(Y))) max(max(abs(Z)))]); - ak = [1.3*maxim -1.3*maxim]; nak = [0 0]; - [X0,Y0] = pol2cart(0:pi/180:2*pi,1.1*maxim); - [X1,Y1] = pol2cart(0:pi/180:2*pi,1.0*maxim); - [X2,Y2] = pol2cart(0:pi/180:2*pi,0.9*maxim); - [X3,Y3] = pol2cart(0:pi/180:2*pi,0.8*maxim); - [X4,Y4] = pol2cart(0:pi/180:2*pi,0.7*maxim); - Z0=zeros(1,361); - plot3(ak, nak, nak, 'k', nak, ak, nak, 'k', nak, nak, ak, 'k'); - text(1.35*maxim, 0, 0, 'x', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 1.35*maxim, 0, 'y', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 0, 1.35*maxim, 'z', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); - plot3(X0,Y0,Z0,'k' ,X1,Y1,Z0,'k', X2,Y2,Z0,'k', X3,Y3,Z0,'k', X4,Y4,Z0,'k'); -% kinder = get(gca,'Children'); - grid off - axis off - case 'outer' - grid on - axis on -end diff --git a/applications/SphericalHarmonics/ita_sht.m b/applications/SphericalHarmonics/ita_sht.m deleted file mode 100644 index 4bbc1b3e92917f41f6091620ef3996c849d38175..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sht.m +++ /dev/null @@ -1,29 +0,0 @@ -function acDataSH = ita_sht(acData, gridData, type) -%ITA_SHT - performs a Spherical Harmonic transform on spherical data struct - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% Author: Martin Pollow -- Email: mpo@akustik.rwth-aachen.de -% Created: 03-Dec-2008 - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -acDataSH = cell(size(acData)); - -for n = 1:numel(acData) - acDataSH{n}.header = acData{n}.header; - % TODO: neue EInheit - if isfield(acData{n},'dat') - oldFieldname = 'dat'; - newFieldname = 'dat_SH'; - elseif isfield(acData{n},'spk') - oldFieldname = 'spk'; - newFieldname = 'spk_SH'; - end - - acDataSH{n}.(newFieldname) = ita_sph_SHT(acData{n}.(oldFieldname), gridData, type); -end \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_complex2reim.m b/applications/SphericalHarmonics/ita_sph_complex2reim.m deleted file mode 100644 index c46763b55ed328eddef56348c96bb345e09c5c72..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_complex2reim.m +++ /dev/null @@ -1,38 +0,0 @@ -function [fRe, fIm] = ita_sph_complex2reim(fCompl) -%ITA_SPH_COMPLEX2REIM - converts complex function to real and imaginary part -% function [fRe, fIm] = ita_sph_complex2reim(fCompl) -% -% converts a spatial function given by its SH-coefficients to their -% real and imaginary part given also as SH-coefficients -% the resynthesis is: fCompl = fRe + j * fIm -% -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 04.11.2008 - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -nCoef = size(fCompl,1); -[degree, order] = ita_sph_linear2degreeorder(1:nCoef); - -fRe = zeros(size(fCompl)); -fIm = fRe; - -for iCoef = 1:nCoef - m = order(iCoef); -% l = degree(iCoef); - if ~m % m=0 - fRe(iCoef,:) = real(fCompl(iCoef,:)); - fIm(iCoef,:) = imag(fCompl(iCoef,:)); - elseif m > 0 - fRe(iCoef,:) = (fCompl(iCoef,:) + (-1)^m * conj(fCompl(iCoef-(2*m))))/2; - fRe(iCoef-(2*m),:) = conj(fRe(iCoef,:)) * (-1)^m; - fIm(iCoef,:) = (fCompl(iCoef,:) - (-1)^m * conj(fCompl(iCoef-(2*m))))/(2*j); - fIm(iCoef-(2*m),:) = conj(fIm(iCoef,:)) * (-1)^m; - end -end diff --git a/applications/SphericalHarmonics/ita_sph_convert2vector.m b/applications/SphericalHarmonics/ita_sph_convert2vector.m deleted file mode 100644 index b48c74e9834e953076d7ac7b3fe51b0109f683c9..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_convert2vector.m +++ /dev/null @@ -1,15 +0,0 @@ -function sph = ita_sph_convert2vector(sph) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -sph.theta = sph.theta(:); -sph.phi = sph.phi(:); -if isfield(sph,'r') - sph.r = sph.r(:); -end -sph.weights = sph.weights(:); diff --git a/applications/SphericalHarmonics/ita_sph_correlationS2.m b/applications/SphericalHarmonics/ita_sph_correlationS2.m deleted file mode 100644 index b099eb51296713ec1d75b8efbe5afb3af3ffeef1..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_correlationS2.m +++ /dev/null @@ -1,30 +0,0 @@ -function correlation = ita_sph_correlationS2(F, G) -%ITA_SPH_CORRELATIONS2 - spatial correlation in SH-domain -% function correlation = ita_sph_correlationS2(F, G) -% -% computes the normalized spatial correlation of two functions -% on the 2-sphere in the spherical harmonic domain -% -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 05.11.2008 - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - -ita_verbose_obsolete('Please use ita_sph_xcorr in future.') - -if ~exist('G', 'var') - G = F; -end - -if size(F,1) ~= size(G,1) - error('coefficient vectors must have the same size'); -end - -correlation = zeros(size(F,1),1); -for iFreq = 1:size(F,1) - correlation(iFreq) = conj(F(iFreq,:))*G(iFreq,:).'/(norm(F(iFreq,:))*norm(G(iFreq,:))); -end \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_plot.m b/applications/SphericalHarmonics/ita_sph_plot.m deleted file mode 100644 index 74ea444356c56ac8574813c35cd063610af570dc..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot.m +++ /dev/null @@ -1,340 +0,0 @@ -function ita_sph_plot(data, varargin) -%ITA_SPH_PLOT - plots a spherical function (and sampling points) -% function ita_sph_plot(data, varargin) -% -% the input data can be given as a spherical harmonic coefficient vector -% -% the optional parameter 'type' can be: -% 'complex' : radius is magnitude, color is phase -% 'sphere' : plots magnitude as color on unit sphere -% 'magnitude' : radius and color is magnitude -% 'spherephase' : plots phase as color on unit sphere -% -% the optional GeometryPoints and pointData give the information about -% spherical sampling points -% GeometryPoints.theta: vector of theta values -% GeometryPoints.phi: vector of phi values -% data: vector of sampling values -% -% type: default 'magnitude' -% GeometryPoints & pointData: default [] -% axes: outer/inner, different 'design' (default: outer) -% fontsize: default 12, for axis annotations - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - - -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 03.09.2008 -% Modified: 14.01.2009 - mpe - parameter-structure: -% Complete rewrite: July-09 - mpo - -% default parameters -def.type = 'magnitude'; -def.facealpha = 0.7; -def.edgealpha = 0.1; -def.grid = []; -def.samplingpoints = []; -def.sampledvalues = []; -def.geometrypoints = []; -def.axes = 'outer'; -def.fontsize = 12; -def.onballoon = 'none'; % 'smaller', 'greater', 'all' -% def.angunit = 'rad'; % ToDo: Winkeldarstellung Bogenma�/Grad ('deg') -% def.plottype = 'ita_sph_plot'; evtl. noch f�r update-Funktion -def.caxis = []; -def.line = false; - -if nargin > 1 -% if isstruct(varargin{1}) && isfield(varargin{1},'pos')% this is sampling points - if isa(varargin{1},'itaSampling') || isa(varargin{1},'itaCoordinates'); % this is sampling points - def.samplingpoints = varargin{1}; - % and delete first element ion list - varargin = varargin(2:end); - if nargin > 2 && isnumeric(varargin{1})% the values of the points are also given - def.sampledvalues = varargin{1}; - varargin = varargin(2:end); - else % use weights (enlarge, if it only theta weights) - def.sampledvalues = def.samplingpoints.weights; -% def.sampledvalues = weights; - end - end -end - -% % test if the sampling points are given -% if nargin > 1 && isstruct(samplingPoints) -% if ~exist('sampledValues','var') -% sampledValues = samplingPoints.weights; -% end -% % or if they are not given, either way plot weights -% if ~isnumeric(sampledValues) -% varargin = {sampledValues varargin{:}}; -% sampledValues = samplingPoints.weights; -% end -% % now handle it via parser -% varargin = {'samplingPoints' samplingPoints ... -% 'sampledValues' sampledValues varargin{:}}; -% clear samplingPoints sampledValues; -% end - -% take over parameters from arguments (varargin) -paraStruct = ita_parse_arguments(def,varargin); - -% load or make grid for plotting -persistent plotGrid -if ~isempty(paraStruct.grid) && ... - (isa(paraStruct.grid,'itaCoordinates') || isa(paraStruct.grid,'itaSampling')); - plotGrid = paraStruct.grid; -elseif ~isstruct(plotGrid) - plotGrid = ita_sph_sampling_equiangular(64,64,'[]','[)');%equiangular(15); -end -% plotGrid = ita_sph_grid_regular_weights(plotGrid,31); -% plotGrid = ita_sph_base(plotGrid, 31); -% theta = reshape(plotGrid.coord(:,1),length(plotGrid.weights),[]); -% phi = reshape(plotGrid.coord(:,2),length(plotGrid.weights),[]); -theta = plotGrid.theta; -phi = plotGrid.phi; - -type = paraStruct.type; -samplingPoints = paraStruct.samplingpoints; -sampledValues = paraStruct.sampledvalues; - -if numel(data) == numel(theta) - disp('it must be spatial data'); - dataSH = ita_sph_SHT(data, plotGrid); -else - if numel(data) == 1 - data = sqrt(4*pi); - elseif size(data,1) == 1 - data = data.'; - end - dataSH = data; - data = ita_sph_ISHT(dataSH, plotGrid); - data = reshape(data, length(plotGrid.weights), []); -end - -switch type - case 'complex' - magn = abs(data); - color = mod(angle(data),2*pi); - colormap(hsv); - case 'sphere' - magn = ones(size(data)); - color = abs(data); - colormap(jet); - case 'spherephase' - magn = ones(size(data)); - color = angle(data); - colormap(hsv); - case 'magnitude' - magn = abs(data); - color = magn; - colormap(jet); - otherwise - error('give a valid type (complex / sphere / spherephase / magnitude)') -end - -% magn = abs(data); -% angle = angle(data) - -% theta = [plotGrid.theta, plotGrid.theta(:,1)]; -% phi = [plotGrid.phi, 2*pi+plotGrid.phi(:,1)]; -theta = theta(:,[1:end 1]); -phi = phi(:,[1:end 1]); -magn = magn(:,[1:end 1]); -color = color(:,[1:end 1]); -% color = [color, color(:,1)]; - -[X,Y,Z] = sph2cart(phi, pi/2 - theta, magn); -% cla; -set(gcf, 'renderer', 'opengl') -surf(X,Y,Z,color, 'EdgeAlpha', paraStruct.edgealpha, 'FaceAlpha', paraStruct.facealpha); - -colorbar; -% shading interp -m_val = max(max(magn)); -if m_val > 0 - xlim([-m_val m_val]); - ylim([-m_val m_val]); - zlim([-m_val m_val]); -end -daspect([1 1 1]); -axis vis3d % off -% axis([-1 1 -1 1 -1 1]) - -switch type - case {'complex','spherephase'} - caxis([0 2*pi]); -end - -grid on; -% bigger and fatter fonts -set(gca, 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); -% set background color to white -set(gcf, 'Color', 'w'); -% view(90,0); -view(3); -% view(0,90); -rotate3d; -xlabel('x'); -ylabel('y'); -zlabel('z'); - -% do we want points on the sphere? -if ~isempty(samplingPoints) - if ~strcmp(samplingPoints.type,'sph') - samplingPoints = cart2sph(samplingPoints); - end - - switch type - case 'complex' - pointRadius = abs(sampledValues); - pointColor = mod(angle(sampledValues), 2*pi); - case 'sphere' - pointRadius = ones(size(sampledValues)); - pointColor = abs(sampledValues); - case 'magnitude' - pointRadius = abs(sampledValues); - pointColor = abs(sampledValues); - case 'spherephase' - pointRadius = ones(size(sampledValues)); - pointColor = mod(angle(sampledValues), 2*pi); - end - - hold on; - -% target = magn(:); - - cmap = colormap; - - % extrema of color bar is calculated out of both directivity and pressure - % on microphones: - minRadiusSphere = min(magn(:)); - maxRadiusSphere = max(magn(:)); - - minRadiusPoints = min(pointRadius(:)); - maxRadiusPoints = max(pointRadius(:)); - -% minRadiusTotal = min(minRadiusSphere, minRadiusPoints); -% maxRadiusTotal = max(maxRadiusSphere, maxRadiusPoints); - - - if strcmp(type,'complex') - cmin = 0; - cmax = 2*pi; - else - cmin = 0; % min([min_pointData min_target]); - cmax = max(max(color(:)), max(pointColor(:))); - end - - if ~isempty(paraStruct.caxis) - cmin = paraStruct.caxis(1); - cmax = paraStruct.caxis(2); - if numel(cmax) - cmax = cmin; - caxis([cmin cmax]); - end - end - - - % length of color points - m = size(cmap,1); - - % from MatLab help "caxis": - index = fix((pointColor-cmin)/(cmax-cmin)*m)+1; - % fix the problem for the maximum value - index(index >= m) = m; - - for m = 1:length(sampledValues) - - % find radius on balloon plot - sizeDataSH = size(dataSH); - dataSHused = zeros([size(samplingPoints.Y,2) sizeDataSH(2:end)]); - % doesnt work on multiple dimensions of dataSH !! - dataSHused(1:length(dataSH)) = dataSH; - - % data of balloon on sampling points - r = abs(dataSHused.' * samplingPoints.Y(m,:).'); - theta = samplingPoints.coord(m,1); - phi = samplingPoints.coord(m,2); -% -% - - if numel(index(m)) == 1 && ~isnan(index(m)) - c = cmap(index(m),:); - else - c = zeros(1,size(cmap,2)); - end - if strcmp(type,'sphere') - r_used = 1; -% plot3(x, y, z, 'o', 'MarkerEdgeColor','k', 'MarkerFaceColor', c, 'MarkerSize',10); - else - if pointRadius(m) > r % reconstruction too silent - lineStyle = ':'; - lineWidth = 2; - switch paraStruct.onballoon - case {'greater','all'} - r_used = r; - otherwise - r_used = pointRadius(m); - end - else - lineStyle = '-'; - lineWidth = 3; - switch paraStruct.onballoon - case {'smaller','all'} - r_used = r; - otherwise - r_used = pointRadius(m); - end - end - end - x = r_used .* cos(phi) .* sin(theta); - y = r_used .* sin(phi) .* sin(theta); - z = r_used .* cos(theta); - plot3(x, y, z, 'o', 'MarkerEdgeColor','k', 'MarkerFaceColor', c, 'MarkerSize',10); - if paraStruct.line - xSurf = r .* sin(theta) .* cos(phi); - ySurf = r .* sin(theta) .* sin(phi); - zSurf = r .* cos(theta); - line([xSurf x],[ySurf y],[zSurf z], 'LineWidth', lineWidth, 'Color', 'black','LineStyle',lineStyle); - end - end -end - -switch paraStruct.axes - case 'inner'% alternative Achsen: - hold on; - maxim = max([max(max(abs(X))) max(max(abs(Y))) max(max(abs(Z)))]); - ak = [1.3*maxim -1.3*maxim]; nak = [0 0]; - [X0,Y0] = pol2cart(0:pi/180:2*pi,1.1*maxim); - [X1,Y1] = pol2cart(0:pi/180:2*pi,1.0*maxim); - [X2,Y2] = pol2cart(0:pi/180:2*pi,0.9*maxim); - [X3,Y3] = pol2cart(0:pi/180:2*pi,0.8*maxim); - [X4,Y4] = pol2cart(0:pi/180:2*pi,0.7*maxim); - Z0=zeros(1,361); - plot3(ak, nak, nak, 'k', nak, ak, nak, 'k', nak, nak, ak, 'k'); - text(1.35*maxim, 0, 0, 'x', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 1.35*maxim, 0, 'y', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 0, 1.35*maxim, 'z', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); - plot3(X0,Y0,Z0,'k' ,X1,Y1,Z0,'k', X2,Y2,Z0,'k', X3,Y3,Z0,'k', X4,Y4,Z0,'k'); - kinder = get(gca,'Children'); -% for k=1:11 -% set(kinder(k),'Visible','on'); -% end - grid off - axis off - case 'outer' -% for k=1:11 -% set(kinder(k),'Visible','off'); -% end -% grid on -% axis on -end - -hold off; - -% set(gcf,'KeyPressFcn',@ita_plottools_buttonpress_spherical); \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_plot_SH.m b/applications/SphericalHarmonics/ita_sph_plot_SH.m deleted file mode 100644 index 514ac3d93c02d2a2ec5627d72698b4bc786235b0..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_SH.m +++ /dev/null @@ -1,148 +0,0 @@ -function ita_sph_plot_SH(coefs, varargin) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% check if 2nd parameter is the cell for the point plot -pointdata = []; -pointsampling = []; -if numel(varargin) && iscell(varargin{1}) - pointcell = varargin{1}; - if numel(pointcell) == 1 - pointsampling = pointcell{1}; - pointdata = pointsampling.r; - else - pointdata = pointcell{1}; - pointsampling = pointcell{2}; - end - varargin = varargin(2:end); -end - -paraStruct = ita_sph_plot_parser(varargin); -plottype = paraStruct.type; - -% load or make grid for plotting -persistent sampling -if ~isempty(paraStruct.sampling) && isa(paraStruct.sampling,'itaSamplingSph') - % a valid sampling given from input parameter - sampling = paraStruct.sampling; -elseif ~isa(sampling,'itaSamplingSph') - % persistant variable doesnt contain a valid grid - sampling = ita_sph_sampling_equiangular(64,64,'[]','[)'); -end - -% convert to given spatial grid -data = ita_sph_ISHT(coefs, sampling); - -% call spatial plot function -[hFig, hSurf] = ita_sph_plot_spatial(data, sampling, varargin{:}); - -% do we want points on the sphere? -if ~isempty(pointdata) - - % convert to spherical coordinates -% if ~strcmp(pointsampling.type,'sph') - pointsampling = cart2sph(pointsampling); -% end - - [magn, color, colorMap] = ita_sph_plot_type(pointdata,plottype); - -% sizeGrid = size(sampling.weights); - theta = pointsampling.theta; - phi = pointsampling.phi; - magn = reshape(magn,size(theta)); - color = reshape(color,size(theta)); - - if numel(coefs) == 1 - r_balloon = ones(size(theta)) .* coefs ./ sqrt(4*pi); - else - r_balloon = abs(ita_sph_functionvalue(coefs, pointsampling)); - r_balloon = reshape(r_balloon,size(theta)); - end - - % find location of the dots - switch paraStruct.onballoon - case 'greater' - % all dots on or inside balloon - lineStyle = '-'; - lineWidth = 3; - r_point = min(r_balloon, magn); - case 'smaller' - % all dot on or outsied balloon - lineStyle = ':'; - lineWidth = 2; - r_point = max(r_balloon, magn); - case 'all' - % all dots on balloon - r_point = r_balloon; - otherwise - r_point = magn; - end - - - % find balloon radii - X = get(hSurf,'XData'); - Y = get(hSurf,'YData'); - Z = get(hSurf,'ZData'); - R = sqrt(X.^2 + Y.^2 + Z.^2); - - % maximum of balloon and dots -% maxVal = max(max(max(R(:)),max(magn))); - colorSurf = get(hSurf,'CData'); -% maxColorSurf = max(max(colorSurf)); - maxVal = max(max(colorSurf(:),max(color(:)))); - - % set colorbar data - if isempty(paraStruct.caxis) - % fix values - cmin = 0; - if strcmp(plottype,'complex') ... - || strcmp(plottype,'spherephase') - cmax = 2*pi; - else - cmax = maxVal; - end - else - % parameter can change the colorbar data - cmin = paraStruct.caxis(1); - cmax = paraStruct.caxis(2); - if numel(cmax) - cmax = cmin; - end - end - caxis([cmin cmax]); - - hold on - cmap = colormap(colorMap); - - % length of color points - nPoints = size(cmap,1); - % from MatLab help "caxis": -% index = fix((color-cmin)/(cmax-cmin)*m)+1; - % fix the problem for the maximum value -% index(index >= m) = m; - - index = fix((color-cmin)/(cmax-cmin)*(nPoints-1))+1; - - x = r_point .* cos(phi) .* sin(theta); - y = r_point .* sin(phi) .* sin(theta); - z = r_point .* cos(theta); - nCmap = size(cmap,1); - for n = 1:nCmap - % indexBound element of 1..nCmap - indexBound = max(min(index,nCmap),1); - ind = (indexBound(:) == n); - plot3(x(ind), y(ind), z(ind), 'o', 'MarkerEdgeColor','k', 'MarkerFaceColor', cmap(n,:), 'MarkerSize',10); - end - if paraStruct.line - xSurf = r_balloon .* sin(theta) .* cos(phi); - ySurf = r_balloon .* sin(theta) .* sin(phi); - zSurf = r_balloon .* cos(theta); - line([xSurf x],[ySurf y],[zSurf z], 'LineWidth', lineWidth, 'Color', 'black','LineStyle',lineStyle); - end -end - -hold off; \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_plot_flat.m b/applications/SphericalHarmonics/ita_sph_plot_flat.m deleted file mode 100644 index 2dc3231524e1a3cff6d1406a7f03c85ce4167767..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_flat.m +++ /dev/null @@ -1,129 +0,0 @@ -function ita_sph_plot_flat(GeometryGrid, GeometryPoints, GeometrySource, data, dataPoints, minmax, colorType) -%ITA_SPH_PLOT_FLAT - plots a projected spherical function (and sampling points) -% function ita_sph_plot_flat(GeometryGrid, GeometryPoints, GeometrySource, data, dataPoints, minmax, colorType) -% -% plots the approximated spherical function (data) on a flat surface, using -% cylindrical projection -% the discrete positions of sampling points are hereby given as circles, -% filled with an apropriate color -% -% GeometryGrid.theta: 2D-meshgrid of theta values (radians) -% GeometryGrid.phi: 2D-meshgrid of phi values (radians, '[0..2*pi)') -% -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 03.09.2008 - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% convert to spatial domain if given as SH vector -if size(data,1) == size(GeometryGrid.Y,2) - data = ISHT(data, g); -end - -if nargin < 7 - colorType = jet; -end - -% rotate the target by pi -rot_steps = [0 size(GeometryGrid.phi,2)/2]; -% phi = circshift(GeometryGrid.phi, rot_steps); -% theta = circshift(GeometryGrid.theta, rot_steps); -target = circshift(reshape(data, size(GeometryGrid.phi)), rot_steps); - -% add another line to have full range between 0 and 2*pi -phi = [GeometryGrid.phi GeometryGrid.phi(:,1)+2*pi]; -theta = [GeometryGrid.theta GeometryGrid.theta(:,1)]; -target = [target target(:,1)]; - -% figure; -hold on - -set(gcf, 'renderer', 'painters') - -% white background, Position -set(gcf, 'color', 'w');%, 'Position', [1 1 700 500]); - -cmap = colormap(colorType); - -% extrema of color bar is calculated out of both directivity and pressure -% on microphones: -min_dataPoints = min(abs(dataPoints)); -min_target = min(abs(data)); -max_dataPoints = max(abs(dataPoints)); -max_target = max(abs(data)); - -if nargin < 6 - minmax = [min_dataPoints; max_dataPoints]; -end - -cmin = min([minmax(1) min_dataPoints min_target]); -cmax = max([minmax(2) max_dataPoints max_target]); - -caxis([cmin cmax]); - -% length of color points -m = size(cmap,1); - -C = abs(dataPoints); -% from MatLab help "caxis": -index = fix((C-cmin)/(cmax-cmin)*m)+1; -% fix the problem for the maximum value -index(find(index >= m)) = m; - - -% set ranges -xlim([0 2*pi]); -ylim([0 pi]); - -% put the north pole up -set(gca,'YDir','reverse') - -% pcolor(con*phi2, con*theta2, abs(data2)); -pcolor(phi, theta, abs(target)); - -for m = 1:size(dataPoints,1) - - if m == 23, pointsign = 'v'; - else pointsign = 'o'; - end - - C1 = mod(GeometryPoints.phi(m)+pi, 2*pi); - C2 = GeometryPoints.theta(m); - C3 = cmap(index(m),:); - - plot(C1, C2, pointsign,'MarkerEdgeColor','k', ... - 'MarkerFaceColor',C3,'MarkerSize',12); -end - -for m = 1:length(GeometrySource.phi) - - C1 = GeometrySource.phi(m); - C2 = GeometrySource.theta(m); - C3 = 'k'; - - pointsign = 'd'; - - plot(C1, C2, pointsign,'MarkerEdgeColor','k', ... - 'MarkerFaceColor',C3,'MarkerSize',6); -end - -% set ticks to pi values -set(gca, 'XTick', 0:pi:2*pi, 'YTick', 0:pi/4:pi); - -% % set ticks to degree values -set(gca, 'XTick', (0:pi/2:2*pi), 'YTick', (0:pi/4:pi)); -set(gca, 'XTicklabel', {'back', 'right', 'front', 'left', 'back'}, 'FontSize', 15); -set(gca, 'YTicklabel', {' 0 ', ' 45 ', ' 90 ', '135 ', '180 '}, 'FontSize', 15); - -% avoid that the upper dot gets cut -set(gca, 'OuterPosition', [0 0 1 0.98]) - -shading interp; - -% look from top -view(0,90); diff --git a/applications/SphericalHarmonics/ita_sph_plot_new.m b/applications/SphericalHarmonics/ita_sph_plot_new.m deleted file mode 100644 index dbd57e2d5f979acc4409458348f7c277210d337c..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_new.m +++ /dev/null @@ -1,312 +0,0 @@ -function ita_sph_plot_new(data, samplingPoints, sampledValues, varargin) -%ITA_SPH_PLOT - plots a spherical function (and sampling points) -% function ita_sph_plot(data, varargin) -% -% the input data can be given as a spherical harmonic coefficient vector -% -% the optional parameter 'type' can be: -% 'complex' : radius is magnitude, color is phase -% 'sphere' : plots magnitude as color on unit sphere -% 'magnitude' : radius and color is magnitude -% 'spherephase' : plots phase as color on unit sphere -% -% the optional GeometryPoints and pointData give the information about -% spherical sampling points -% GeometryPoints.theta: vector of theta values -% GeometryPoints.phi: vector of phi values -% data: vector of sampling values -% -% type: default 'magnitude' -% GeometryPoints & pointData: default [] -% axes: outer/inner, different 'design' (default: outer) -% fontsize: default 12, for axis annotations - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - - -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 03.09.2008 -% Modified: 14.01.2009 - mpe - parameter-structure: - -% default parameters -def.type = 'magnitude'; -def.facealpha = 0.7; -def.edgealpha = 0.1; -def.samplingpoints = []; -def.sampledvalues = []; -def.geometrypoints = []; -def.axes = 'outer'; -def.fontsize = 12; -def.onballoon = 'none'; % 'smaller', 'greater', 'both' -% def.angunit = 'rad'; % ToDo: Winkeldarstellung Bogenmaß/Grad ('deg') -% def.plottype = 'ita_sph_plot'; evtl. noch für update-Funktion -def.caxis = []; -def.line = false; - -% test if the sampling points are given -if nargin > 1 && isstruct(samplingPoints) - if ~exist('sampledValues','var') - sampledValues = samplingPoints.weights; - end - % or if they are not given, either way plot weights - if ~isnumeric(sampledValues) - varargin = {sampledValues varargin{:}}; - sampledValues = samplingPoints.weights; - end - % now handle it via parser - varargin = {'samplingPoints' samplingPoints ... - 'sampledValues' sampledValues varargin{:}}; - clear samplingPoints sampledValues; -end - -% take over parameters from arguments (varargin) -paraStruct = ita_parse_arguments(def,varargin); - -% load or make grid for plotting -persistent plotGrid -if ~isstruct(plotGrid) - plotGrid = ita_sph_grid_regular(64); - plotGrid = ita_sph_grid_regular_weights(plotGrid,31); - plotGrid = ita_sph_base(plotGrid, 31); -end - -type = paraStruct.type; -samplingPoints = paraStruct.samplingpoints; -sampledValues = paraStruct.sampledvalues; - -if numel(data) == numel(plotGrid.theta) - disp('it must be spatial data'); - dataSH = ita_sph_SHT(data, plotGrid); -else - if numel(data) == 1 - data = sqrt(4*pi); - elseif size(data,1) == 1 - data = data.'; - end - dataSH = data; - data = ita_sph_ISHT(dataSH, plotGrid); - data = reshape(data, size(plotGrid.theta)); -end - -switch type - case 'complex' - magn = abs(data); - color = mod(angle(data),2*pi); - colormap(hsv); - case 'sphere' - magn = ones(size(data)); - color = abs(data); - colormap(jet); - case 'spherephase' - magn = ones(size(data)); - color = angle(data); - colormap(hsv); - case 'magnitude' - magn = abs(data); - color = magn; - colormap(jet); - otherwise - error('give a valid type (complex / sphere / spherephase / magnitude)') -end - -% magn = abs(data); -% angle = angle(data) - -theta = [plotGrid.theta, plotGrid.theta(:,1)]; -phi = [plotGrid.phi, 2*pi+plotGrid.phi(:,1)]; -magn = [magn, magn(:,1)]; -color = [color, color(:,1)]; - -[X,Y,Z] = sph2cart(phi, pi/2 - theta, magn); -% cla; -set(gcf, 'renderer', 'opengl') -surf(X,Y,Z,color, 'EdgeAlpha', paraStruct.edgealpha, 'FaceAlpha', paraStruct.facealpha); - -colorbar; -% shading interp -m_val = max(max(magn)); -if m_val > 0 - xlim([-m_val m_val]); - ylim([-m_val m_val]); - zlim([-m_val m_val]); -end -daspect([1 1 1]); -axis vis3d % off -% axis([-1 1 -1 1 -1 1]) - -switch type - case {'complex','spherephase'} - caxis([0 2*pi]); -end - -grid on; -% bigger and fatter fonts -set(gca, 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); -% set background color to white -set(gcf, 'Color', 'w'); -% view(90,0); -view(3); -% view(0,90); -rotate3d; -xlabel('x'); -ylabel('y'); -zlabel('z'); - -% do we want points on the sphere? -if ~isempty(samplingPoints) - if ~strcmp(samplingPoints.pos.type,'sph') - samplingPoints.pos = cart2sph(samplingPoints.pos); - end - - switch type - case 'complex' - pointRadius = abs(sampledValues); - pointColor = mod(angle(sampledValues), 2*pi); - case 'sphere' - pointRadius = ones(size(sampledValues)); - pointColor = abs(sampledValues); - case 'magnitude' - pointRadius = abs(sampledValues); - pointColor = abs(sampledValues); - case 'spherephase' - pointRadius = ones(size(sampledValues)); - pointColor = mod(angle(sampledValues), 2*pi); - end - - hold on; - - target = magn(:); - - cmap = colormap; - - % extrema of color bar is calculated out of both directivity and pressure - % on microphones: - minRadiusSphere = min(magn(:)); - maxRadiusSphere = max(magn(:)); - - minRadiusPoints = min(pointRadius(:)); - maxRadiusPoints = max(pointRadius(:)); - - minRadiusTotal = min(minRadiusSphere, minRadiusPoints); - maxRadiusTotal = max(maxRadiusSphere, maxRadiusPoints); - - - if strcmp(type,'complex') - cmin = 0; - cmax = 2*pi; - else - cmin = 0; % min([min_pointData min_target]); - cmax = max(max(color(:)), max(pointColor(:))); - end - - if ~isempty(paraStruct.caxis) - cmin = paraStruct.caxis(1); - cmax = paraStruct.caxis(2); - if numel(cmax) - cmax = cmin; - caxis([cmin cmax]); - end - end - - - % length of color points - m = size(cmap,1); - - % from MatLab help "caxis": - index = fix((pointColor-cmin)/(cmax-cmin)*m)+1; - % fix the problem for the maximum value - index(index >= m) = m; - - for m = 1:length(sampledValues) - - % find radius on balloon plot - sizeDataSH = size(dataSH); - dataSHused = zeros([size(samplingPoints.Y,2) sizeDataSH(2:end)]); - % doesnt work on multiple dimensions of dataSH !! - dataSHused(1:length(dataSH)) = dataSH; - - % data of balloon on sampling points - r = abs(dataSHused.' * samplingPoints.Y(m,:).'); - theta = samplingPoints.pos.coord(m,1); - phi = samplingPoints.pos.coord(m,2); -% -% - - if numel(index(m)) == 1 && ~isnan(index(m)) - c = cmap(index(m),:); - else - c = zeros(1,size(cmap,2)); - end - if strcmp(type,'sphere') - r_used = 1; -% plot3(x, y, z, 'o', 'MarkerEdgeColor','k', 'MarkerFaceColor', c, 'MarkerSize',10); - else - if pointRadius(m) > r % reconstruction too silent - lineStyle = ':'; - lineWidth = 2; - switch paraStruct.onballoon - case {'greater','both'} - r_used = r; - otherwise - r_used = pointRadius(m); - end - else - lineStyle = '-'; - lineWidth = 3; - switch paraStruct.onballoon - case {'smaller','both'} - r_used = r; - otherwise - r_used = pointRadius(m); - end - end - end - x = r_used .* cos(phi) .* sin(theta); - y = r_used .* sin(phi) .* sin(theta); - z = r_used .* cos(theta); - plot3(x, y, z, 'o', 'MarkerEdgeColor','k', 'MarkerFaceColor', c, 'MarkerSize',10); - if paraStruct.line - xSurf = r .* sin(theta) .* cos(phi); - ySurf = r .* sin(theta) .* sin(phi); - zSurf = r .* cos(theta); - line([xSurf x],[ySurf y],[zSurf z], 'LineWidth', lineWidth, 'Color', 'black','LineStyle',lineStyle); - end - end -end - -switch paraStruct.axes - case 'inner'% alternative Achsen: - hold on; - maxim = max([max(max(abs(X))) max(max(abs(Y))) max(max(abs(Z)))]); - ak = [1.3*maxim -1.3*maxim]; nak = [0 0]; - [X0,Y0] = pol2cart(0:pi/180:2*pi,1.1*maxim); - [X1,Y1] = pol2cart(0:pi/180:2*pi,1.0*maxim); - [X2,Y2] = pol2cart(0:pi/180:2*pi,0.9*maxim); - [X3,Y3] = pol2cart(0:pi/180:2*pi,0.8*maxim); - [X4,Y4] = pol2cart(0:pi/180:2*pi,0.7*maxim); - Z0=zeros(1,361); - plot3(ak, nak, nak, 'k', nak, ak, nak, 'k', nak, nak, ak, 'k'); - text(1.35*maxim, 0, 0, 'x', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 1.35*maxim, 0, 'y', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 0, 1.35*maxim, 'z', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); - plot3(X0,Y0,Z0,'k' ,X1,Y1,Z0,'k', X2,Y2,Z0,'k', X3,Y3,Z0,'k', X4,Y4,Z0,'k'); - kinder = get(gca,'Children'); -% for k=1:11 -% set(kinder(k),'Visible','on'); -% end - grid off - axis off - case 'outer' -% for k=1:11 -% set(kinder(k),'Visible','off'); -% end -% grid on -% axis on -end - -hold off; - -% set(gcf,'KeyPressFcn',@ita_plottools_buttonpress_spherical); \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_plot_parser.m b/applications/SphericalHarmonics/ita_sph_plot_parser.m deleted file mode 100644 index 1e667a3f9607eb7d758ef316454a9e0b0b9bd140..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_parser.m +++ /dev/null @@ -1,34 +0,0 @@ -function paraStruct = ita_sph_plot_parser(varargin) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% default parameters -def.type = 'magnitude'; % 'complex', 'sphere', 'spherephase', 'dB' -def.facealpha = 0.9; -def.edgealpha = 0.1; -def.sampling = []; -% def.samplingpoints = []; -% def.sampledvalues = []; -def.geometrypoints = []; -def.axes = 'outer'; -def.fontsize = 12; -def.onballoon = 'none'; % 'smaller', 'greater', 'all' -% def.angunit = 'rad'; % ToDo: Winkeldarstellung Bogenmaß/Grad ('deg') -% def.plottype = 'ita_sph_plot'; evtl. noch für update-Funktion -def.caxis = []; -def.rlim = []; -def.line = false; - -% stuff for the dot plot -def.symbol = 'o'; -def.MarkerEdgeColor = 'k'; -def.dotColor = [0 0 0]; % black -def.dotSampling = itaSamplingSph; -def.MarkerSize = 10; - -% take over parameters from arguments (varargin) -paraStruct = ita_parse_arguments(def,varargin{:}); diff --git a/applications/SphericalHarmonics/ita_sph_plot_spatial.m b/applications/SphericalHarmonics/ita_sph_plot_spatial.m deleted file mode 100644 index eedd29cc7b071cacefcdf246afb0f7606026f4d8..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_spatial.m +++ /dev/null @@ -1,139 +0,0 @@ -function [hFig, hSurf] = ita_sph_plot_spatial(data, sampling, varargin) -%ITA_SPH_PLOT_SPATIAL - plots a spatial spherical function (and sampling points) -% function ita_sph_plot_spatial(data, varargin) -% -% the optional parameter 'type' can be: -% 'complex' : radius is magnitude, color is phase -% 'sphere' : plots magnitude as color on unit sphere -% 'magnitude' : radius and color is magnitude -% 'spherephase' : plots phase as color on unit sphere -% 'db' : plots 20*log10(abs(data)),putting the maximum level to a fixed value -% -% the optional GeometryPoints and pointData give the information about -% spherical sampling points -% GeometryPoints.theta: vector of theta values -% GeometryPoints.phi: vector of phi values -% data: vector of sampling values -% -% type: default 'magnitude' -% GeometryPoints & pointData: default [] -% axes: outer/inner, different 'design' (default: outer) -% fontsize: default 12, for axis annotations - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - - -% Martin Pollow (mpo@akustik.rwth-aachen.de) -% Institute of Technical Acoustics, RWTH Aachen, Germany -% 03.09.2008 -% Modified: 14.01.2009 - mpe - parameter-structure: -% Complete rewrite: July-09 - mpo - -% if nargin < 2 -% sampling = data; -% data = ones(size(sampling)); -% -% end - -% narginchk(2,3); - -paraStruct = ita_sph_plot_parser(varargin); - -type = paraStruct.type; - -% get the values for the plot -[magn, color, colorMap] = ita_sph_plot_type(data,type); - -% reshape for use in plot - -sqrtNumel = sqrt(numel(magn)); -isWholeNumber = floor(sqrtNumel) == ceil(sqrtNumel); -if isWholeNumber && sqrtNumel > 15; - dim = [sqrt(numel(magn)) sqrt(numel(magn))]; - magn = reshape(magn,dim); - color = reshape(color,dim); - theta = reshape(sampling.theta,dim); - phi = reshape(sampling.phi,dim); -else - error('mist hier') -end - -% add one vertical line of values to get a closed balloon -theta = theta(:,[1:end 1]); -phi = phi(:,[1:end 1]); -magn = magn(:,[1:end 1]); -color = color(:,[1:end 1]); - -% plot the balloon -[X,Y,Z] = sph2cart(phi, pi/2 - theta, magn); -% hFig = figure; -hFig = gcf; -set(hFig, 'renderer', 'opengl') -hSurf = surf(X,Y,Z,color, 'EdgeAlpha', paraStruct.edgealpha, 'FaceAlpha', paraStruct.facealpha); -colorbar; -colormap(colorMap); - -% set axes limits -maxMagn = max(max(magn)); -if maxMagn < 0 - error('Magnitude is < 0, how to plot this'); -end - -if isempty(paraStruct.rlim) - rlim = maxMagn; -else - rlim = paraStruct.rlim; -end -xlim([-rlim rlim]); -ylim([-rlim rlim]); -zlim([-rlim rlim]); - -daspect([1 1 1]); -axis vis3d - -% set colorbar settings -if ismember(type, {'complex','spherephase'}) - caxis([0 2*pi]); -else - caxis([0 maxMagn]); -end - -grid on; -% bigger and fatter fonts -set(gca, 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); -% set background color to white -set(gcf, 'Color', 'w'); -% view(90,0); -view(3); -% view(0,90); -rotate3d; -xlabel('x'); -ylabel('y'); -zlabel('z'); - -switch paraStruct.axes - case 'inner'% alternative Achsen: - hold on; - ak = [1.3*rlim -1.3*rlim]; nak = [0 0]; - [X0,Y0] = pol2cart(0:pi/180:2*pi,1.1*rlim); - [X1,Y1] = pol2cart(0:pi/180:2*pi,1.0*rlim); - [X2,Y2] = pol2cart(0:pi/180:2*pi,0.9*rlim); - [X3,Y3] = pol2cart(0:pi/180:2*pi,0.8*rlim); - [X4,Y4] = pol2cart(0:pi/180:2*pi,0.7*rlim); - Z0=zeros(1,361); - plot3(ak, nak, nak, 'k', nak, ak, nak, 'k', nak, nak, ak, 'k'); - text(1.35*rlim, 0, 0, 'x', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 1.35*rlim, 0, 'y', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); text(0, 0, 1.35*rlim, 'z', 'FontSize', paraStruct.fontsize, 'FontWeight', 'bold'); - plot3(X0,Y0,Z0,'k' ,X1,Y1,Z0,'k', X2,Y2,Z0,'k', X3,Y3,Z0,'k', X4,Y4,Z0,'k'); - kinder = get(gca,'Children'); - grid off - axis off - case 'outer' - grid on - axis on -end - -% set(gcf,'KeyPressFcn',@ita_plottools_buttonpress_spherical); \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_plot_type.m b/applications/SphericalHarmonics/ita_sph_plot_type.m deleted file mode 100644 index abc9a91dd8d67c8c24f4958ba28f1e02f731e944..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_plot_type.m +++ /dev/null @@ -1,36 +0,0 @@ -function [magn, color, colorMap] = ita_sph_plot_type(data, type) -% internal function, not to be called seperately - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -switch lower(type) - case 'complex' - magn = abs(data); - color = mod(angle(data),2*pi); - colorMap = 'hsv'; - case 'sphere' - magn = ones(size(data)); - color = abs(data); - colorMap = 'jet'; - case 'spherephase' - magn = ones(size(data)); - color = mod(angle(data),2*pi); - colorMap = 'hsv'; - case 'magnitude' - magn = abs(data); - color = magn; - colorMap = 'jet'; - case 'db' - % put the maximum level to a fixed value - magn = 20*log10(abs(data)); - magn = magn - max(magn) + 50; - magn = max(magn,0); - color = magn; - colorMap = 'jet'; - otherwise - error('give a valid type (complex / sphere / spherephase / magnitude / db)') -end diff --git a/applications/SphericalHarmonics/ita_sph_rotate_complex_valued_spherical_harmonics.m b/applications/SphericalHarmonics/ita_sph_rotate_complex_valued_spherical_harmonics.m deleted file mode 100644 index c524cacf67bcc2cc6f8be00c7ec1035ccfd6cb2b..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_rotate_complex_valued_spherical_harmonics.m +++ /dev/null @@ -1,77 +0,0 @@ -function varargout = ita_sph_rotate_complex_valued_spherical_harmonics(input, euler) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% if "value" is a matrix of coefficients (size(value) == [nmax_lin, ~]) , which weights some real valued spherical -% basefunctions, this function returns the coeficients of the rotated -% function. -% if value == nmax, it returns a rotation matrix -% (newCoef = marix * oldCoef) -% -% rotation is proceeded along euler-angel -% first: euler(1,1) - rotation arround the z-axis -% then: euler(1,2) - rotation arround the y-axis -% then: euler(1,3) - rotation arround the z-axis -% then the function continues with euler(2,1) ... -% -% attention: - there are also other definitions of euler-angles!! -% - all angles must be [rad] -% -% author: martin kunkemoeller, 16.11.2010 -% according to Dis Zotter, chapter 3.1.4 - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -if length(input) == 1 - nmax = input; - value = []; -elseif ~mod(sqrt(size(input,1))-1, 1) - nmax = sqrt(size(input,1))-1; - value = input; -else - error('can not handle your input!'); -end - - - -if size(euler,2) ~= 3 - error('size(euler,2) must be 3'); -end - - -%proceed rotation -ROT = eye((nmax+1)^2); - -if sum(abs(euler(:,2))) - for idxE = 1:size(euler,1) - ROT = ROT... - *ROT_z(nmax,euler(idxE,1))... - *ROT_y(nmax,euler(idxE,2))... - *ROT_z(nmax,euler(idxE,3)); - end -else - for idxE = 1:size(euler,1) - ROT = ROT... - *ROT_z(nmax,euler(idxE,1) + euler(idxE,3)); - end -end - -if isempty(value) - %not the coordnate system is rotation, but the function ... - varargout{1} = ROT.'; -else - varargout{1} = ROT.'*value; -end -end - -function matrix = ROT_z(nmax,phi) -matrix = ita_sph_wignerD(nmax, [-phi 0 0]); -end - -function matrix = ROT_y(nmax, phi) -matrix = ita_sph_wignerD(nmax, [0 -phi 0]); -end \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_rotate_real_valued_spherical_harmonics.m b/applications/SphericalHarmonics/ita_sph_rotate_real_valued_spherical_harmonics.m deleted file mode 100644 index 8ddd9c57e94d3d2ade43fed75ca0d005b0829bec..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_rotate_real_valued_spherical_harmonics.m +++ /dev/null @@ -1,185 +0,0 @@ -function varargout = ita_sph_rotate_real_valued_spherical_harmonics(input, euler) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% if "value" is a matrix of coefficients (size(value) == [nmax_lin, ~]) , which weights some real valued spherical -% basefunctions, this function returns the coeficients of the rotated -% function. -% if value == nmax, it returns a rotation matrix -% (newCoef = marix * oldCoef) -% -% rotation is proceeded along euler-angel -% first: euler(1,1) - rotation arround the z-axis -% then: euler(1,2) - rotation arround the y-axis -% then: euler(1,3) - rotation arround the z-axis -% then the function continues with euler(2,1) ... -% -% attention: - there are also other definitions of euler-angles!! -% - all angles must be [rad] -% -% this implementation has many if-caseses due to awesome speedup -% -% author: martin kunkemoeller, 16.11.2010 -% according to Dis Zotter, chapter 3.1.4 - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -% initialize -if length(input) == 1 - nmax = input; - value = []; -elseif ~mod(sqrt(size(input,1))-1, 1) - nmax = sqrt(size(input,1))-1; - value = input; -else - error('can not handle your input!'); -end - -if size(euler,2) ~= 3 - error('size(euler,2) must be 3'); -end - -whos_ = whos('input'); -precision = whos_.class; - -%% proceed rotation -if sum(abs(euler(:,2))) - ROT = eye((nmax+1)^2, precision); - ROT_y = ROT_y_90d(nmax, precision); - for idxE = 1:size(euler,1) - ROT = ROT... - *ROT_z(nmax,euler(idxE,1)+pi/2, precision)... - *ROT_y... - *ROT_z(nmax,euler(idxE,2)+pi, precision)... - *ROT_y... - *ROT_z(nmax,euler(idxE,3)+pi/2, precision); - end - if isempty(value) - %not the coordnate system is rotation, but the function -> transpose - varargout{1} = ROT.'; - else - varargout{1} = ROT.'*value; - end - -elseif isempty(value) - ROT = ROT_z(nmax,sum(euler(:,1))+sum(euler(:,3)), precision); - varargout{1} = ROT.'; -else - varargout{1} = ROT_Val_z(value, nmax, sum(euler(:,1))+sum(euler(:,3)), precision); -end -end - - -function matrix = ROT_z(nmax, phi, precision) -%Idea: Fs,m = [ cos(m phi) sin(m phi)] * [Fs,mo ; Fc,mo] -% Fc,m = [-sin(m phi) cos(m phi)] * [Fs,mo ; Fc,mo] - -matrix = zeros((nmax+1)^2, precision); -for n = 0:nmax - matrix(nm2N(n,0),nm2N(n,0)) = 1; - for m = 1:n - matrix(nm2N(n,-m),nm2N(n,[-m m])) = [cos(m*phi) sin(m*phi)]; - matrix(nm2N(n, m),nm2N(n,[-m m])) = [-sin(m*phi) cos(m*phi)]; - end -end -end - -function rotValue = ROT_Val_z(value, nmax, phi, precision) -%Idea: Fs,m = [ cos(m phi) sin(m phi)] * [Fs,mo ; Fc,mo] -% Fc,m = [-sin(m phi) cos(m phi)] * [Fs,mo ; Fc,mo] - -rotValue = zeros(size(value), precision); -for m = 0:nmax - for n = m:nmax - rotValue([nm2N(n,-m);nm2N(n, m)],:) = [cos(m*phi) -sin(m*phi); sin(m*phi) cos(m*phi)] * value(nm2N(n,[-m m]),:); - end -end -end - -function matrix = ROT_y_90d(nmax, precision) -blocks = cell(2*nmax+1, 1); - -% step 1 -for n = 0:2*nmax - % mo = 0:n; - blocks{n+1} = zeros(min(n+1, 2*nmax+1-n), n+1, precision); - P = cast(legendre(n,0), precision); - blocks{n+1}(1,:) = sqrt(4*pi/(2*n+1)) * normalize_const(n) .* P.'; -end - -% step 2 -for n = 2*nmax : -1 : 2 - for m = 0:min(n-2, 2*nmax - n) - for mo = m+1:n-1 - blocks{n}(m+2,mo+1) = sqrt(2-d(m+1,0)) / (2*b(n,m)*sqrt(2-d(m,0))) * ... - (sqrt(2-d(mo,0)) * ... - (b(n,mo-1) /sqrt(2-d(mo-1,0))* blocks{n+1}(m+1,mo)... - - b(n,-mo-1) /sqrt(2-d(mo+1,0))* blocks{n+1}(m+1,mo+2))... - + 2*a(n-1,mo) * blocks{n+1}(m+1,mo+1)); - end - end -end - -% step 3 -for n = 0:nmax - for mo = 0:n - for m = mo+1:n - blocks{n+1}(m+1,mo+1) = (-1)^(m+mo)*blocks{n+1}(mo+1, m+1); - end - end -end - -matrix = zeros(nm2N(nmax,nmax), precision); -for n = 0:nmax - mo = 0:n; - for m = 1:n % sinus part - matrix(nm2N(n,-m),nm2N(n,-mo)) = d(mod(n+m+mo+1,2),0) .* blocks{n+1}(m+1, mo+1); - end - mo = 0:n; - for m = 0:n % cosinus part - matrix(nm2N(n,m), nm2N(n,mo)) = d(mod(n+m+mo,2),0) .* blocks{n+1}(m+1, mo+1); - end -end - -end - -function N = normalize_const(n) -% function for orthogonality (Dis Zotter, eq.31 (page 19)) -N = zeros(1,n); -for m = 0:n - N(m+1) = (-1)^m * sqrt((2*n+1)*2*factorial(n-m) / (4*pi*factorial(n+m))); -end -N(1) = N(1)/sqrt(2); -end - -function val = a(n,m) -% just a factor see dis Zotter eq 146, (page 45) -if abs(m) > n - val = 0; -else - val = sqrt((n-abs(m)+1).*(n+abs(m)+1)/(2*n+1)/(2*n+3)); -end -end - -function val = b(n,m) -% just a factor see dis Zotter eq 146, (page 45) - -val = sign(m) .* sqrt((n-m-1).*(n-m)./(2*n-1)./(2*n+1)); -val(m==0 || m>n) = sqrt((n-1)*n/(2*n-1)/(2*n+1)); -end - -function out = d(x,m) -% kronecker delta -out = zeros(size(x)); -out(x~=m)=0; -out(x==m)=1; -end - -function lin = nm2N(n,m) -if length(n) > 1, error(' '); end -lin = n^2+n+1+m; -end diff --git a/applications/SphericalHarmonics/ita_sph_sampling_GfAI_array.m b/applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_GfAI_array.m similarity index 100% rename from applications/SphericalHarmonics/ita_sph_sampling_GfAI_array.m rename to applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_GfAI_array.m diff --git a/applications/SphericalHarmonics/ita_sph_sampling_GfAI_array_xml.m b/applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_GfAI_array_xml.m similarity index 100% rename from applications/SphericalHarmonics/ita_sph_sampling_GfAI_array_xml.m rename to applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_GfAI_array_xml.m diff --git a/applications/SphericalHarmonics/ita_sph_sampling_dodecahedron_physical.m b/applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_dodecahedron_physical.m similarity index 100% rename from applications/SphericalHarmonics/ita_sph_sampling_dodecahedron_physical.m rename to applications/SphericalHarmonics/ita_sph_sampling/ita_sph_sampling_dodecahedron_physical.m diff --git a/applications/SphericalHarmonics/ita_sph_sampling_visualize.m b/applications/SphericalHarmonics/ita_sph_sampling_visualize.m deleted file mode 100644 index 473ec2aed4a886ec4860af30653dd719a6f38c2d..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_sampling_visualize.m +++ /dev/null @@ -1,49 +0,0 @@ -function s = ita_sph_sampling_visualize(s, twistCable) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -if nargin < 2 - twistCable = true; -end - -ita_sph_plot_SH(0, {s.weights, s}, 'type','sphere','FaceAlpha',0.5) - -% input('press a key for evaluation a route (this can take a while)'); - -% theta = pi/2 - sph.theta; -% phi = sph.phi; - -% P = eye(length(phi)); -% for iCurrent = 1:(length(s.weights)-1) -% disp(['evaluating point nr. ' num2str(iCurrent)]) -% clear dist az; -% for iNext = 1:(length(s.weights)-iCurrent) -% % freely find a route -% [dist(iNext), az(iNext)] = distance(pi/2-s.coord(iCurrent,1),s.coord(iCurrent,2),... -% pi/2-s.coord(iCurrent+iNext,1),s.coord(iCurrent+iNext,2),'Radians'); -% if ~twistCable % dont twist the cable, no jump between -pi and pi -% dist(iNext) = sqrt((s.coord(iCurrent,1) - s.coord(iCurrent+iNext,1)).^2 ... -% + ( rem(s.coord(iCurrent,2) - s.coord(iCurrent+iNext,2),2*pi) ).^2); -% end -% end -% % weight to get a higher use of azimuthal movement (turntable) instead of arm -% [void,iMin] = min(dist .* (1.5 - abs(sin(az))) ); -% s = permute_sph(s, iCurrent+1, iCurrent+iMin); -% end -% -% [x,y,z] = sph2cart(s.coord(:,2), pi/2-s.coord(:,1), 1); -% hold all; -% plot3(x,y,z,'LineWidth',3); -% hold off; -% end -% -% function s = permute_sph(s,a,b) -% s.coord([a b],:) = s.coord([b a],:); -% s.weights([a b],:) = s.weights([b a],:); -% s.Y([a b],:) = s.Y([b a],:); -% end \ No newline at end of file diff --git a/applications/SphericalHarmonics/ita_sph_surf_SH.m b/applications/SphericalHarmonics/ita_sph_surf_SH.m deleted file mode 100644 index 0932ec48ee2d086ef4906747a5445b0df7e9784f..0000000000000000000000000000000000000000 --- a/applications/SphericalHarmonics/ita_sph_surf_SH.m +++ /dev/null @@ -1,68 +0,0 @@ -function varargout = ita_sph_surf_SH(SHcoefs, varargin) - -% -% This file is part of the application SphericalHarmonics for the ITA-Toolbox. All rights reserved. -% You can find the license for this m-file in the application folder. -% - - -% This function plots the vector of spherical harmonic coefficients as a -% spherical function. If no sampling grid is given, loading an -% equiangular sampling grid -% -% Usage: -% h = ita_sph_surf_SH(SHcoefs, sampling, [opt. props]) - -ita_verbose_obsolete('Marked as obsolete. Please report to mpo, if you still use this function.'); - -persistent nmaxOld samplingOld - -% first check if there was a sampling given -sampling = []; -if nargin > 1 - if isa(varargin{1},'itaSamplingSph') - sampling = varargin{1}; - % and delete it from the other properties - varargin = varargin(2:end); - end -end - -% if there was no sampling given, create one -if isempty(sampling) - % check number of grid points - nrCoefs = numel(SHcoefs); - % convert to maximum order - % if in doubt (strange number of coefs) use more points (ceil) - nmax = ceil(sqrt(nrCoefs)-1); - - if isequal(nmaxOld,nmax) && ~isempty(samplingOld) - sampling = samplingOld; - else - sampling = ita_sph_sampling_equiangular(nmax); - % and set the values to remember - samplingOld = sampling; - nmaxOld = nmax; - end -end - -% check if Y is calculated already -if numel(sampling.Y) == 0 - error('Set nmax to evaluate the SH base.'); -end - -% now transform into a spatial function -spatial = sampling.Y * SHcoefs(:); - -% and call surf of itaCoordinates class -hFig = surf(sampling, spatial, varargin{:}); - -maxVal = max(abs(spatial(:))); -xlim([-maxVal maxVal]); -ylim([-maxVal maxVal]); -zlim([-maxVal maxVal]); - -if nargout - varargout = {hFig}; -else - varargout = {}; -end