Updated a fun math shape generator

Back in 2013, “kakaroto” posted a nice curve generator to thingiverse.

However, it uses the assign function that is going to disappear from OpenSCAD, so I changed it to use normal variable assignment.

It’s fun to play with!


Created another variant to enable making molds by specifying a draft angle for the sides:

I had an interesting time finding software that can toolpath this shape, though. FreeCAD keeps crashing when I try. Kiri:moto runs indefinitely on Firefox, which is either better or worse than Chrome which quickly crashes the tab. Arjan van de Ven came to the rescue with open source software he wrote for his Shapeoko which finishes in about a minute. It currently has an interesting artifact that would be trivial to work around by extending the model and letting it cut a little bit of air.


Kiri:moto ran indefinitely because my model wasn’t manifold. I haven’t figured out how to make OpenSCAD generate a manifold here. The only obvious way would be basically equivalent to just writing code to write the STL directly. Prusa-slicer has made me lazy, I guess, by generally just making things work even when the model isn’t actually manifold.

I learned in the process more about how to fix non-manifold STLs in meshlab, and then Kiri:moto worked really well. It has a nice outline pass generator. It has clearly had a lot of time invested in it, and at this point I’m guessing that it will end up being my go-to for toolpathing STLs.

Here’s a top-down view with roughing op with ¼" flat mill as black lines, and outline op with ⅛" ball mill as pink lines, and three tabs in lavender:

It also has a simulation that draws a mesh. It’s not real-time but it shows the path.


It did a really nice job on my MDF prototype.

I think it’s about 15mm too narrow so I’ll scale up for the aluminum version. I also made the bars a little thicker but not much.


here some oSCAD code that should work …


 for (i=[0:step:360-step]){
1 Like

That’s compact, which makes sense working from the polar form instead of the cartesian form. I’m frequently amazed by your compact OpenSCAD code.

I admit to not seeing how ratio=5 successfully corresponds to the 5/7 in my version but it clearly does!

I’m not aware of any way to make that approach able to represent draft angle, with the thickness of the part at the top thinner than the bottom. I could see it hull by parts, putting the linear extrude inside the loop, at which point it’s logically very similar to the cartesian form I made.

1 Like

you could use a minkowski with a cone else you need to work from a polyhedron and here you get those intersections causing “non manifold” geometry.
but if you create the hull from two cones in 3D this would work probably better and give you tapered walls. (but then you can’t use offset to round the corners).
the ratio=5 just makes ratio×rotations for the inner circle/arm - for every rotation of the outer.

1 Like

I see, yes, minkowski of a cone around it would do that. I’ve tended not to use a minkowski sum when I can avoid it because it’s so amazingly slow. I was imagining non-manifold geometry from hulls of truncated cones, just like I got from polyhedrons in my original OpenSCAD model.

I didn’t actually particularly want the rounded corners; I used the smallest bits I could to minimize the radius of the inside corners. :relaxed:

OK. It’s not obvious to me how to get some of the patterns that way. For example, the integer paterns; such as this 5/1 curve:

it is like a spirograph. The ratio is the teeth ratio.

Also quite interessting when adding a 3rd circle, but you quickly end up with the elements limitation in oscad.

I’m just used to thinking of the curves by numerators and denominator as shown in this chart from Rose (mathematics) - Wikipedia

Last night, I didn’t try negative ratios. Those let me do some additional shapes. When I use -5, that gives the 5/3 curve:

I haven’t figured out how to make the integer curves using your approach.

1 Like

plus or minus changing the rotation …

with Rosette(r1=10,r2=10,ratio=-5/3); i get this.

(the module is in ub.scad) As the module calculates how many turns needed for a closed curve… you get nice results for ratios little bit off like 1.1 or 0.15 (don’t try .14 as this need 550 turns).

Also i made it usable for 3D … so you can just use a 3D child object (cone or sphere).

-5/3 with the code above gave me this:

For others wondering about ub.scad, it is available from Ulrich’s site:

I see the rotations() ub.scad to calculate the number of rotations required. :tada:

1 Like

You guys are making my head hurt, but in a good way!


I assume as i took a completly different approach - the k factor (n/d) can’t be used.

Also as i have r1 and r2 there are much more possibilities as you can create all sort of trochoids


I should consider porting your method to CascadeStudio — the original OpenSCAD model I worked with could also do lots of different trochoids, but my CascadeStudio implementation I limited to rose curves for simplicity.

I remember that spirograph had racetrack shapes as well, and your model would work great for that by making r1 a piece-wise function…

also kind of damping would result in pendular shapes like these https://joindiaspora.com/posts/20282233


Rosette(r1=30, r2=29, ratio=5)
    cylinder(r1=3, r2=2, h=19);

Here’s the quick preview:

Render is slow, though. By contrast, CascadeStudio using OCC means that fully rendering the CascadeStudio version is nearly instantaneous.

I glanced back at my CascadeStudio code, and getting a working model required that the pipes not be self-intersecting, so I broke the pipes at every min and max distance from the origin. The clever use of rotation and translation in your Rosette code means I would need to use another tactic. I think breaking the pipes when the angles are the same mod 180° would probably work. So it wouldn’t be as succinct as your ub.scad code, though it should render faster.

@Ulrich_Baer I hope you don’t mind that I moved the discussion here, since this was where I was working on OpenSCAD code for rhodonea and other trochoids. :relaxed: