[OpenSCAD] trying to modify Sweep
nop.head at gmail.com
Tue Jan 2 16:20:14 EST 2018
You can't pass functions in OpenSCAD. You are simply passing in the result
of calling the function with no argument. So inside sweep it has no access
On 2 January 2018 at 21:15, jon <jon at jonbondy.com> wrote:
> I'm trying to do something that seems conceptually simple to me, but it
> keeps failing.
> Rather than passing a parameter-less shape() function into sweep(), I am
> passing a function with one parameter, the scale. This should allow me to
> use a circular cross section to create a snake-that-swallowed-a-grapefruit
> shape, by varying the scale dynamically.
> In the implementation of sweep() I changed this function, as follows (I
> calculate to_3d() of the shape() each time):
> function sweep_points() = flatten([for (i=[0:pathlen])
> transform(path_transforms[i], to_3d(shape(i)))]);
> I renamed sweep.scad to be sweep-jon.scad. While sweep-jon.scad compiles
> without errors, the invocation code (below) fails with"Ignoring unknown
> function 'shape'" and then "PolySet has degenerate polygons".
> What am I missing?
> use <sweep-Jon.scad>
> function f(a) = [18*sin(360*a), 18-18*cos(360*a*0.7), 36*sin(360*a/2)];
> function shape(d) =
> [for (i=[1:10:360]) [d*sin(i), d*cos(i)]];
> step = 0.005;
> path = [for (t=[0:step:1-step]) f(t)];
> path_transforms = construct_transform_path(path);
> sweep(shape(), path_transforms);
> Sent from my desktop computer.
> I do not receive emails while away from my desk,
> nor do I receive texts on my main phone number
> (which is a land line).
> If you know that I am on the road, please text me.
> If you know that I am home, please email me.
> OpenSCAD mailing list
> Discuss at lists.openscad.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss