surf.m 2.27 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
13
14
15
% sArgs        = struct('pos1_data','double', 'parent', 0);
% [input,sArgs] = ita_parse_arguments(sArgs,varargin); 


numArgIn = nargin;


16
17
18
titleString = [];

uniformPlot = 0;
19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% this is the plot to a uniform sphere
if numArgIn == 3 && varargin{1} == 1
    tmp = varargin{2};
    clear varargin
    varargin{1}= tmp;
    clear tmp
    
    uniformPlot = 1;
    numArgIn = 2;
    
end


if numArgIn == 2
    % 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
    
        ita_verbose_info('This must be SH vector, transforming to spatial domain')
%         ita_verbose_info('TODO: all results are currenty mirrowed at the x-z axis, I think. Take care!!!',0)
        
        nSHGrid = size(this.Y,2);
        nSHData = size(varargin{1}(:),1);
        if nSHGrid ~= nSHData
%             error('the spherical harmonics dimensions don''t fit');            
            % 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);
            end
        end
        % 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
        disp(['plotting SH-coefficients up to order ' num2str(this.nmax)]);
        nmaxVec = ceil(sqrt(nSHData)-1);
        titleString = ['Spherical Harmonics coefficients, nmax = ' num2str(nmaxVec) '/' num2str(this.nmax) ' (data/grid)'];
    end
end

if uniformPlot
   varargin{2} =  varargin{1};
   varargin{1} = 1;
end

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

% set title
if numel(titleString)
    title(titleString);
end

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