[OpenSCAD] Not understanding things

Parkinbot rudolf at parkinbot.com
Sat Jan 27 07:52:43 EST 2018


skin() and sweep() explicitly knit a polyhedron from given data. Thus they
create module objects that can be combined by use of Boolean operations with
any other modules like cylinder. While they offer you a lot of expressive
power, you have to take special care to create valid manifolds with no
self-intersection only, if you want to get valid STLs at the end.  

skin() and sweep() differ in the data you have to provide and thus in
operation and usage scope.  

The original version of sweep() you are referring to, expects a geometric
primitive like a square and a transformation sequence (which is difficult to
compose and also limited to affine transformations) to be applied to this
primitive. 

skin() in contrast expects a vector of polygons already placed in 3D space
to be skinned. This is much less restrictive, because you can create any
transitions for any 2D-shapes you like, without being limited to a common 2D
shape and affine transformations - but at the price of additional care:
valid (= simple) polygons, proper sequencing with no mutual intersections of
any polygons allowed. 

When I started to play with sweep() some years ago, my aim was to define
smooth transitions between different airfoils. I immediately saw, that
sweep() will not do the job and started to implement my own sweep() which
later turned out to be (almost) semantically equivalent to skin(). I
collected all the stuff (mainly affine operations) needed to place 2D-shapes
into 3D space and knit them together into a polyhedron and stuffed it into a
library which I called Naca_sweep(). Thus the main function is called
sweep() but behaves like skin(). Because I am a fan of short notations I
called the affine operations operating over a polygon (or 2D-shape with
z-coordinate) Rx_(), Ry_(), Ry_(), Tx_(), ... Sx_(). 

The following code example shows you what happens, when this library is used
to generate a Moebius strip with a sinusoidal radius function. 
1. Write a parametrized function that composes your 2D shape (here circle
but any simple polygon is allowed - e.g. airfoil)
2. Write a parametrized function that composes a sequence of polygons (my
sweep() expects all polygons to have the same # of vertices, skin() doen't
care) properly placed in 3D space. 
3. call sweep() or skin()

My sweep() implementiation provides a *showslices* parameter. Setting it
true will show you the polygons' placement. Try it out. 

The problem is: how will you close the strip into a ring? You could either
change sweep() to account for the twistm when closing the ring, which is
hard stuff and not very general, or you just do a Boolean union of two half
sweeps ... try the modify the example code, good exercise. 
 

use <naca_sweep.scad>  // https://www.thingiverse.com/thing:900137

// use <skin.scad>   // alternative 
// skin(Moebius());  

sweep(Moebius(), showslices = true);  // show, what happens
sweep(Moebius());  // same semantics as skin

function Moebius(R = 30, edges = 3, M=50) = [for(i=[0:M-1])
  let(ang = 360/M*i)
  Ry_(ang,                // rotate to ring
  Tx_(R,                      // shift triag
  Rz_(ang/edges,                // rotate triag
  circle(r=5*sin(2*ang)+10, N=edges))))]; // generate circle with moduluated
radius  

function circle(r=10, N=3) = [for(i=[0:N-1]) r*[cos(360/N*i), sin(360/N*i),
0]]; 
 



--
Sent from: http://forum.openscad.org/




More information about the Discuss mailing list