Skip to main content

Crate molgfx_math

Crate molgfx_math 

Source
Expand description

glam-based math foundation: cameras, projections, bounds, splines, transport frames.

Conventions carried by every type here: the world unit is the Ångström, all spaces are right-handed with +X right, +Y up and +Z toward the viewer, the camera looks down −Z, and clip depth uses the reversed [0, 1] range (near maps to 1.0, far to 0.0) so floating-point depth precision spreads evenly across a molecular scene.

Re-exports§

pub use parallel::BLOCK;
pub use parallel::map_zip_blocks_into;

Modules§

parallel
Threshold-guarded data parallelism with a thread-count-independent shape.
simd
Width-agnostic kernels over the columns the load path sweeps.

Structs§

Aabb
An axis-aligned bounding box in whichever space its points came from.
BoundingSphere
A sphere enclosing a set of geometry; the shape cameras frame against.
Bvh
Flat hierarchy and stable source-primitive permutation.
BvhBuildError
A hierarchy offset cannot be represented by the GPU node layout.
BvhBuildScratch
Reusable construction workspace. Keeping it beside a dynamic structure makes trajectory-driven hierarchy rebuilds allocation-free after warmup.
BvhNode
One compact BVH node. Internal children are adjacent; leaves address the hierarchy’s primitive-index array.
Camera
A look-at camera in world space (right-handed, +Y up, looking down −Z in its own view space).
CurveSample
One sampled point and unit tangent along a spline.
Mat3
A column-major 3×3 matrix.
Mat4
A SIMD-aligned column-major 4×4 matrix.
Quat
A SIMD-aligned quaternion stored as (x, y, z, w).
Rgba8
A color packed as four 8-bit channels, in memory order red, green, blue, alpha. Exactly four bytes, so a per-atom color column stays compact and uploads without conversion.
SphereBounds
Bounds derived from a position column and a radius column.
SweptSphereBounds
Bounds swept between two position columns sharing one radius column.
TransportFrame
Orthonormal frame carried along a curve.
Vec2
A two-component single-precision vector.
Vec3
A three-component single-precision vector.
Vec4
A four-component SIMD-aligned single-precision vector.

Enums§

Projection
How a camera maps view space to clip space.

Traits§

BvhSource
A random-access supply of primitive bounds.

Functions§

parallel_transport
Builds minimal-rotation frames into caller-owned storage. The initial axis is selected deterministically to avoid degeneracy near a world axis.
round_u8
Rounds a value already expressed in 0..=255 units, ties upward.
sample_catmull_rom
Samples a centripetal-looking uniform Catmull-Rom trace with more samples where midpoint deviation and tangent change are high. Output storage is caller-owned and reused; work and output are bounded by max_steps.
sample_catmull_rom_demanding
Adaptive sampling with one extra per-interval demand the curve cannot see.
sample_catmull_rom_fixed
Fixed-step Catmull-Rom sampling: the form a GPU kernel evaluates in parallel, one invocation per sample. The basis is identical to sample_catmull_rom — only the per-segment step count is a constant instead of curvature-adaptive — so this doubles as the CPU parity reference for the spline compute shader. Output storage is caller-owned and reused.
sample_cubic_bezier
Samples a cubic Bezier segment, including both endpoints.
truncate_u16
Truncates a non-negative value to u16, saturating at the maximum.
unit_to_grid
Truncates a unit value onto a grid of levels + 1 steps.
unorm8
Rounds a unit value to unorm8 with ties resolved upward.