discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: Helix with circular cross-section

RW
Rogier Wolff
Sun, Oct 27, 2024 1:52 PM

On Fri, Oct 25, 2024 at 03:03:57PM -0400, L Michael Fraser wrote:

Following the posts of this group made me realize just how much I have lost
since I retired 8 years ago and stopped programming every day. My visit
from Mr COVID didn't help either.

All my moaning aside;  thanks!

For Rogier, in your sample code, you call "mys" twice, with 'i' & 'i+1'.
From what I can tell, this calls mys twice for every 'i' except for '0' and
nsteps. What is the purpose?  The output seems to be visually
identical, even at high magnification.

The "hull ()" between two close spheres produces a tube (with
rounded ends) that closely matches the shape we want to produce.

If only "just the spheres" without the "hull" produces the shape
you want, then the number of steps is way too high.  Also there
will be a concave corner between each of the spheres, while the
outside of the helix should be fully convex.

Anyway... Like linear extrude with a rotation, this just pastes
together "enough" small segments of what we want so that it looks
reasonably smooth.

So we first create a tube segment from i=0 to i=1 and then from i=1 to
i=2, etc. This uses each intermediate value twice except for the endpoints.

On my slow system (the one where I'm using an older version of openscad
without manifold)

module mys (n)
{
rotate (n * nr * 360/nsteps) translate ([d,0,n*l/nsteps])
//sphere (d=d);
rotate ([90,0,0]) cylinder (d=d, h=.1, center=true);
}

is 26x faster than the sphere version.

Roger. 

Mike

On Fri, Oct 25, 2024 at 12:09 PM L Michael Fraser <
mike.fraser.1945@gmail.com> wrote:

And here is the output with Rogier's input:

Thanks all.  Once again this group is AWSOME!

Mike
[image: image.png]

On Fri, Oct 25, 2024 at 12:03 PM L Michael Fraser <
mike.fraser.1945@gmail.com> wrote:

Here is what I get with spiral_sweep.  Notice the oval cross section.
Code below image

Mike
[image: image.png]

// Spiral-B
//Adrian Mariano input

$fn=90 ;

include <BOSL2/std.scad>
include <BOSL2/threading.scad>

path=right(3, p=circle(d=3)) ;

spiral_sweep(path, h=60,r=3,turns=1, spin=0  ) ;
spiral_sweep(path, h=60,r=3,turns=1, spin=120) ;
spiral_sweep(path, h=60,r=3,turns=1, spin=240) ;

On Fri, Oct 25, 2024 at 10:21 AM L Michael Fraser <
mike.fraser.1945@gmail.com> wrote:

Nope, I will try both RSN.

Mike

On Fri, Oct 25, 2024, 8:07 AM Rogier Wolff via Discuss <
discuss@lists.openscad.org> wrote:

On Fri, Oct 25, 2024 at 11:35:59AM +0000, mike.fraser.1945+osc--- via
Discuss wrote:

Is there any way to create a helix with a circular cross-section?  I
have tried linear_extrude with both a circle & various ovals as
input.  I’ve tried various BOLS2 threading functions.  I can get
the helix easily but not with a smooth circle cross-section.

Do you mean this?

r = 15;

d = 4;
l = 20;
nr = 4.5;
nsteps = 300;

$fs = .1;
$fa = 2;
module mys (n)
{
rotate (n * nr * 360/nsteps) translate ([d,0,n*l/nsteps]) sphere
(d=d);
}

for (i=[0:1:nsteps-1])
hull () {mys (i);mys(i+1);}

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ **
+31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233
**
f equals m times a. When your f is steady, and your m is going down
your a** is going up.  -- Chris Hadfield about flying up the space
shuttle.
**  'a' for accelleration.


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

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
f equals m times a. When your f is steady, and your m is going down
your a** is going up.  -- Chris Hadfield about flying up the space shuttle.
**  'a' for accelleration.

