nx_q14_math.nx
buildroot/runtime/nx_q14_math.nx
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
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
| 20 | const NX_Q14: nx_int = 16384 |
| 21 | const NX_Q14_2PI: nx_int = 102944 // 2π in Q14 |
| 22 | const NX_Q14_PI: nx_int = 51472 // π in Q14 |
functions
| 26 | func nx_q14_abs(x: nx_int) -> nx_int |
| 33 | func nx_q14_sign(x: nx_int) -> nx_int called by 1: main |
| 41 | func nx_q14_clamp(x: nx_int, lo: nx_int, hi: nx_int) -> nx_int called by 1: main |
| 53 | func nx_q14_mul(a: nx_int, b: nx_int) -> nx_int called by 1: main |
| 61 | func nx_q14_div(a: nx_int, b: nx_int) -> nx_int called by 1: main |
| 72 | func nx_q14_sqrt(v: nx_int) -> nx_int |
| 91 | func _sin_lut(idx: nx_int) -> nx_int called by 1: nx_q14_sin |
| 117 | func nx_q14_sin(angle_q14: nx_int) -> nx_int |
| 152 | func nx_q14_cos(angle_q14: nx_int) -> nx_int |
| 158 | func nx_q14_vec3_dot(ax: nx_int, ay: nx_int, az: nx_int, |
| 168 | func nx_q14_vec3_length(x: nx_int, y: nx_int, z: nx_int) -> nx_int |
| 178 | func nx_q14_vec3_normalize(x_q14: nx_int, y_q14: nx_int, z_q14: nx_int, |
| 195 | func nx_q14_vec3_cross(ax: nx_int, ay: nx_int, az: nx_int, called by 1: main |