Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

mathx Module

Public Luau surface over the __mathx Internal FFI namespace — batch math kernels that operate on buffer slices.

Purpose

Wrap the SIMD-friendly batch ops exposed by Rust (damp, lerp, slerp, normalize, accumulate, transform) in a typed Luau table that gets auto-injected as _G.mathx via the prelude. Single-value forms are out of scope — Luau handles those at sub-µs cost and an FFI hop would dominate.

For element-wise NumPy-style ops on typed buffers, prefer the nx module; mathx is the slice-and-target form for specific position / orientation / quaternion shapes.

Usage

-- Critically-damped scalar follow
mathx.dampScalar(buf, 0, 16, 0.0, 0.16, dt)

-- Lerp every vec3 in a slice toward a target
mathx.lerpVec3(positions, 0, n, 0, 1, 0, 0.5)

-- Slerp every quat toward a target rotation
mathx.slerpQuat(rotations, 0, n, 0, 0, 0, 1, 0.25)

-- particle integration: pos += vel * dt
mathx.addScaledVec3(positions, velocities, n, dt)

-- transform vec3 positions by a 4x4 world matrix
mathx.transformVec3(positions, 0, n, worldMatrix)

Exports

  • mathx.dampScalar(buf, off, count, target, smoothTime, dt)
  • mathx.lerpVec3(buf, off, count, tx, ty, tz, t)
  • mathx.slerpQuat(buf, off, count, tx, ty, tz, tw, t)
  • mathx.normalizeQuat(buf, off, count)
  • mathx.addScaledVec3(dstBuf, srcBuf, count, scale)
  • mathx.transformVec3(buf, off, count, mat16)