@@ -48,7 +48,7 @@ def geodetic_to_ecef(
4848 return x , y , z
4949
5050
51- def ecef_to_geodetic (x : float , y : float , z : float ) -> tuple [float , float , float ]:
51+ def ecef_to_geodetic (x_ecef : float , y_ecef : float , z_ecef : float ) -> tuple [float , float , float ]:
5252 """
5353 Converts Earth-Centered, Earth-Fixed (ECEF) coordinates to
5454 Geodetic coordinates (Latitude, Longitude, Altitude) using Bowring's method.
@@ -60,24 +60,24 @@ def ecef_to_geodetic(x: float, y: float, z: float) -> tuple[float, float, float]
6060 >>> round(lat, 2), round(lon, 2), round(alt, 2)
6161 (90.0, 0.0, 0.0)
6262 """
63- p = math .sqrt (x ** 2 + y ** 2 )
63+ p = math .sqrt (x_ecef ** 2 + y_ecef ** 2 )
6464
6565 # Handle the special case where the point is exactly at the poles
6666 if p == 0 :
6767 lon_deg = 0.0
68- lat_deg = 90.0 if z > 0 else - 90.0
69- alt_m = abs (z ) - WGS84_B
68+ lat_deg = 90.0 if z_ecef > 0 else - 90.0
69+ alt_m = abs (z_ecef ) - WGS84_B
7070 return lat_deg , lon_deg , alt_m
7171
72- theta = math .atan2 (z * WGS84_A , p * WGS84_B )
72+ theta = math .atan2 (z_ecef * WGS84_A , p * WGS84_B )
7373
7474 sin_theta = math .sin (theta )
7575 cos_theta = math .cos (theta )
7676
7777 # Calculate exact latitude and longitude
78- lon_rad = math .atan2 (y , x )
78+ lon_rad = math .atan2 (y_ecef , x_ecef )
7979 lat_rad = math .atan2 (
80- z + WGS84_EP_SQ * WGS84_B * sin_theta ** 3 ,
80+ z_ecef + WGS84_EP_SQ * WGS84_B * sin_theta ** 3 ,
8181 p - WGS84_E_SQ * WGS84_A * cos_theta ** 3 ,
8282 )
8383
@@ -92,7 +92,7 @@ def ecef_to_geodetic(x: float, y: float, z: float) -> tuple[float, float, float]
9292
9393
9494def enu_to_ecef (
95- e : float , n : float , u : float , ref_lat_deg : float , ref_lon_deg : float
95+ east : float , north : float , up : float , ref_lat_deg : float , ref_lon_deg : float
9696) -> tuple [float , float , float ]:
9797 """
9898 Rotates East-North-Up (ENU) offset coordinates to ECEF offset coordinates,
@@ -111,9 +111,9 @@ def enu_to_ecef(
111111 cos_lon = math .cos (lon_rad )
112112
113113 # Rotation matrix components for ENU to ECEF
114- dx = - sin_lon * e - sin_lat * cos_lon * n + cos_lat * cos_lon * u
115- dy = cos_lon * e - sin_lat * sin_lon * n + cos_lat * sin_lon * u
116- dz = cos_lat * n + sin_lat * u
114+ dx = - sin_lon * east - sin_lat * cos_lon * north + cos_lat * cos_lon * up
115+ dy = cos_lon * east - sin_lat * sin_lon * north + cos_lat * sin_lon * up
116+ dz = cos_lat * north + sin_lat * up
117117
118118 return dx , dy , dz
119119
@@ -151,15 +151,15 @@ def calculate_target_coordinates(
151151
152152 # Standard spherical to cartesian for ENU
153153 # North is aligned with 0 degrees Azimuth, East is 90 degrees
154- e = range_m * math .cos (el_rad ) * math .sin (az_rad )
155- n = range_m * math .cos (el_rad ) * math .cos (az_rad )
156- u = range_m * math .sin (el_rad )
154+ east = range_m * math .cos (el_rad ) * math .sin (az_rad )
155+ north = range_m * math .cos (el_rad ) * math .cos (az_rad )
156+ up = range_m * math .sin (el_rad )
157157
158158 # Step 2: Get absolute ECEF position of the Radar
159159 radar_x , radar_y , radar_z = geodetic_to_ecef (radar_lat , radar_lon , radar_alt )
160160
161161 # Step 3: Convert the Local ENU offsets to ECEF offsets
162- dx , dy , dz = enu_to_ecef (e , n , u , radar_lat , radar_lon )
162+ dx , dy , dz = enu_to_ecef (east , north , up , radar_lat , radar_lon )
163163
164164 # Step 4: Add offsets to the Radar's ECEF coordinates to find Target ECEF
165165 target_x = radar_x + dx
0 commit comments