Expand description
§Helix Noise
A divergence-free helical (Beltrami) spectral flow-field noise. The field is an analytic sum of divergence-free helical modes, so it can be evaluated grid-free at any point in space and time and its curl (vorticity) and vector potential come out in closed form. Handy for curl-noise particle advection, smoke and fluid-looking motion, procedural vector textures, and GPU flow shaders.
This crate is a port of the JavaScript helix-noise library with numerical parity: the
deterministic mulberry32 mode-construction stream is bit-identical, so a field built with
the same options and seed reproduces the reference values to floating-point tolerance.
The crate has zero runtime dependencies and no threads or I/O in the hot path, so it compiles cleanly to WebAssembly.
§Quickstart
use helix_noise::{HelixField, HelixOptions};
let field = HelixField::new(HelixOptions { seed: 42, modes: 48, ..Default::default() });
// Velocity at a point.
let u = field.sample(1.0, 2.0, 3.0);
// Velocity animated in time.
let u_t = field.sample_t(1.0, 2.0, 3.0, 0.5);
// Velocity + vorticity in one pass.
let (u, w) = field.sample_uw(1.0, 2.0, 3.0, 0.0);§Custom spectrum
use helix_noise::{HelixField, HelixOptions};
let field = HelixField::new(HelixOptions {
spectrum: Some(Box::new(|k: f64| (-k).exp())),
..Default::default()
});§Obstacles (free-slip boundary)
use helix_noise::{HelixField, HelixOptions, BoundaryOptions};
let field = HelixField::new(HelixOptions::default());
let bounded = field.with_boundary(
|x: f64, y: f64, z: f64| ((x - 3.0).powi(2) + (y - 3.0).powi(2) + (z - 3.0).powi(2)).sqrt() - 1.2,
BoundaryOptions { thickness: 0.9, ..Default::default() },
);
let u = bounded.sample(2.0, 2.0, 2.0, 0.0);§Scope
Covers both engines — the spectral HelixField and the sparse-atom HelixAtoms — plus
the free-slip SDF boundary (which wraps either) and the GLSL/shader emitter. The atom-engine
GLSL emitter of the JS reference is a documented follow-up and not yet ported.
Structs§
- Atom
Options - Options for constructing a
HelixAtomsfield. - Boundary
Options - Options for
HelixField::with_boundary. - Bounded
Field - A base flow field constrained by an SDF obstacle. Borrows the base field, which may be either
engine (anything implementing
VectorPotential). - Glsl
Options - Options for
HelixField::glsl. - Helix
Atoms - The sparse-atom engine. See the module docs.
- Helix
Field - A divergence-free helical flow field, evaluatable grid-free as an analytic sum of Beltrami
modes. Construct via
HelixField::neworHelixField::create. - Helix
Options - Options for constructing a
crate::HelixField. - Mode
Snapshot - A read-only snapshot of a field’s built per-mode spectral arrays. See
HelixField::mode_snapshot. - Mulberry32
- A
mulberry32generator. CallMulberry32::next_f64to draw the next uniform in[0, 1).
Enums§
- Layout
- Mode layout strategy.
Constants§
Traits§
- Vector
Potential - A divergence-free flow field that exposes its exact vector potential
A— the one requirement for the free-slip boundary wrapper. Implemented by both engines (HelixFieldandHelixAtoms), so any field can be wrapped with an obstacle.
Functions§
- ga
- Golden angle in radians — the Fibonacci-sphere azimuth increment.
Type Aliases§
- Scalar
Field3 - A spatially-varying scalar field
(x, y, z) -> value, sampled once at each atom’s center. - Spectrum
Fn - A user-supplied spectral amplitude law
|k| -> amplitude.