discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

code for Helical spring in OpenSCAD wikibook

L
laich2@gmail.com
Tue, Sep 13, 2022 10:14 PM

Hi,

Anyone know where I can get the OpenSCAD model of the “Helical Spring” animation in the linear_extrude section? (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude)

best regards

sc

Hi, Anyone know where I can get the OpenSCAD model of the “Helical Spring” animation in the **linear_extrude** section? (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude) best regards sc
JB
Jordan Brown
Wed, Sep 14, 2022 1:12 AM

On 9/13/2022 3:14 PM, laich2@gmail.com wrote:

Anyone know where I can get the OpenSCAD model of the “Helical Spring”
animation in the linear_extrude section?
(https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude)

No, but a note:  you might think that linear_extrude with a twist is a
good way to generate helix-like shapes, but it really isn't.  The
problem is that you usually want to specify a cross-section across the
helix - nearly, but not precisely, a vertical cross-section, while what
you would have to supply with linear_extrude is a horizontal cross-section.

To get a helix with a round cross-section like this:

what you need to give to linear_extrude is a shape like this:

I'm sure that one of the mathematicians could tell you how to generate
that shape - I sure can't.  I generated it by using a sweep function to
create the helix, and then taking a cross section of the helix.

Here's that helix, using BOSL2's path_sweep module:

include <BOSL2/std.scad>
r = 20;
path_sweep(circle(5), [
    for (i=[0:10:900]) [ r*cos(i), r*sin(i), i/10 ]
]);
On 9/13/2022 3:14 PM, laich2@gmail.com wrote: > > Anyone know where I can get the OpenSCAD model of the “Helical Spring” > animation in the *linear_extrude* section? > (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude) > No, but a note:  you might think that linear_extrude with a twist is a good way to generate helix-like shapes, but it really isn't.  The problem is that you usually want to specify a cross-section across the helix - nearly, but not precisely, a vertical cross-section, while what you would have to supply with linear_extrude is a horizontal cross-section. To get a helix with a round cross-section like this: what you need to give to linear_extrude is a shape like this: I'm sure that one of the mathematicians could tell you how to generate that shape - I sure can't.  I generated it by using a sweep function to create the helix, and then taking a cross section of the helix. Here's that helix, using BOSL2's path_sweep module: include <BOSL2/std.scad> r = 20; path_sweep(circle(5), [ for (i=[0:10:900]) [ r*cos(i), r*sin(i), i/10 ] ]);
HL
Hans L
Wed, Sep 14, 2022 7:15 AM

I have an old helical coil design on thingiverse which you can try:
https://www.thingiverse.com/thing:1098806

On Tue, Sep 13, 2022 at 8:12 PM Jordan Brown openscad@jordan.maileater.net
wrote:

On 9/13/2022 3:14 PM, laich2@gmail.com wrote:

Anyone know where I can get the OpenSCAD model of the “Helical Spring”
animation in the linear_extrude section? (
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude
)

No, but a note:  you might think that linear_extrude with a twist is a
good way to generate helix-like shapes, but it really isn't.  The problem
is that you usually want to specify a cross-section across the helix -
nearly, but not precisely, a vertical cross-section, while what you would
have to supply with linear_extrude is a horizontal cross-section.

To get a helix with a round cross-section like this:

what you need to give to linear_extrude is a shape like this:

I'm sure that one of the mathematicians could tell you how to generate
that shape - I sure can't.  I generated it by using a sweep function to
create the helix, and then taking a cross section of the helix.

Here's that helix, using BOSL2's path_sweep module:

include <BOSL2/std.scad>
r = 20;
path_sweep(circle(5), [
for (i=[0:10:900]) [ rcos(i), rsin(i), i/10 ]
]);


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

I have an old helical coil design on thingiverse which you can try: https://www.thingiverse.com/thing:1098806 On Tue, Sep 13, 2022 at 8:12 PM Jordan Brown <openscad@jordan.maileater.net> wrote: > On 9/13/2022 3:14 PM, laich2@gmail.com wrote: > > Anyone know where I can get the OpenSCAD model of the “Helical Spring” > animation in the *linear_extrude* section? ( > https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude > ) > > > No, but a note: you might think that linear_extrude with a twist is a > good way to generate helix-like shapes, but it really isn't. The problem > is that you usually want to specify a cross-section across the helix - > nearly, but not precisely, a vertical cross-section, while what you would > have to supply with linear_extrude is a horizontal cross-section. > > To get a helix with a round cross-section like this: > > > what you need to give to linear_extrude is a shape like this: > > > > I'm sure that one of the mathematicians could tell you how to generate > that shape - I sure can't. I generated it by using a sweep function to > create the helix, and then taking a cross section of the helix. > > Here's that helix, using BOSL2's path_sweep module: > > include <BOSL2/std.scad> > r = 20; > path_sweep(circle(5), [ > for (i=[0:10:900]) [ r*cos(i), r*sin(i), i/10 ] > ]); > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RD
Revar Desmera
Wed, Sep 14, 2022 8:13 AM

If you're going to use BOSL2, then spiral_sweep() already exists for just this purpose:
include <BOSL2/std.scad>
spiral_sweep(circle(5), h=90, r=20, turns=2.5);

  • Revar

