discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Getting hull() to work difference()? (Subtracting variable-depth spiral from a cube)

JW
Jim Witte
Fri, Dec 17, 2021 7:40 PM

I have the following program, that is meant to construct a spiral that gets
progressively deeper, by using hulls between successive extrusions of the
circles that make it up.  (A circle is extruded, then hulled to the next
one, etc).  This is then subtracted from a cube.

If I uncomment the plotSpiral() command at the bottom (without the
difference), it renders as I expect.  But with the difference, it
differences the extrusions, but not the hulls between them.  So the inside
of the spiral, where the individual extrusions overlap, it works like I
want (sort of), but on the outside, I just get a series of individual
pockets.

I could change  the angle spacing as I get further out (that would look
cleaner too), but that would take longer, and this whole thing will be done
with a ball-nose end mill anyway, which should smooth it out on it's own.

Does anyone have any other ideas of how to get a "deepening spiral" design?

Thanks,
JIm


module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1,
snakeSides = 5) {

// Number of sides of the "snake"
$fn = snakeSides;

bumpiness = 1;
segmentsPerTurn = 35;
numTurns = 4;
numTurnsToPlot = 4;

// *** Derived ***

jCeiling = 1/numTurns*numTurnsToPlot;
sphereDiameterOne = spiralThickness/bumpiness;
sphereDiameterTwo = spiralThickness/bumpiness;

//spiralWidth = 30;
//spiralHeight = 100;
spiralNumSegments = segmentsPerTurn * numTurns;

spiralRadius = spiralWidth/2;

exponent = 1.685;
//ORIG: exponent = 1.685;

function L_Spiral (angle,
                   radius = 50, spiralDepth, turns = 4,
                   exponent = 0.685, start_angle = 0) =
    let (fx = exponent < 0 ?
            pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) :
            pow( max(0, 1-angle), max(1, exponent+1) ),

         depthVar = (angle * spiralDepth)
        )
        [(radius * fx ) * cos(start_angle +

angleturns360sign(turns)),
(radius * fx ) * sin(start_angle +
angle
turns360sign(turns)),
depthVar];

for (angle = [0 : 1/spiralNumSegments : jCeiling]) {
    hull() {
        //echo(angle);
        translate(L_Spiral (angle,
                            spiralRadius, -spiralHeight, numTurns,
                            exponent, 0 ))
            linear_extrude(angle * spiralHeight)
                circle(d = sphereDiameterOne);

        translate(L_Spiral (angle + 1/spiralNumSegments,
                           spiralRadius, -spiralHeight, numTurns,
                           exponent, 0 ))
            linear_extrude(angle * spiralHeight)
                circle(d = sphereDiameterTwo);
        }   // hull()
}   // for j

}  // plotSpiral()

spiralWidth = 30;
spiralDepth = 5;

///*
difference() {
// Subtract the spiral from the cube
translate([-spiralWidth/2, -spiralWidth/2, 0])
color("red", 0.3)
cube([spiralWidth, spiralWidth, spiralDepth*2]);

translate([0, 0, spiralDepth*2 ])
    plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

}  // difference
//*/

//translate([0, 0, spiralDepth2 ])
//    plotSpiral(spiralWidth, spiralDepth
3, snakeSides=5);

I have the following program, that is meant to construct a spiral that gets progressively deeper, by using hulls between successive extrusions of the circles that make it up. (A circle is extruded, then hulled to the next one, etc). This is then subtracted from a cube. If I uncomment the plotSpiral() command at the bottom (without the difference), it renders as I expect. But with the difference, it differences the extrusions, but not the hulls between them. So the inside of the spiral, where the individual extrusions overlap, it works like I want (sort of), but on the outside, I just get a series of individual pockets. I could change the angle spacing as I get further out (that would look cleaner too), but that would take longer, and this whole thing will be done with a ball-nose end mill anyway, which should smooth it out on it's own. Does anyone have any other ideas of how to get a "deepening spiral" design? Thanks, JIm --- module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1, snakeSides = 5) { // Number of sides of the "snake" $fn = snakeSides; bumpiness = 1; segmentsPerTurn = 35; numTurns = 4; numTurnsToPlot = 4; // *** Derived *** jCeiling = 1/numTurns*numTurnsToPlot; sphereDiameterOne = spiralThickness/bumpiness; sphereDiameterTwo = spiralThickness/bumpiness; //spiralWidth = 30; //spiralHeight = 100; spiralNumSegments = segmentsPerTurn * numTurns; spiralRadius = spiralWidth/2; exponent = 1.685; //ORIG: exponent = 1.685; function L_Spiral (angle, radius = 50, spiralDepth, turns = 4, exponent = 0.685, start_angle = 0) = let (fx = exponent < 0 ? pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) : pow( max(0, 1-angle), max(1, exponent+1) ), depthVar = (angle * spiralDepth) ) [(radius * fx ) * cos(start_angle + angle*turns*360*sign(turns)), (radius * fx ) * sin(start_angle + angle*turns*360*sign(turns)), depthVar]; for (angle = [0 : 1/spiralNumSegments : jCeiling]) { hull() { //echo(angle); translate(L_Spiral (angle, spiralRadius, -spiralHeight, numTurns, exponent, 0 )) linear_extrude(angle * spiralHeight) circle(d = sphereDiameterOne); translate(L_Spiral (angle + 1/spiralNumSegments, spiralRadius, -spiralHeight, numTurns, exponent, 0 )) linear_extrude(angle * spiralHeight) circle(d = sphereDiameterTwo); } // hull() } // for j } // plotSpiral() spiralWidth = 30; spiralDepth = 5; ///* difference() { // Subtract the spiral from the cube translate([-spiralWidth/2, -spiralWidth/2, 0]) color("red", 0.3) cube([spiralWidth, spiralWidth, spiralDepth*2]); translate([0, 0, spiralDepth*2 ]) plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); } // difference //*/ //translate([0, 0, spiralDepth*2 ]) // plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);
MM
Michael Möller
Fri, Dec 17, 2021 7:49 PM

sitting here with the mobile on the bus, but

linear_extrude(angle * spiralHeight)
circle(d = sphereDiameterOne);

why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne)

Msquare

fre. 17. dec. 2021 20.41 skrev Jim Witte jim.witte@gmail.com:

I have the following program, that is meant to construct a spiral that
gets progressively deeper, by using hulls between successive extrusions of
the circles that make it up.  (A circle is extruded, then hulled to the
next one, etc).  This is then subtracted from a cube.

If I uncomment the plotSpiral() command at the bottom (without the
difference), it renders as I expect.  But with the difference, it
differences the extrusions, but not the hulls between them.  So the inside
of the spiral, where the individual extrusions overlap, it works like I
want (sort of), but on the outside, I just get a series of individual
pockets.

I could change  the angle spacing as I get further out (that would look
cleaner too), but that would take longer, and this whole thing will be done
with a ball-nose end mill anyway, which should smooth it out on it's own.

Does anyone have any other ideas of how to get a "deepening spiral" design?

Thanks,
JIm


module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1,
snakeSides = 5) {

 // Number of sides of the "snake"
 $fn = snakeSides;

 bumpiness = 1;
 segmentsPerTurn = 35;
 numTurns = 4;
 numTurnsToPlot = 4;

 // *** Derived ***

 jCeiling = 1/numTurns*numTurnsToPlot;
 sphereDiameterOne = spiralThickness/bumpiness;
 sphereDiameterTwo = spiralThickness/bumpiness;

 //spiralWidth = 30;
 //spiralHeight = 100;
 spiralNumSegments = segmentsPerTurn * numTurns;

 spiralRadius = spiralWidth/2;

 exponent = 1.685;
 //ORIG: exponent = 1.685;

 function L_Spiral (angle,
                    radius = 50, spiralDepth, turns = 4,
                    exponent = 0.685, start_angle = 0) =
     let (fx = exponent < 0 ?
             pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) :
             pow( max(0, 1-angle), max(1, exponent+1) ),

          depthVar = (angle * spiralDepth)
         )
         [(radius * fx ) * cos(start_angle +

angleturns360sign(turns)),
(radius * fx ) * sin(start_angle +
angle
turns360sign(turns)),
depthVar];

 for (angle = [0 : 1/spiralNumSegments : jCeiling]) {
     hull() {
         //echo(angle);
         translate(L_Spiral (angle,
                             spiralRadius, -spiralHeight, numTurns,
                             exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterOne);

         translate(L_Spiral (angle + 1/spiralNumSegments,
                            spiralRadius, -spiralHeight, numTurns,
                            exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterTwo);
         }   // hull()
 }   // for j

}  // plotSpiral()

spiralWidth = 30;
spiralDepth = 5;

///*
difference() {
// Subtract the spiral from the cube
translate([-spiralWidth/2, -spiralWidth/2, 0])
color("red", 0.3)
cube([spiralWidth, spiralWidth, spiralDepth*2]);

 translate([0, 0, spiralDepth*2 ])
     plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

}  // difference
//*/

//translate([0, 0, spiralDepth2 ])
//    plotSpiral(spiralWidth, spiralDepth
3, snakeSides=5);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

sitting here with the mobile on the bus, but linear_extrude(angle * spiralHeight) circle(d = sphereDiameterOne); why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne) Msquare fre. 17. dec. 2021 20.41 skrev Jim Witte <jim.witte@gmail.com>: > I have the following program, that is meant to construct a spiral that > gets progressively deeper, by using hulls between successive extrusions of > the circles that make it up. (A circle is extruded, then hulled to the > next one, etc). This is then subtracted from a cube. > > If I uncomment the plotSpiral() command at the bottom (without the > difference), it renders as I expect. But with the difference, it > differences the extrusions, but not the hulls between them. So the inside > of the spiral, where the individual extrusions overlap, it works like I > want (sort of), but on the outside, I just get a series of individual > pockets. > > I could change the angle spacing as I get further out (that would look > cleaner too), but that would take longer, and this whole thing will be done > with a ball-nose end mill anyway, which should smooth it out on it's own. > > Does anyone have any other ideas of how to get a "deepening spiral" design? > > Thanks, > JIm > > --- > > module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1, > snakeSides = 5) { > > // Number of sides of the "snake" > $fn = snakeSides; > > bumpiness = 1; > segmentsPerTurn = 35; > numTurns = 4; > numTurnsToPlot = 4; > > // *** Derived *** > > jCeiling = 1/numTurns*numTurnsToPlot; > sphereDiameterOne = spiralThickness/bumpiness; > sphereDiameterTwo = spiralThickness/bumpiness; > > //spiralWidth = 30; > //spiralHeight = 100; > spiralNumSegments = segmentsPerTurn * numTurns; > > spiralRadius = spiralWidth/2; > > exponent = 1.685; > //ORIG: exponent = 1.685; > > function L_Spiral (angle, > radius = 50, spiralDepth, turns = 4, > exponent = 0.685, start_angle = 0) = > let (fx = exponent < 0 ? > pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) : > pow( max(0, 1-angle), max(1, exponent+1) ), > > depthVar = (angle * spiralDepth) > ) > [(radius * fx ) * cos(start_angle + > angle*turns*360*sign(turns)), > (radius * fx ) * sin(start_angle + > angle*turns*360*sign(turns)), > depthVar]; > > for (angle = [0 : 1/spiralNumSegments : jCeiling]) { > hull() { > //echo(angle); > translate(L_Spiral (angle, > spiralRadius, -spiralHeight, numTurns, > exponent, 0 )) > linear_extrude(angle * spiralHeight) > circle(d = sphereDiameterOne); > > translate(L_Spiral (angle + 1/spiralNumSegments, > spiralRadius, -spiralHeight, numTurns, > exponent, 0 )) > linear_extrude(angle * spiralHeight) > circle(d = sphereDiameterTwo); > } // hull() > } // for j > } // plotSpiral() > > spiralWidth = 30; > spiralDepth = 5; > > ///* > difference() { > // Subtract the spiral from the cube > translate([-spiralWidth/2, -spiralWidth/2, 0]) > color("red", 0.3) > cube([spiralWidth, spiralWidth, spiralDepth*2]); > > translate([0, 0, spiralDepth*2 ]) > plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); > } // difference > //*/ > > //translate([0, 0, spiralDepth*2 ]) > // plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
JW
Jim Witte
Fri, Dec 17, 2021 8:42 PM

