Shared Math Utilities
Overview
services/tick-engine/src/math_utils.py centralises physical constants and
basic vector operations used across the tick-engine service. Before this
module, each file defined its own copies of _G, STANDARD_GRAVITY, and
vector helpers, risking value drift and duplication.
Constants
| Symbol | Value | Description |
|---|---|---|
_G |
6.6743e-11 |
Gravitational constant (m^3 kg^-1 s^-2) |
TWO_PI |
2 * math.pi |
Full circle in radians |
STANDARD_GRAVITY |
9.80665 |
Standard gravitational acceleration (m/s^2) |
Vector functions (3-tuples)
vec_mag(v)– magnitudevec_sub(a, b)– subtraction (a - b)vec_add(a, b)– addition (a + b)vec_scale(v, s)– scalar multiplicationvec_dot(a, b)– dot productvec_cross(a, b)– cross productvec_normalize(v)– unit vector (returns zero if magnitude < 1e-10)
Redis extraction
extract_pos(data)– position tuple from Redis hash dictextract_vel(data)– velocity tuple from Redis hash dictextract_pos_vel(data)– (position, velocity) pair from Redis hash dict
Import chain
Modules that previously defined their own copies now import from
math_utils and re-export under underscore-prefixed names for backward
compatibility:
automation_helpersre-exportsSTANDARD_GRAVITY,_extract_pos,_extract_pos_vel,_vec_mag,_vec_sub,_vec_dot,_vec_normalizeautomation_orbitalre-exports_Gorbitalimports_G as G
Downstream modules (automation_maneuvers, maneuver_interplanetary,
maneuver_landing, maneuver_ascent, trajectory_planner) import through
these chains or directly from math_utils.
qlaw.py retains its own independent _G and vector math for performance
isolation.