It's a little bit unclear what exactly you want to do. But there's likely
already existing libraries that do it.
Several libraries have a sweep operation of some sort that constructs a
solid by linking together transformations of an initial polygon.
Some that I'm aware of are the original list-comprehension-demos, dotSCAD
and BOSL2. The first one is old and has some issues with the latest version
of openscad. A basic sweep concept is to take a polygon and "sweep" it
along a curved path, line a linear extrude that follows a nonlinear path.
(There's quite a bit of hidden complexity having to do with orientation of
the polygon, however.) The most general sweep concept is to use a series of
arbitrary transformation operators to define a sequence of polygons.
Another operation is to link together a sequence of polygons that might be
unrelated, so a square could morph into a circle, or perhaps a hexagon.
List-comprehension-demos included a skin() operator which does this (sort
of) and BOSL2 includes code that can handle polygons with dissimilar numbers
BOSL2 also includes offset_sweep which constructs a polyhedron by a sequence
of offset operations. This is useful for creating a shape with a constant
@adrianv you're right the pasted example was linear and I've achieved this
but not with that code but to me the trickiest part was to manage the growth
for each layer. The model shown the picture below was made with a similar
code using a sine profile for the inner curve.
@caterpillar very interesting and concise. However I had to modify the calls
to libraries like this to make it function: