[OpenSCAD] Fwd: Twisted Torus

doug moen doug at moens.org
Tue Sep 25 22:32:39 EDT 2018


There is no "rotate_extrude_with_a_twist" in OpenSCAD, and there's no way
to define new CSG operators with this kind of behaviour from inside the
OpenSCAD language. So you are left with building the model by assembling a
large number of small pieces. An expert would use polyhedron(), as Ezra
said, and then it will be fast.

I make these kinds of models using Curv, which has a richer set of CSG
operators, including "twist" and "bend". Here's my standard twisted torus
in Curv. Note that this has a square cross section. It works by making a
tall skinny box, twisting it around the Z axis, then bending it around 360°
into a torus.

let
twisted_torus(d1, d2, ntwists) =
    box(d1,d1,d2)
    >> twist (90*ntwists*deg/d2)
    >> rotate {angle: 90*deg, axis: Y_axis}
    >> bend {};

in
twisted_torus(1, 10, 4)

which looks like this:


Your design has a semi-circle as a cross section. I'd make that by starting
with a cylinder, cutting away half the cylinder so that it has a
semi-circle cross section, then twist and bend as before.

let
twisted_torus(d1, d2, ntwists) =
    difference( cylinder{d: d1, h: d2}, box{xmin: 0} )
    >> twist (360*ntwists*deg/d2)
    >> rotate {angle: 90*deg, axis: Y_axis}
    >> bend {};

in
twisted_torus(25, 50, 1)



Curv works differently from OpenSCAD. Shapes are represented internally as
mathematical functions, not as triangle meshes, and curved surfaces are
rendered on the screen at "infinite" resolution. You don't get a triangle
mesh until you export an STL file. This representation makes Curv good for
curved organic shapes, and non-affine transformations like twist and bend
are easier to implement.

You should be aware that Curv is a one-man hobby project on github. Mac and
Linux only (no Windows), and you build your own executable by following the
build instructions. https://github.com/doug-moen/curv

Doug Moen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscad.org/pipermail/discuss_lists.openscad.org/attachments/20180925/4b033eb0/attachment.html>


More information about the Discuss mailing list