UWBIns/lib/gnss/satellite_az_el.m

26 lines
667 B
Matlab
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

function [az, el] = satellite_az_el(SP, RP)
%% 计算卫星俯仰角(el), 和方位角(az)
% get_satellite_az_el: computes the satellite azimuth and elevation
% given the position of the user and the satellite in ECEF
% : SP: 卫星位置ECEF
% RP: 用户位置ECEF
% Output Args:
% az: azimuth: 方位角
% el: elevation 俯仰角
% 参考 GPS 原理及接收机设计 谢刚
[lat, lon, ~] = ch_ECEF2LLA(RP);
C_ECEF2ENU = [-sin(lon) cos(lon) 0; -sin(lat)*cos(lon) -sin(lat)*sin(lon) cos(lat); cos(lat)*cos(lon) cos(lat)*sin(lon) sin(lat)];
enu = C_ECEF2ENU*[SP - RP];
% nroamlized line of silght vector
enu = enu / norm(enu);
az = atan2(enu(1), enu(2));
el = asin(enu(3)/norm(enu));
end