Skip to content

Rust geometry core via pyo3 (v2 performance path) #31

Description

@bamdadd

Context

The analytic core is pure NumPy in src/multicam_sim/geometry.py: look_at_rotation (30), projection_matrix (60), project_point (69), segment_intersects_sphere (84), segment_intersects_aabb (105). For large scenes (many cameras × frames × points × occluders) this is the hot path. A v2 performance path is a good candidate for a compiled core.

What to do (larger, happy to mentor)

Port the geometry primitives to a Rust extension via pyo3 + maturin, exposed as an optional module that mirrors the geometry.py function signatures. Keep the NumPy implementation as the default and fallback; select the Rust path behind a flag / optional extra so the package still installs and runs pure-Python. Start with project_point and the two segment-intersection tests (the occlusion inner loop), which dominate.

Acceptance criteria

  • A Rust project_point and segment_intersects_{sphere,aabb} return results identical to the NumPy versions within ~1e-9 across a randomized battery (parity test).
  • The Rust path is opt-in; with it absent, everything works on the pure-Python core and all existing tests pass.
  • A short benchmark (Rust vs NumPy) on a representative scene, posted on the issue or in docs/.
  • Build wiring (maturin) documented; CI note for building the extension.

Pointers: geometry.py:30,60,69,84,105 (the port surface). Convention in DESIGN.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions