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
Helical sweep (§5.7): sweep a CLOSED PLANAR profile loop along a helix of
helix_radius about the axis through axis_origin with direction
axis_direction, rising pitch per revolution for turns revolutions.
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.
KNOWN LIMITATION: whole-turn shallow helixes (pitch ≲ 0.63·R) are rejected
by the loft’s cap-plane guard (|n·axis| ≥ 0.1 — the end-to-end axis is
purely axial while the cap normal is nearly tangential); the error
propagates honestly rather than being worked around.