surf.m 1.77 KB
Newer Older
1 2 3 4 5 6 7 8
function varargout = surf(this, varargin)

% <ITA-Toolbox>
% 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-Toolbox>


9 10 11 12
% sArgs        = struct('pos1_data','double', 'parent', 0);
% [input,sArgs] = ita_parse_arguments(sArgs,varargin); 


13
titleString = [];
14

15 16 17 18 19
% check if SH coefs are given
if numel(varargin{1}) > 0 &&...
    this.nPoints ~= numel(varargin{1})     &&...
    numel(this.Y) > 0       &&...
    size(this.Y,1) == this.nPoints
20

21
    ita_verbose_info('This must be SH vector, transforming to spatial domain')
22
%         ita_verbose_info('TODO: all results are currenty mirrowed at the x-z axis, I think. Take care!!!',0)
23 24 25 26 27 28 29 30 31

    nSHGrid = size(this.Y,2);
    nSHData = size(varargin{1}(:),1);
    if nSHGrid ~= nSHData
        % TODO make autofit
        if nSHGrid > nSHData
            varargin{1} = [varargin{1}(:); zeros(nSHGrid - nSHData,1)];
        else
            ita_verbose_info('Insufficient grid, I cannot plot the full SH spectrum',0);
32 33
        end
    end
34 35 36 37 38 39
    % apply IDSHT:      
    varargin{1} = this.Y * varargin{1}(:);
    if size(this.Y,2)>1 && ~all(isreal(this.Y(:,2))) && all(isreal(varargin{1}))
        % change to complex drawing mode, if complex base is used
        varargin{1}(1) = varargin{1}(1) + 1i * eps;
    end
40
    ita_verbose_info(['plotting SH-coefficients up to order ' num2str(this.nmax)],2);
41 42
    nmaxVec = ceil(sqrt(nSHData)-1);
    titleString = ['Spherical Harmonics coefficients, nmax = ' num2str(nmaxVec) '/' num2str(this.nmax) ' (data/grid)'];
43 44
end

45

46 47 48 49

hFig = {surf@itaCoordinates(this, varargin{:})};

% set title
50
if ~isempty(titleString)
51 52 53 54 55 56 57 58 59
    title(titleString);
end

if nargout
    varargout = {hFig};
else
    varargout = {};
end