Parametric Helical Coil (Spring)
An experiment to create an accurate helical coil in OpenSCAD using the linear_extrude function.
In order for this to work, a polygon representing the end section of the spring had to be calculated first.
To derive this equation
1) Started with a circle representing the cross section of a round wire.
2) This wire will be angled by the spring's pitch angle, so the cross section gets stretched into an ellipse by scaling one of the axis.
3) Then this ellipse gets distorted by wrapping it around the mean coil diameter.
4) Finally use extrude this shape vertically while twisting it.
It was an interesting math challenge and the result looks pretty good.
It generates very quickly even at high detail, though you may run out of memory if detail is too high!