pub fn sweep_profile_helix(
profile: &[NurbsCurve],
axis_origin: Vec3,
axis_direction: Vec3,
helix_radius: f64,
pitch: f64,
turns: f64,
name: Option<&str>,
) -> Result<BrepSolid, String>Expand description
The helix is transcendental, not exactly NURBS-representable, so the path
is FIT: points (R·cosθ, R·sinθ, pitch·θ/2π) in the axis frame are sampled
uniformly in θ and globally interpolated with a cubic (interpolate_curve
— the same machinery every other fitted path here uses). DENSITY: 64
samples per turn, capped at 1025 total nodes. Cubic interpolation error
on a circle of radius R with node spacing Δθ is ≈ R·Δθ⁴/384: ~2·10⁻⁷·R at
64/turn, and still ~6·10⁻⁵·R at the cap’s worst case (16/turn at the
64-turn limit) — orders below any profile a caller could sweep without
self-intersecting. Uniform-in-θ parameters are exact chord-length for a
helix (constant speed), which is what the averaged-knot interpolation
assumes.
The fitted path then drives the EXISTING path-sweep core with 32 stations per turn (min 32, capped at 1024 — the loft’s dense interpolation solve is O(stations³) per control column, so the cap trades per-turn density, never correctness, at high turn counts).
GUARDS beyond the path sweep’s own: the path sweep documents self-intersection as caller responsibility, so the helix variant — which knows its curvature analytically — rejects the two garbage modes itself: • fold-over: the helix curvature radius (R² + c²)/R (c = pitch/2π) must exceed the profile’s max extent about its centroid, or the tube folds through itself on the inner side (the torus tube-radius > major-radius failure, pitch-relaxed); • coil collision (turns ≥ 1): the normal gap between consecutive coils, pitch·2πR/√((2πR)² + pitch²), must exceed the profile diameter. Both use the profile’s max sample distance from its centroid — conservative for asymmetric profiles (extent in a harmless direction still counts), but a false reject beats silent garbage.
SHALLOW COILS BUILD. They did not until 2026-09-08: the loft measured its
advance by the END-TO-END chord, which on a whole-turn helix is purely
AXIAL while both caps face nearly tangentially, so |n·chord| fell under
the loft’s 0.1 sliver band and everything with pitch ≲ 0.63·R — most
springs — was refused. The loft measures the advance at each END now
(loft_topology::basic::advance_from), which is the direction the tube
actually grows through the cap it is orienting, so the band only ever
catches a real sliver.