On Fri, Oct 25, 2024 at 03:03:57PM -0400, L Michael Fraser wrote: > Following the posts of this group made me realize just how much I have lost > since I retired 8 years ago and stopped programming every day. My visit > from Mr COVID didn't help either. > > All my moaning aside; thanks! > > For Rogier, in your sample code, you call "mys" twice, with 'i' & 'i+1'. > From what I can tell, this calls mys twice for every 'i' except for '0' and > nsteps. What is the purpose? The output seems to be visually > identical, even at high magnification. The "hull ()" between two close spheres produces a tube (with rounded ends) that closely matches the shape we want to produce. If only "just the spheres" without the "hull" produces the shape you want, then the number of steps is way too high. Also there will be a concave corner between each of the spheres, while the outside of the helix should be fully convex. Anyway... Like linear extrude with a rotation, this just pastes together "enough" small segments of what we want so that it looks reasonably smooth. So we first create a tube segment from i=0 to i=1 and then from i=1 to i=2, etc. This uses each intermediate value twice except for the endpoints. On my slow system (the one where I'm using an older version of openscad without manifold) module mys (n) { rotate (n * nr * 360/nsteps) translate ([d,0,n*l/nsteps]) //sphere (d=d); rotate ([90,0,0]) cylinder (d=d, h=.1, center=true); } is 26x faster than the sphere version. Roger. > > Mike > > On Fri, Oct 25, 2024 at 12:09 PM L Michael Fraser < > mike.fraser.1945@gmail.com> wrote: > > > And here is the output with Rogier's input: > > > > Thanks all. Once again this group is AWSOME! > > > > Mike > > [image: image.png] > > > > > > On Fri, Oct 25, 2024 at 12:03 PM L Michael Fraser < > > mike.fraser.1945@gmail.com> wrote: > > > >> Here is what I get with spiral_sweep. Notice the oval cross section. > >> Code below image > >> > >> Mike > >> [image: image.png] > >> > >> // Spiral-B > >> //Adrian Mariano input > >> > >> $fn=90 ; > >> > >> > >> include <BOSL2/std.scad> > >> include <BOSL2/threading.scad> > >> > >> path=right(3, p=circle(d=3)) ; > >> > >> spiral_sweep(path, h=60,r=3,turns=1, spin=0 ) ; > >> spiral_sweep(path, h=60,r=3,turns=1, spin=120) ; > >> spiral_sweep(path, h=60,r=3,turns=1, spin=240) ; > >> > >> On Fri, Oct 25, 2024 at 10:21 AM L Michael Fraser < > >> mike.fraser.1945@gmail.com> wrote: > >> > >>> Nope, I will try both RSN. > >>> > >>> Mike > >>> > >>> On Fri, Oct 25, 2024, 8:07 AM Rogier Wolff via Discuss < > >>> discuss@lists.openscad.org> wrote: > >>> > >>>> On Fri, Oct 25, 2024 at 11:35:59AM +0000, mike.fraser.1945+osc--- via > >>>> Discuss wrote: > >>>> > Is there any way to create a helix with a circular cross-section? I > >>>> > have tried linear_extrude with both a circle & various ovals as > >>>> > input. I’ve tried various BOLS2 threading functions. I can get > >>>> > the helix easily but not with a smooth circle cross-section. > >>>> > >>>> Do you mean this? > >>>> > >>>> r = 15; > >>>> > >>>> d = 4; > >>>> l = 20; > >>>> nr = 4.5; > >>>> nsteps = 300; > >>>> > >>>> $fs = .1; > >>>> $fa = 2; > >>>> module mys (n) > >>>> { > >>>> rotate (n * nr * 360/nsteps) translate ([d,0,n*l/nsteps]) sphere > >>>> (d=d); > >>>> } > >>>> > >>>> for (i=[0:1:nsteps-1]) > >>>> hull () {mys (i);mys(i+1);} > >>>> > >>>> > >>>> > >>>> -- > >>>> ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** > >>>> +31-15-2049110 ** > >>>> ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 > >>>> ** > >>>> f equals m times a. When your f is steady, and your m is going down > >>>> your a** is going up. -- Chris Hadfield about flying up the space > >>>> shuttle. > >>>> ** 'a' for accelleration. > >>>> _______________________________________________ > >>>> OpenSCAD mailing list > >>>> To unsubscribe send an email to discuss-leave@lists.openscad.org > >>>> > >>> -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** f equals m times a. When your f is steady, and your m is going down your a** is going up. -- Chris Hadfield about flying up the space shuttle. ** 'a' for accelleration.