Well, I moved the spiral a bit higher, changing the bit inside the
difference to:

translate([0, 0, spiralDepth*2+0.1])
    plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

And it worked.  Before I guess it just didn't quite go through the top of
the cube, and I guess that screws up the hull for some reason.

On Fri, Dec 17, 2021 at 2:49 PM Michael Möller private2michael@gmail.com
wrote:

sitting here with the mobile on the bus, but

linear_extrude(angle * spiralHeight)
circle(d = sphereDiameterOne);

why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne)

Msquare

fre. 17. dec. 2021 20.41 skrev Jim Witte jim.witte@gmail.com:

I have the following program, that is meant to construct a spiral that
gets progressively deeper, by using hulls between successive extrusions of
the circles that make it up.  (A circle is extruded, then hulled to the
next one, etc).  This is then subtracted from a cube.

If I uncomment the plotSpiral() command at the bottom (without the
difference), it renders as I expect.  But with the difference, it
differences the extrusions, but not the hulls between them.  So the inside
of the spiral, where the individual extrusions overlap, it works like I
want (sort of), but on the outside, I just get a series of individual
pockets.

I could change  the angle spacing as I get further out (that would look
cleaner too), but that would take longer, and this whole thing will be done
with a ball-nose end mill anyway, which should smooth it out on it's own.

Does anyone have any other ideas of how to get a "deepening spiral"
design?

Thanks,
JIm


