code wiki / (root) / nx_q14_math.nx

nx_q14_math.nx

buildroot/runtime/nx_q14_math.nx

6840 B202 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind librarytopic q14
docsdependenciesstructsconstsfunctions

about

nx_q14_math.nx -- fixed-point math library. Q14 throughout: 16384 = 1.0. Range ~ ±131071 (suitable for game world coordinates, direction vectors, camera transforms). NO floating point — Cortex-M0+ compatible. Shared library: nx_raycast_voxel + nx_camera_q14 + nx_world_seed all use these helpers instead of hand-rolling. Operations: abs / sign sqrt (Newton's method, 8 iterations) sin / cos (16-entry lookup + linear interpolation) normalize (vec3 to unit length) dot / cross (vec3 products)

dependencies 2 imports · 5 importers

nx_syscalls.nx nx_tier.nx nx_q14_math.nx nx_collision_aabb.nx nx_collision_aabb_test.nx nx_game_engine_compose_test.nx nx_game_runtime_compose_test.nx nx_q14_math_test.nx

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_collision_aabb.nxnx_collision_aabb_test.nxnx_game_engine_compose_test.nxnx_game_runtime_compose_test.nxnx_q14_math_test.nx

structs

none

consts

20const NX_Q14: nx_int = 16384
21const NX_Q14_2PI: nx_int = 102944 // 2π in Q14
22const NX_Q14_PI: nx_int = 51472 // π in Q14

functions

26func nx_q14_abs(x: nx_int) -> nx_int
called by 2: mainmain
33func nx_q14_sign(x: nx_int) -> nx_int
called by 1: main
41func nx_q14_clamp(x: nx_int, lo: nx_int, hi: nx_int) -> nx_int
called by 1: main
53func nx_q14_mul(a: nx_int, b: nx_int) -> nx_int
called by 1: main
61func nx_q14_div(a: nx_int, b: nx_int) -> nx_int
called by 1: main
72func nx_q14_sqrt(v: nx_int) -> nx_int
91func _sin_lut(idx: nx_int) -> nx_int
called by 1: nx_q14_sin
117func nx_q14_sin(angle_q14: nx_int) -> nx_int
called by 3: mainnx_q14_cosmain calls 1: _sin_lut
152func nx_q14_cos(angle_q14: nx_int) -> nx_int
called by 2: mainmain calls 1: nx_q14_sin
158func nx_q14_vec3_dot(ax: nx_int, ay: nx_int, az: nx_int,
168func nx_q14_vec3_length(x: nx_int, y: nx_int, z: nx_int) -> nx_int
178func nx_q14_vec3_normalize(x_q14: nx_int, y_q14: nx_int, z_q14: nx_int,
called by 1: main calls 1: nx_q14_vec3_length
195func nx_q14_vec3_cross(ax: nx_int, ay: nx_int, az: nx_int,
called by 1: main