ufrgs-gnss-lab / geo-alhazen

Modeling of reflection on a sphere
1 stars 0 forks source link

Infinite distance (trigonometric): merge into main function? #32

Open fgnievinski opened 1 year ago

fgnievinski commented 1 year ago

it seems the support for infinite distance could be accommodated in the main function, get_spherical_reflection:

function [delay, graz_ang, arc_len, slant_dist, x_spec, y_spec, x_trans, y_trans, elev_spec] = ...
            get_spherical_reflection (e, Ha, Ht, Rs, algorithm, trajectory, frame, infinite)
    % (...)
    if (nargin < 8),  infinite = [];  end
    if isempty(infinite),  infinite = false;  end
    % (...)
    %% Additional parameters
    [delay, arc_len, slant_dist, elev_spec] = get_spherical_reflection_extra (...
        n2, Ha, Rs, geo_ang, x_spec, y_spec, x_trans, y_trans);
    if infinite
        [delay, slant_dist] = get_spherical_reflection_extra_infinite (g, e, e_spec, Ha, Rs);
    end

where the subfunction is:

function [Di, sldist]= get_spherical_reflection_extra_infinite (g, e, e_spec, Ha, Rs)

Ra = Rs+Ha;
gamma = (Ra./Rs).^2-cosd(g).^2;
sldist = Rs.*(sqrt(gamma)-sind(g));
der = e-e_spec; % or der = -(-e+e_spec) (master thesis incorrect)
Di = sldist.*(1-cosd(der));
% Di1 = sldist.*(1-cosd(2.*e+der)); % #WRONG! (master thesis incorrect)

end

to avoid disruption, the existing code would become just an interface:

function [Di, sldist, g, gamma, der] = get_spherical_reflection_trig (e, Ha, Rs, optnum)
    if (nargin < 3) || isempty(Rs);  Rs = get_earth_radius();  end
    if (nargin < 4) || isempty(optnum);  optnum = struct();  end
    if isfieldempty (optnum, 'Ht'),  optnum.Ht = [];  end
    if isfieldempty (optnum, 'algorithm'),  optnum.algorithm = [];  end
    if isfieldempty (optnum, 'trajectory'),  optnum.trajectory = [];  end
    if isfieldempty (optnum, 'frame'),  optnum.frame = [];  end
    optnum.infinite = true;
    [Di, g, ~, sldist] = get_spherical_reflection (e, Ha, optnum.Ht, Rs, ...
        optnum.algorithm, optnum.trajectory, optnum.frame, optnuminfinite);
end

question: what's gamma -- geocentric angle?