module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1,
snakeSides = 5) {

 // Number of sides of the "snake"
 $fn = snakeSides;

 bumpiness = 1;
 segmentsPerTurn = 35;
 numTurns = 4;
 numTurnsToPlot = 4;

 // *** Derived ***

 jCeiling = 1/numTurns*numTurnsToPlot;
 sphereDiameterOne = spiralThickness/bumpiness;
 sphereDiameterTwo = spiralThickness/bumpiness;

 //spiralWidth = 30;
 //spiralHeight = 100;
 spiralNumSegments = segmentsPerTurn * numTurns;

 spiralRadius = spiralWidth/2;

 exponent = 1.685;
 //ORIG: exponent = 1.685;

 function L_Spiral (angle,
                    radius = 50, spiralDepth, turns = 4,
                    exponent = 0.685, start_angle = 0) =
     let (fx = exponent < 0 ?
             pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) :
             pow( max(0, 1-angle), max(1, exponent+1) ),

          depthVar = (angle * spiralDepth)
         )
         [(radius * fx ) * cos(start_angle +

angleturns360sign(turns)),
(radius * fx ) * sin(start_angle +
angle
turns360sign(turns)),
depthVar];

 for (angle = [0 : 1/spiralNumSegments : jCeiling]) {
     hull() {
         //echo(angle);
         translate(L_Spiral (angle,
                             spiralRadius, -spiralHeight, numTurns,
                             exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterOne);

         translate(L_Spiral (angle + 1/spiralNumSegments,
                            spiralRadius, -spiralHeight, numTurns,
                            exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterTwo);
         }   // hull()
 }   // for j

}  // plotSpiral()

spiralWidth = 30;
spiralDepth = 5;

///*
difference() {
// Subtract the spiral from the cube
translate([-spiralWidth/2, -spiralWidth/2, 0])
color("red", 0.3)
cube([spiralWidth, spiralWidth, spiralDepth*2]);

 translate([0, 0, spiralDepth*2 ])
     plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

}  // difference
//*/

//translate([0, 0, spiralDepth2 ])
//    plotSpiral(spiralWidth, spiralDepth
3, snakeSides=5);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Well, I moved the spiral a bit higher, changing the bit inside the difference to: translate([0, 0, spiralDepth*2+0.1]) plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); And it worked. Before I guess it just didn't quite go through the top of the cube, and I guess that screws up the hull for some reason. On Fri, Dec 17, 2021 at 2:49 PM Michael Möller <private2michael@gmail.com> wrote: > sitting here with the mobile on the bus, but > > linear_extrude(angle * spiralHeight) > circle(d = sphereDiameterOne); > > why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne) > > > Msquare > > fre. 17. dec. 2021 20.41 skrev Jim Witte <jim.witte@gmail.com>: > >> I have the following program, that is meant to construct a spiral that >> gets progressively deeper, by using hulls between successive extrusions of >> the circles that make it up. (A circle is extruded, then hulled to the >> next one, etc). This is then subtracted from a cube. >> >> If I uncomment the plotSpiral() command at the bottom (without the >> difference), it renders as I expect. But with the difference, it >> differences the extrusions, but not the hulls between them. So the inside >> of the spiral, where the individual extrusions overlap, it works like I >> want (sort of), but on the outside, I just get a series of individual >> pockets. >> >> I could change the angle spacing as I get further out (that would look >> cleaner too), but that would take longer, and this whole thing will be done >> with a ball-nose end mill anyway, which should smooth it out on it's own. >> >> Does anyone have any other ideas of how to get a "deepening spiral" >> design? >> >> Thanks, >> JIm >> >> --- >> >> module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1, >> snakeSides = 5) { >> >> // Number of sides of the "snake" >> $fn = snakeSides; >> >> bumpiness = 1; >> segmentsPerTurn = 35; >> numTurns = 4; >> numTurnsToPlot = 4; >> >> // *** Derived *** >> >> jCeiling = 1/numTurns*numTurnsToPlot; >> sphereDiameterOne = spiralThickness/bumpiness; >> sphereDiameterTwo = spiralThickness/bumpiness; >> >> //spiralWidth = 30; >> //spiralHeight = 100; >> spiralNumSegments = segmentsPerTurn * numTurns; >> >> spiralRadius = spiralWidth/2; >> >> exponent = 1.685; >> //ORIG: exponent = 1.685; >> >> function L_Spiral (angle, >> radius = 50, spiralDepth, turns = 4, >> exponent = 0.685, start_angle = 0) = >> let (fx = exponent < 0 ? >> pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) : >> pow( max(0, 1-angle), max(1, exponent+1) ), >> >> depthVar = (angle * spiralDepth) >> ) >> [(radius * fx ) * cos(start_angle + >> angle*turns*360*sign(turns)), >> (radius * fx ) * sin(start_angle + >> angle*turns*360*sign(turns)), >> depthVar]; >> >> for (angle = [0 : 1/spiralNumSegments : jCeiling]) { >> hull() { >> //echo(angle); >> translate(L_Spiral (angle, >> spiralRadius, -spiralHeight, numTurns, >> exponent, 0 )) >> linear_extrude(angle * spiralHeight) >> circle(d = sphereDiameterOne); >> >> translate(L_Spiral (angle + 1/spiralNumSegments, >> spiralRadius, -spiralHeight, numTurns, >> exponent, 0 )) >> linear_extrude(angle * spiralHeight) >> circle(d = sphereDiameterTwo); >> } // hull() >> } // for j >> } // plotSpiral() >> >> spiralWidth = 30; >> spiralDepth = 5; >> >> ///* >> difference() { >> // Subtract the spiral from the cube >> translate([-spiralWidth/2, -spiralWidth/2, 0]) >> color("red", 0.3) >> cube([spiralWidth, spiralWidth, spiralDepth*2]); >> >> translate([0, 0, spiralDepth*2 ]) >> plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); >> } // difference >> //*/ >> >> //translate([0, 0, spiralDepth*2 ]) >> // plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
HL
Hans L
Sat, Dec 25, 2021 6:27 AM

Yes it's always a good idea to set up your negative objects so that they
extend beyond the surface a bit.

The other issue with your script was that the top face of your spiral
cutout was not flat.
The second linear_extrude did not account for the additional translation
amount, it should be:

linear_extrude((angle + 1/spiralNumSegments)* spiralHeight)

Still not sure why that completely broke the hull, but changing just that
line by itself fixes the render (preview is still patchy without the added
z offset, but that is expected).

On Fri, Dec 17, 2021 at 2:42 PM Jim Witte jim.witte@gmail.com wrote:

Well, I moved the spiral a bit higher, changing the bit inside the
difference to:

 translate([0, 0, spiralDepth*2+0.1])
     plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

And it worked.  Before I guess it just didn't quite go through the top of
the cube, and I guess that screws up the hull for some reason.

On Fri, Dec 17, 2021 at 2:49 PM Michael Möller private2michael@gmail.com
wrote:

sitting here with the mobile on the bus, but

linear_extrude(angle * spiralHeight)
circle(d = sphereDiameterOne);

why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne)

