extends Node


var M2FT: float = 3.28084
var FT2M: float = 1/3.28084

var WGS84_A_M = 6378137.0
var WGS84_B_M = 6356752.314245
var EARTH_RADIUS_M = (2*WGS84_A_M + WGS84_B_M) / 3
var EARTH_RADIUS_KM = EARTH_RADIUS_M / 1000
#               8171221.7221355
var WGS84_AB = WGS84_A_M * WGS84_B_M

var g = 9.80665

	
func calc_time_diff(timestamp_1, timestamp_2):
	if timestamp_2 < 3600 and timestamp_1 > 82800:
		return (timestamp_2 + 86400) - timestamp_1
	return timestamp_2 - timestamp_1

func is_timestamp_newer(old_timestamp: float, new_timestamp: float) -> bool:
	if old_timestamp > 82800. and new_timestamp < 3600: # earlier than 23 hours
		return true
	return old_timestamp < new_timestamp

func calc_wgs84_altitude(latitude_rad: float):
	var theta_rad = abs(latitude_rad)
	var a_sin_2 = (WGS84_A_M ** 2) * (sin(theta_rad)**2)
	var b_cos_2 = (WGS84_B_M ** 2) * (cos(theta_rad)**2)
	return WGS84_AB / sqrt(a_sin_2 + b_cos_2)
