import math

# --- General Constants ---
PI = math.pi

# --- Angle Conversion (ICD 1553 Semicircles) ---
SEMICIRCLE_LSB = 3.05176E-05
SEMICIRCLE_RAD_LSB = SEMICIRCLE_LSB * PI
GEOPOS_SC_LSB = 4.65661E-10
GEOPOS_RAD_LSB = GEOPOS_SC_LSB * PI
ATTITUDE_RATE_SC_LSB = 1.22070E-04
ATTITUDE_RATE_RAD_LSB = ATTITUDE_RATE_SC_LSB * PI
WAYPOINT_LATLON_LSB = 5.96046E-08 * PI

RAD_TO_DEG = 180.0 / PI
DEG_TO_RAD = PI / 180.0

# --- Distance and Speed ---
NM_TO_METERS = 1852.0
METERS_TO_FEET = 3.280839895
FEET_TO_METERS = 1.0 / METERS_TO_FEET

MS_TO_KNOTS = 3600.0 / NM_TO_METERS
KNOTS_TO_MS = 1.0 / MS_TO_KNOTS

TAS_KNOTS_LSB = 0.125
TAS_MS_LSB = TAS_KNOTS_LSB * KNOTS_TO_MS

CAS_KNOTS_LSB = 1.0
CAS_MS_LSB = CAS_KNOTS_LSB * KNOTS_TO_MS

# --- Altitude and Physics ---
RADIO_ALT_FEET_LSB = 2.0
RADIO_ALT_METERS_LSB = RADIO_ALT_FEET_LSB * FEET_TO_METERS

BARO_ALT_FEET_LSB = 4.0
BARO_ALT_METERS_LSB = BARO_ALT_FEET_LSB * FEET_TO_METERS

SPOI_ALT_FEET_LSB = 1.0
SPOI_ALT_METERS_LSB = SPOI_ALT_FEET_LSB * FEET_TO_METERS

VELOCITY_FEET_LSB = 3.81470E-06
VELOCITY_METERS_LSB = VELOCITY_FEET_LSB * FEET_TO_METERS

ACCELERATION_FEET_LSB = 0.03125
ACCELERATION_METERS_LSB = ACCELERATION_FEET_LSB * FEET_TO_METERS

CRS_SLAVE_RNG_METERS_LSB = 8.0 * FEET_TO_METERS

# --- Time ---
TIMETAG_MICROSECONDS_LSB = 64