On Sep 13, 2022, at 6:12 PM, Jordan Brown openscad@jordan.maileater.net wrote:

On 9/13/2022 3:14 PM, laich2@gmail.com mailto:laich2@gmail.com wrote:

Anyone know where I can get the OpenSCAD model of the “Helical Spring” animation in the linear_extrude section? (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude)

No, but a note:  you might think that linear_extrude with a twist is a good way to generate helix-like shapes, but it really isn't.  The problem is that you usually want to specify a cross-section across the helix - nearly, but not precisely, a vertical cross-section, while what you would have to supply with linear_extrude is a horizontal cross-section.

To get a helix with a round cross-section like this:
<Esv568UuTkLejpfN.png>

what you need to give to linear_extrude is a shape like this:

<kFWxNdUdBzrBU5fr.png>

I'm sure that one of the mathematicians could tell you how to generate that shape - I sure can't.  I generated it by using a sweep function to create the helix, and then taking a cross section of the helix.

Here's that helix, using BOSL2's path_sweep module:
include <BOSL2/std.scad>
r = 20;
path_sweep(circle(5), [
for (i=[0:10:900]) [ rcos(i), rsin(i), i/10 ]
]);


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

If you're going to use BOSL2, then `spiral_sweep()` already exists for just this purpose: include <BOSL2/std.scad> spiral_sweep(circle(5), h=90, r=20, turns=2.5); - Revar > On Sep 13, 2022, at 6:12 PM, Jordan Brown <openscad@jordan.maileater.net> wrote: > > On 9/13/2022 3:14 PM, laich2@gmail.com <mailto:laich2@gmail.com> wrote: >> Anyone know where I can get the OpenSCAD model of the “Helical Spring” animation in the linear_extrude section? (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude <https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude>) >> > > No, but a note: you might think that linear_extrude with a twist is a good way to generate helix-like shapes, but it really isn't. The problem is that you usually want to specify a cross-section across the helix - nearly, but not precisely, a vertical cross-section, while what you would have to supply with linear_extrude is a horizontal cross-section. > > To get a helix with a round cross-section like this: > <Esv568UuTkLejpfN.png> > > what you need to give to linear_extrude is a shape like this: > > <kFWxNdUdBzrBU5fr.png> > > I'm sure that one of the mathematicians could tell you how to generate that shape - I sure can't. I generated it by using a sweep function to create the helix, and then taking a cross section of the helix. > > Here's that helix, using BOSL2's path_sweep module: > include <BOSL2/std.scad> > r = 20; > path_sweep(circle(5), [ > for (i=[0:10:900]) [ r*cos(i), r*sin(i), i/10 ] > ]); > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
RW
Raymond West
Wed, Sep 14, 2022 12:51 PM

here's some generic code for spirals/threads, whatever.

clw = true;  // direction of spiral
p = 15;      // pitch of spiral
n = 3.5;     // number of 'threads'
res = 100;   // number of 'steps' in circle
di = 20;     // diam of os of spiral
d = 5;       // diam of 'wire'

////////////////////

t = n*res;    //total number of steps
s = (res/360)*di/2; // width of profile
v = p/res;   // vertical shift per inc of rotation
//a = 360/res; // angle per step
a=clw==true ?  360/res  : -360/res;

module xsec(){
  $fn=80;
    translate([di-(d/2),0,0])
    rotate([90,0,0])
  //cylinder (d=d,h=s/2);  // whatever 'profile' you like
    cube([d,d,s/2],true);
}

for (i=[0:1:t]){
   translate([0,0,iv])
   rotate([0,0,i
a])
   xsec();
 }

It's relatively simple to change the profile or resolution as required,
to make buttress threads, Whitworth profile, whatever. Easy enough to
convert to a function/module with relevant parameters, change
resolution, etc..

On 13/09/2022 23:14, laich2@gmail.com wrote:

Hi,

Anyone know where I can get the OpenSCAD model of the “Helical Spring”
animation in the linear_extrude section?
(https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude)

best regards

sc


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

here's some generic code for spirals/threads, whatever. clw = true;  // direction of spiral p = 15;      // pitch of spiral n = 3.5;     // number of 'threads' res = 100;   // number of 'steps' in circle di = 20;     // diam of os of spiral d = 5;       // diam of 'wire' //////////////////// t = n*res;    //total number of steps s = (res/360)*di/2; // width of profile v = p/res;   // vertical shift per inc of rotation //a = 360/res; // angle per step a=clw==true ?  360/res  : -360/res; module xsec(){   $fn=80;     translate([di-(d/2),0,0])     rotate([90,0,0])   //cylinder (d=d,h=s/2);  // whatever 'profile' you like     cube([d,d,s/2],true); } for (i=[0:1:t]){    translate([0,0,i*v])    rotate([0,0,i*a])    xsec();  } It's relatively simple to change the profile or resolution as required, to make buttress threads, Whitworth profile, whatever. Easy enough to convert to a function/module with relevant parameters, change resolution, etc.. On 13/09/2022 23:14, laich2@gmail.com wrote: > > Hi, > > Anyone know where I can get the OpenSCAD model of the “Helical Spring” > animation in the *linear_extrude* section? > (https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Using_the_2D_Subsystem#linear_extrude) > > best regards > > sc > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org