Msquare

fre. 17. dec. 2021 20.41 skrev Jim Witte jim.witte@gmail.com:

I have the following program, that is meant to construct a spiral that
gets progressively deeper, by using hulls between successive extrusions of
the circles that make it up.  (A circle is extruded, then hulled to the
next one, etc).  This is then subtracted from a cube.

If I uncomment the plotSpiral() command at the bottom (without the
difference), it renders as I expect.  But with the difference, it
differences the extrusions, but not the hulls between them.  So the inside
of the spiral, where the individual extrusions overlap, it works like I
want (sort of), but on the outside, I just get a series of individual
pockets.

I could change  the angle spacing as I get further out (that would look
cleaner too), but that would take longer, and this whole thing will be done
with a ball-nose end mill anyway, which should smooth it out on it's own.

Does anyone have any other ideas of how to get a "deepening spiral"
design?

Thanks,
JIm


module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1,
snakeSides = 5) {

 // Number of sides of the "snake"
 $fn = snakeSides;

 bumpiness = 1;
 segmentsPerTurn = 35;
 numTurns = 4;
 numTurnsToPlot = 4;

 // *** Derived ***

 jCeiling = 1/numTurns*numTurnsToPlot;
 sphereDiameterOne = spiralThickness/bumpiness;
 sphereDiameterTwo = spiralThickness/bumpiness;

 //spiralWidth = 30;
 //spiralHeight = 100;
 spiralNumSegments = segmentsPerTurn * numTurns;

 spiralRadius = spiralWidth/2;

 exponent = 1.685;
 //ORIG: exponent = 1.685;

 function L_Spiral (angle,
                    radius = 50, spiralDepth, turns = 4,
                    exponent = 0.685, start_angle = 0) =
     let (fx = exponent < 0 ?
             pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) :
             pow( max(0, 1-angle), max(1, exponent+1) ),

          depthVar = (angle * spiralDepth)
         )
         [(radius * fx ) * cos(start_angle +

angleturns360sign(turns)),
(radius * fx ) * sin(start_angle +
angle
turns360sign(turns)),
depthVar];

 for (angle = [0 : 1/spiralNumSegments : jCeiling]) {
     hull() {
         //echo(angle);
         translate(L_Spiral (angle,
                             spiralRadius, -spiralHeight, numTurns,
                             exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterOne);

         translate(L_Spiral (angle + 1/spiralNumSegments,
                            spiralRadius, -spiralHeight, numTurns,
                            exponent, 0 ))
             linear_extrude(angle * spiralHeight)
                 circle(d = sphereDiameterTwo);
         }   // hull()
 }   // for j

}  // plotSpiral()

spiralWidth = 30;
spiralDepth = 5;

///*
difference() {
// Subtract the spiral from the cube
translate([-spiralWidth/2, -spiralWidth/2, 0])
color("red", 0.3)
cube([spiralWidth, spiralWidth, spiralDepth*2]);

 translate([0, 0, spiralDepth*2 ])
     plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5);

}  // difference
//*/

