[OpenSCAD] Unusual hull() and minkowski modelling

Parkinbot rudolf at parkinbot.com
Sat Jun 18 10:23:02 EDT 2016


Parkinbot wrote
> You feed a minkowski with two polygons - a nonclosed one and closed one -
> or a polygon and a 2D shape and get a sweep. 
> ...
> because I doubt, Minkowski will ever be fast enough for somebody, who
> knows what he is doing.

here is your Minkowski-tweaked sweep() using a path and a 3D shape, which I
called extrude() - also allowing for self-intersection. It is a 'weak'
peek&poke solution, because hull() insists on some 'flesh' in the Z
direction (crashes OpenSCAD otherwise). Also not all Z-trajectories seem to
be 'allowed'. 


> p =   [for (x=[0:10:360]) 30*[cos(x), sin(2*x), x/100]]; 
> p1 =   [for (x=[0:4:360]) 30*[cos(x), sin(4*x), -cos(x)]]; 
> extrude(p) cylinder(3);
> extrude(p1) sphere(3);
> module extrude(p)  minkowski() {polygon2path(p); children();}
> module polygon2path(p) for(i=[0:len(p)-2]) line(p[i], p[i+1]);
> module line(a, b) hull(){ point(a); point(b);}  
> module point(t) translate(t) scale([0, 0, 0.0001]) cube([]);

Of course, either polygon2path() could get a built-in operator (avoiding
hull()), or minkowski() could be overloaded to directly accept and process a
vec3D set. 

BTW, this is an old solution of mine, the only difference, I used
non-degenerate 'sufficiently small' shapes to hull the path into a solid

Anyway you put it, degenrate or not, I don't see much progress because the
approach is expectedly very slow. Therefore I'd always opt for a dedicated
extrude() operator that could internally use minkowski PLUS some shortcuts
if boundingbox checks allow for them, to speed up things dramatically. 

Concerning runtime, don't try the following one. Looks harmless, but I guess
it takes hours to process, due to its convexity. 

> extrude(p) {sphere(3);translate([2,0,0]) sphere(3);}

I also guess a render() will speed it up a bit to several minutes, but to
get the 'hires' shot (step=2) I preferred to use a convex decomposition,
which tweaked it down to a minute.  

>   extrude(p) sphere(3);
>   translate([2,0,0]) 
>   extrude(p) sphere(3);
>    Top level object is a 3D object:
>    Simple:        yes
>    Vertices:     3027
>    Halfedges:   14294
>    Edges:        7147
>    Halffacets:   8244
>    Facets:       4122
>    Volumes:         2

Therefore, I really don't see much chance for the minkowski approach when
implementing extrude().

aren't you always looking for some compact crasher code? I never encountered
a higher crash rate before writing this post ;-) 


View this message in context: http://forum.openscad.org/Unusual-hull-and-minkowski-modelling-tp17730p17756.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

More information about the Discuss mailing list