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) = [18sin(360a), 18-18cos(360a0.7), 36sin(360*a/2)];
function shape(d) =
[for (i=[1:10:360]) [dsin(i), dcos(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.
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
to shape().
On 2 January 2018 at 21:15, jon jon@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) = [18sin(360a), 18-18cos(360a0.7), 36sin(360*a/2)];
function shape(d) =
[for (i=[1:10:360]) [dsin(i), dcos(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@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org