//translate([0, 0, spiralDepth2 ])
//    plotSpiral(spiralWidth, spiralDepth
3, snakeSides=5);


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Yes it's always a good idea to set up your negative objects so that they extend beyond the surface a bit. The other issue with your script was that the top face of your spiral cutout was not flat. The second linear_extrude did not account for the additional translation amount, it should be: linear_extrude((angle + 1/spiralNumSegments)* spiralHeight) Still not sure why that completely broke the hull, but changing just that line by itself fixes the render (preview is still patchy without the added z offset, but that is expected). On Fri, Dec 17, 2021 at 2:42 PM Jim Witte <jim.witte@gmail.com> wrote: > Well, I moved the spiral a bit higher, changing the bit inside the > difference to: > > translate([0, 0, spiralDepth*2+0.1]) > plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); > > And it worked. Before I guess it just didn't quite go through the top of > the cube, and I guess that screws up the hull for some reason. > > On Fri, Dec 17, 2021 at 2:49 PM Michael Möller <private2michael@gmail.com> > wrote: > >> sitting here with the mobile on the bus, but >> >> linear_extrude(angle * spiralHeight) >> circle(d = sphereDiameterOne); >> >> why not just cylinder(h=angle*spiralHeight, d=sphereDiameterOne) >> >> >> Msquare >> >> fre. 17. dec. 2021 20.41 skrev Jim Witte <jim.witte@gmail.com>: >> >>> I have the following program, that is meant to construct a spiral that >>> gets progressively deeper, by using hulls between successive extrusions of >>> the circles that make it up. (A circle is extruded, then hulled to the >>> next one, etc). This is then subtracted from a cube. >>> >>> If I uncomment the plotSpiral() command at the bottom (without the >>> difference), it renders as I expect. But with the difference, it >>> differences the extrusions, but not the hulls between them. So the inside >>> of the spiral, where the individual extrusions overlap, it works like I >>> want (sort of), but on the outside, I just get a series of individual >>> pockets. >>> >>> I could change the angle spacing as I get further out (that would look >>> cleaner too), but that would take longer, and this whole thing will be done >>> with a ball-nose end mill anyway, which should smooth it out on it's own. >>> >>> Does anyone have any other ideas of how to get a "deepening spiral" >>> design? >>> >>> Thanks, >>> JIm >>> >>> --- >>> >>> module plotSpiral(spiralWidth, spiralHeight = 0, spiralThickness = 1, >>> snakeSides = 5) { >>> >>> // Number of sides of the "snake" >>> $fn = snakeSides; >>> >>> bumpiness = 1; >>> segmentsPerTurn = 35; >>> numTurns = 4; >>> numTurnsToPlot = 4; >>> >>> // *** Derived *** >>> >>> jCeiling = 1/numTurns*numTurnsToPlot; >>> sphereDiameterOne = spiralThickness/bumpiness; >>> sphereDiameterTwo = spiralThickness/bumpiness; >>> >>> //spiralWidth = 30; >>> //spiralHeight = 100; >>> spiralNumSegments = segmentsPerTurn * numTurns; >>> >>> spiralRadius = spiralWidth/2; >>> >>> exponent = 1.685; >>> //ORIG: exponent = 1.685; >>> >>> function L_Spiral (angle, >>> radius = 50, spiralDepth, turns = 4, >>> exponent = 0.685, start_angle = 0) = >>> let (fx = exponent < 0 ? >>> pow( max(0, 1-angle), 1/abs(min(-1, exponent-1) )) : >>> pow( max(0, 1-angle), max(1, exponent+1) ), >>> >>> depthVar = (angle * spiralDepth) >>> ) >>> [(radius * fx ) * cos(start_angle + >>> angle*turns*360*sign(turns)), >>> (radius * fx ) * sin(start_angle + >>> angle*turns*360*sign(turns)), >>> depthVar]; >>> >>> for (angle = [0 : 1/spiralNumSegments : jCeiling]) { >>> hull() { >>> //echo(angle); >>> translate(L_Spiral (angle, >>> spiralRadius, -spiralHeight, numTurns, >>> exponent, 0 )) >>> linear_extrude(angle * spiralHeight) >>> circle(d = sphereDiameterOne); >>> >>> translate(L_Spiral (angle + 1/spiralNumSegments, >>> spiralRadius, -spiralHeight, numTurns, >>> exponent, 0 )) >>> linear_extrude(angle * spiralHeight) >>> circle(d = sphereDiameterTwo); >>> } // hull() >>> } // for j >>> } // plotSpiral() >>> >>> spiralWidth = 30; >>> spiralDepth = 5; >>> >>> ///* >>> difference() { >>> // Subtract the spiral from the cube >>> translate([-spiralWidth/2, -spiralWidth/2, 0]) >>> color("red", 0.3) >>> cube([spiralWidth, spiralWidth, spiralDepth*2]); >>> >>> translate([0, 0, spiralDepth*2 ]) >>> plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); >>> } // difference >>> //*/ >>> >>> //translate([0, 0, spiralDepth*2 ]) >>> // plotSpiral(spiralWidth, spiralDepth*3, snakeSides=5); >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to discuss-leave@lists.openscad.org >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >