| Crates.io | lumen-geometry |
| lib.rs | lumen-geometry |
| version | 0.1.0 |
| created_at | 2026-01-15 04:27:01.290285+00 |
| updated_at | 2026-01-15 04:27:01.290285+00 |
| description | Mathematical models for tubular anatomical structures (colon, bronchi, intestines) |
| homepage | |
| repository | https://github.com/via-balaena/lumen-geometry |
| max_upload_size | |
| id | 2044574 |
| size | 58,489 |
Mathematical models for tubular anatomical structures.
This crate provides pure math for generating and querying the geometry of hollow organs like the colon, bronchi, and intestines. No game engine required - just math you can use anywhere.
"Lumen" is the medical term for the interior space of a tubular organ (from Latin lumen, meaning "light" or "opening").
use lumen_geometry::colon::{ColonConfig, ColonCurve};
use lumen_geometry::TubularCurve;
// Create a colon with default anatomical parameters
let config = ColonConfig::default();
let colon = ColonCurve::new(&config);
// Query positions along the centerline (t: 0.0 = rectum, 1.0 = cecum)
let rectum_pos = colon.position_at(0.0);
let transverse_pos = colon.position_at(0.5);
let cecum_pos = colon.position_at(1.0);
// Get the direction the tube is heading at any point
let forward = colon.tangent_at(0.3);
// Query wall position including haustra (pouches)
let wall_point = colon.wall_position_at(0.3, std::f32::consts::PI);
The human colon is approximately 1.5 meters long and consists of anatomically distinct regions:
t=0.0 t=1.0
│ │
▼ ▼
Rectum → Sigmoid → Descending → Splenic → Transverse → Hepatic → Ascending → Cecum
Flexure Flexure
| Segment | t-range | Characteristics |
|---|---|---|
| Rectum | 0.00-0.08 | Entry point, relatively straight |
| Sigmoid | 0.08-0.20 | S-shaped curve, highly variable between individuals |
| Descending | 0.20-0.35 | Runs down the left side of abdomen |
| Splenic Flexure | 0.35-0.40 | Sharp ~90° bend near the spleen |
| Transverse | 0.40-0.65 | Crosses abdomen horizontally |
| Hepatic Flexure | 0.65-0.70 | Sharp ~90° bend near the liver |
| Ascending | 0.70-0.90 | Runs up the right side of abdomen |
| Cecum | 0.90-1.00 | Pouch at terminus, connects to small intestine |
The colon wall has characteristic sac-like pouches called haustra, formed by:
Taenia 1 (0°)
│
╭─────┴─────╮
╱ ╲
│ Haustrum │
╲ ╱
╰─────┬─────╯
│
Taenia 2 (120°)
Different seeds produce anatomically plausible variations:
use lumen_geometry::colon::{ColonConfig, ColonCurve};
// Same anatomy every time
let standard = ColonCurve::new(&ColonConfig::default());
// Procedurally varied
let patient_a = ColonCurve::new(&ColonConfig::with_seed(42));
let patient_b = ColonCurve::new(&ColonConfig::with_seed(123));
Seeds affect:
Position along the curve is expressed as t ∈ [0.0, 1.0]:
t = 0.0 → Rectum (entry point)t = 1.0 → Cecum (end)Physical distance along the curve (in world units). Convert between t and arc length:
use lumen_geometry::TubularCurve;
// Travel 10 units forward from t=0.3
let new_t = colon.advance_by_arc(0.3, 10.0);
// Get arc length to a specific t
let distance = colon.t_to_arc(0.5);
At any point, you can get a local coordinate system:
use lumen_geometry::TubularCurve;
let tangent = colon.tangent_at(0.5);
let normal = colon.normal_at(0.5);
let binormal = colon.binormal_at(0.5);
let frame = colon.frame_at(0.5); // As a quaternion
This crate only depends on:
glam - Standard 3D math (Vec3, Quat)rand / rand_chacha - Deterministic random number generationUse it with Bevy, Godot, Unity (via FFI), or plain Rust.
Licensed under either of:
at your option.