nx_bvhfk_lib.nx
buildroot/runtime/nx_bvhfk_lib.nx
about
nx_bvhfk_lib.nx -- SHARED BVH FORWARD-KINEMATICS CORE (fk_eval + integer matrix substrate).
Extracted 2026-08-13 when the SECOND consumer appeared (nx_clipcheck's bvh self-clearance
control lane needs world positions per frame) rather than copy-pasting the FK into it --
Rule 15, and the standing law: EXTRACT THE FIX, DON'T RE-TYPE IT. The functions below are
MOVED VERBATIM from nx_bvhfk.nx; that organ's KAT (bone-length isometry proven on real
third-party mocap) remains the proof that this extraction is value-identical.
SEMANTICS (BVH is specific and easy to get subtly wrong):
world_rot[j] = world_rot[parent] * R_local[j]
world_pos[j] = world_pos[parent] + world_rot[parent] * offset[j]
R_local is the product of that joint's rotation channels IN THE ORDER THE FILE LISTS THEM
(commonly ZXY, but the file decides -- never the convention).
The root additionally consumes its position channels as a translation.
UNITS: positions in file units x B_SCALE (1000) -- BVH does not state its unit; the convention
is centimetres, so we do not claim mm. Angles arrive as millidegrees and are converted to the
it_* integer-trig circle (25736 units) -- never to floats.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 2 importers
imports: nx_bvh_lib.nxnx_itrig.nxnx_vecmath.nx
imported by: nx_bvhfk.nxnx_clipcheck.nx
structs
| none |
consts
| 24 | const FK_ONE: i64 = 65536 // matrices carry fx16, not the trig table's fx12 -- see fk_ortho |
| 25 | const FK_TRIGUP: i64 = 16 // it_* tables are x4096; lift to x65536 for matmul headroom |
| 26 | const FK_HALF: i64 = 32768 // round-to-nearest, not truncate-toward-zero |
| 27 | const FK_CIRCLE: i64 = 25736 |
| 28 | const FK_MDEG: i64 = 360000 |
functions
| 30 | func fk_ang(md: i64) -> i64 called by 1: fk_axis |
| 37 | func fk_ident(m: *i64) -> i64 called by 1: fk_eval |
| 44 | func fk_axis(code: i64, md: i64, m: *i64) -> i64 |
| 69 | func fk_mul(a: *i64, b: *i64, c: *i64) -> i64 called by 1: fk_eval |
| 87 | func fk_xform(m: *i64, vx: i64, vy: i64, vz: i64, out: *i64) -> i64 called by 1: fk_eval |
| 103 | func fk_ortho(m: *i64) -> i64 |
| 127 | func fk_isqrt(v: i64) -> i64 { return vm_isqrt(v) } |
| 129 | func fk_dist(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64) -> i64 |
| 137 | func fk_eval(H: *i64, parent: *i64, nchan: *i64, chan0: *i64, off: *i64, chtype: *i64, |