ufrgs-gnss-lab / geo-alhazen

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

vectorial get_geocentric_angle #27

Closed fgnievinski closed 6 months ago

fgnievinski commented 1 year ago

check equivalence: $\theta=acos(\vec{R_s}/R_s\cdot\vec{R_a}/R_a)$

fgnievinski commented 1 year ago

code:

function geo_ang = get_geocentric_angle_vec (pos_ant_geo, pos_tgt_geo)

% Returns geocentric angle of a target (vectorial formulation)
%
% OUTPUT:
% - geo_ang: Target geocentric angle
% 
% INPUT:
% - pos_ant_geo: Antenna position (vector, in meters)
% - pos_tgt_geo: Target position (vector, in meters)
% 
% Notes: 
% - position vectors should be in geocentric frame
% - target may be surface or transmitter

%% Geocentric Angle:
dir_ant_geo = pos_ant_geo./norm(pos_ant_geo);
dir_tgt_geo = pos_tgt_geo./norm(pos_tgt_geo);
temp = dot(dir_tgt_geo, dir_ant_geo);
geo_ang = acosd(temp);

end
vitorhjr commented 1 year ago

Geocentric angle antenna - specular point

I corrected the formula to geo_ang = 2*acosd(temp)-90. It is producing results with a precision of 10e-7 degrees for an antenna height of 100m as it's shown below. image

I only have difficulty computing the vectorial formula at zenith exactly. At zenith, the code acosd(temp) sometimes results in 180° instead 90° because the Y coord. of specular points vary in positive and negative values. Although, the Y coord. is too much closer to zero (e.g. -10e-9 or +10e-9), this variation in sign is enough to cross the trigonometric circle from 90° to 180°.

Furthermore, there are cases at zenith in which the reflection point coordinates are exactly [0 0]. In these cases, the vectorial formula cannot compute the arc cosine.

vitorhjr commented 1 year ago

Geocentric angle antenna - transmitter

Apparently, the vectorial formula used to compute the geocentric angle between antenna and specular point is not applicable to compute the angle antenna-transmitter. The results produced are too much different from the results of https://github.com/vitorhjr/geo-alhazen/blob/main/geo-alhazen-aux/get_geocentric_angle.m#L48.

I think the geometric setup between antenna and transmitter doesn't allow to reuse the vectorial formula of the angle antenna-spec. point.

vitorhjr commented 1 year ago

You can run the demo1_geo_ang to attest my conclusions about the get_geocentric_angle_vec .

fgnievinski commented 1 year ago

@vitorhjr the input position vector coordinates should be in the geocentric frame, not the local frame. I've updated the code to make that requirement more explicit.

that way, it should work for the transmitter, too.

also, it should be geo_ang = acosd(temp);

vitorhjr commented 1 year ago

You're correct. I carried out wrong the tests with quasigeocentric coordinates. Now I'm getting coordinates as:

[~, g, ~, ~, X_spec, Y_spec, X_trans, Y_trans] = get_reflection_spherical(e_grid, Ha_grid, [], [], [], [], 'quasigeo');
pos_ant (2,:) = Rs+Ha_dom;

In this case, the code geo_ang = (acosd(temp)) works very well image

I'm going to update this in the repository.

vitorhjr commented 1 year ago

I updated get_geocentric_angle_vec.m. I add the word "geocentric" in the commentaries to alert the user and modified the geo angle to geo_ang = acosd(temp);.

vitorhjr commented 1 year ago

On the other hand, the code still not working for the geo angle between antenna and transmitter.

fgnievinski commented 1 year ago

how far off is the geocentric angle between antenna and transmitter -- could it be just 360-geo_ang?

vitorhjr commented 6 months ago

On the other hand, the code still not working for the geo angle between the antenna and transmitter.

I found the problem of why the closed-form and vectorial were not matching. The closed form has been computed to retrieve a radian angle as geo_ang_at=acos((D.^2 -(Ra).^2 -(Rt).^2)./(-2*(Ra).*(Rt)));.

Because of this, when I was comparing it with the vectorial - which retrieves an angle in degrees - the differences were big.

vitorhjr commented 6 months ago

Although get_geocentric_angle is computing correctly the two geocentric angles, the geo angle between antenna and transmitter is retrieved in radians while the angle between antenna and specular point is retrieved in degrees.

It could be corrected after splitting the two geo angles in https://github.com/ufrgs-gnss-lab/geo-alhazen/issues/25

vitorhjr commented 6 months ago

Finally, vectorial and closed-form geocentric angles showed a good agreement, especially the geo angle between antenna and specular point. These figures are to an antenna at 100 m. geoang_as geoang_at

vitorhjr commented 6 months ago

Something I find interesting is that discrepancies in the geocentric angle antenna-transmitter show almost same values and the same behavior for all heights, even if I simulate a height of 10 m or 1000 m. So, I think these discrepancies could be corrected by fitting a polynomial.

geoang_at

vitorhjr commented 6 months ago

So, vectorial geocentric angle computation (https://github.com/ufrgs-gnss-lab/geo-alhazen/blob/main/geo-alhazen-aux/get_geocentric_angle_vec.m) is working well.