discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Generating cylindical shape using linear_extrude or other command

JS
John Sprockets
Sat, Dec 9, 2017 1:10 AM

Greetings to the list.

I am attempting to create a helical looped form from a cylinder using
linear_extrude.

Though it appears semi-cylindrical in a  perspective orthogonal view, in a
side view the cylinder appears flat.

Is their any way to fill out this twisted circle?

I realize linear_extrude says it should not be used to generate helical
windings.

Is there another module or command I should be using?

All help is appreciated.

Greetings to the list. I am attempting to create a helical looped form from a cylinder using linear_extrude. Though it appears semi-cylindrical in a perspective orthogonal view, in a side view the cylinder appears flat. Is their any way to fill out this twisted circle? I realize linear_extrude says it should not be used to generate helical windings. Is there another module or command I should be using? All help is appreciated.
CC
Chris Camacho
Sat, Dec 9, 2017 1:49 AM

I'm not sure exactly what you're trying to describe, but I fished around
my archive and found this that might help inspire you

STEP=2; // fine in most cases
TUBE = 2; // radius of tube

SIDES=4; // number of sides in the profile 3 to 16 (unless printed very
large 16 should be plenty for printing)

r=2;   // torus minor radius
R=4; // torus major radius

P=2;  // inner term
Q=3; // outer term

// don't just set $fn as SIDES is used elsewhere
$fn=SIDES; // use to select number of faces in the path profile

// calculates position in path a=angle
function knot(a) =
    let( t = [ rsin(Qa), rcos(Qa) - R, rsin(Qa) ] ) // section
parametrization
    [ [ cos(Pa), -sin(Pa), 0],
      [ sin(Pa),  cos(Pa), 0],  // rotation in z of p*a degrees
      [0,0,1] ] * t;

// from wiki

// Find the unitary vector with direction v. Fails if v=[0,0,0].
function unit(v) = norm(v)>0 ? v/norm(v) : undef;
// Find the transpose of a rectangular matrix
function transpose(m) = // m is any rectangular matrix of objects
  [ for(j=[0:len(m[0])-1]) [ for(i=[0:len(m)-1]) m[i][j] ] ];
// The identity matrix with dimension n
function identity(n) = [for(i=[0:n-1]) [for(j=[0:n-1]) i==j ? 1 : 0] ];

// computes the rotation with minimum angle that brings a to b
// the code fails if a and b are opposed to each other
function rotate_from_to(a,b) =
    let( axis = unit(cross(a,b)) )
    axis*axis >= 0.99 ?
        transpose([unit(b), axis, cross(axis, unit(b))]) *
            [unit(a), axis, cross(axis, unit(a))] :
        identity(3);

for (a=[0:STEP:360-STEP]) {
  v = knot(a) - knot(a+STEP);
  v2 = knot(a+STEP) - knot(a+STEP+STEP);
  hull() {
    translate(knot(a))
      multmatrix(rotate_from_to([0,0,1],v))
        rotate(a*(1+(2.0/SIDES)))  // fudge
          //cylinder(r=TUBE,h=0.001,center=true);
        cube([TUBE,TUBE/8,0.001],center=true);
    translate(knot(a+STEP))
      multmatrix(rotate_from_to([0,0,1],v2))
        rotate(((a+STEP)*(1+(2.0/SIDES)))) // fudge
          //cylinder(r=TUBE,h=0.001,center=true);
        cube([TUBE,TUBE/8,0.001],center=true);

  }
}

On 09/12/17 01:10, John Sprockets wrote:

Greetings to the list.

I am attempting to create a helical looped form from a cylinder using
linear_extrude.

Though it appears semi-cylindrical in a  perspective orthogonal view,
in a side view the cylinder appears flat.

Is their any way to fill out this twisted circle?

I realize linear_extrude says it should not be used to generate
helical windings.

Is there another module or command I should be using?

All help is appreciated.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I'm not sure exactly what you're trying to describe, but I fished around my archive and found this that might help inspire you STEP=2; // fine in most cases TUBE = 2; // radius of tube SIDES=4; // number of sides in the profile 3 to 16 (unless printed very large 16 should be plenty for printing) r=2;   // torus minor radius R=4; // torus major radius P=2;  // inner term Q=3; // outer term // don't just set $fn as SIDES is used elsewhere $fn=SIDES; // use to select number of faces in the path profile // calculates position in path a=angle function knot(a) =     let( t = [ r*sin(Q*a), r*cos(Q*a) - R, r*sin(Q*a) ] ) // section parametrization     [ [ cos(P*a), -sin(P*a), 0],       [ sin(P*a),  cos(P*a), 0],  // rotation in z of p*a degrees       [0,0,1] ] * t; // from wiki // Find the unitary vector with direction v. Fails if v=[0,0,0]. function unit(v) = norm(v)>0 ? v/norm(v) : undef; // Find the transpose of a rectangular matrix function transpose(m) = // m is any rectangular matrix of objects   [ for(j=[0:len(m[0])-1]) [ for(i=[0:len(m)-1]) m[i][j] ] ]; // The identity matrix with dimension n function identity(n) = [for(i=[0:n-1]) [for(j=[0:n-1]) i==j ? 1 : 0] ]; // computes the rotation with minimum angle that brings a to b // the code fails if a and b are opposed to each other function rotate_from_to(a,b) =     let( axis = unit(cross(a,b)) )     axis*axis >= 0.99 ?         transpose([unit(b), axis, cross(axis, unit(b))]) *             [unit(a), axis, cross(axis, unit(a))] :         identity(3); for (a=[0:STEP:360-STEP]) {   v = knot(a) - knot(a+STEP);   v2 = knot(a+STEP) - knot(a+STEP+STEP);   hull() {     translate(knot(a))       multmatrix(rotate_from_to([0,0,1],v))         rotate(a*(1+(2.0/SIDES)))  // fudge           //cylinder(r=TUBE,h=0.001,center=true);         cube([TUBE,TUBE/8,0.001],center=true);     translate(knot(a+STEP))       multmatrix(rotate_from_to([0,0,1],v2))         rotate(((a+STEP)*(1+(2.0/SIDES)))) // fudge           //cylinder(r=TUBE,h=0.001,center=true);         cube([TUBE,TUBE/8,0.001],center=true);   } } On 09/12/17 01:10, John Sprockets wrote: > > Greetings to the list. > > I am attempting to create a helical looped form from a cylinder using > linear_extrude. > > Though it appears semi-cylindrical in a  perspective orthogonal view, > in a side view the cylinder appears flat. > > Is their any way to fill out this twisted circle? > > I realize linear_extrude says it should not be used to generate > helical windings. > > Is there another module or command I should be using? > > All help is appreciated. > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
A
arnholm@arnholm.org
Sat, Dec 9, 2017 12:56 PM

On 2017-12-09 02:10, John Sprockets wrote:

Greetings to the list.

I am attempting to create a helical looped form from a cylinder using
linear_extrude.

You mean extruding along a helical path? You cannot do that with linear
extrude. That would be a sweep operation, which isn't a core feature in
OpenSCAD. People have made sweep functionality as .scad scripts though,
so perhaps you could use it (I don't have a reference).

Carsten Arnholm

On 2017-12-09 02:10, John Sprockets wrote: > Greetings to the list. > > I am attempting to create a helical looped form from a cylinder using > linear_extrude. You mean extruding along a helical path? You cannot do that with linear extrude. That would be a sweep operation, which isn't a core feature in OpenSCAD. People have made sweep functionality as .scad scripts though, so perhaps you could use it (I don't have a reference). Carsten Arnholm
P
Parkinbot
Sat, Dec 9, 2017 1:25 PM

Carsten,

"you cannot do that" is a very rigid phrase. We had some discussion about
this theme before and there were solutions, at least to some extend (helical
angle). Have a look here:

http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20170.html

The only practical problem is that you have to find (and calculate) the
proper projection of the helical shape to the XY - axis which is not a
simple task.

Concerning the sweep approach, there are many helical structures like
threadings that will not be sweepable due to inherent self-intersection. (We
have discussed that theme before.) Ι have published a threading libray that
deals with it in a tricky way by extruding and unioning two half sweeps:

https://www.thingiverse.com/thing:1659079

cacb wrote

You mean extruding along a helical path? You cannot do that with linear
extrude. That would be a sweep operation, which isn't a core feature in
OpenSCAD. People have made sweep functionality as .scad scripts though,
so perhaps you could use it (I don't have a reference).

Carsten, "you cannot do that" is a very rigid phrase. We had some discussion about this theme before and there were solutions, at least to some extend (helical angle). Have a look here: http://forum.openscad.org/how-to-make-the-groove-more-width-tp20154p20170.html The *only* practical problem is that you have to find (and calculate) the proper projection of the helical shape to the XY - axis which is not a simple task. Concerning the sweep approach, there are many helical structures like threadings that will not be sweepable due to inherent self-intersection. (We have discussed that theme before.) Ι have published a threading libray that deals with it in a tricky way by extruding and unioning two half sweeps: https://www.thingiverse.com/thing:1659079 cacb wrote > You mean extruding along a helical path? You cannot do that with linear > extrude. That would be a sweep operation, which isn't a core feature in > OpenSCAD. People have made sweep functionality as .scad scripts though, > so perhaps you could use it (I don't have a reference). -- Sent from: http://forum.openscad.org/
JB
Jordan Brown
Sat, Dec 9, 2017 11:43 PM

Pardon my ignorance of geometry, but could somebody explain why the
obvious use of linear_extrude isn't a helix?

Is the problem that if you want some particular vertical cross-section
of the object to have a particular shape you have to generate the
horizontal cross-section, and that's hard?  (e.g. to generate a circular
cross-section you'd need something sort of kidney-bean shaped)

Pardon my ignorance of geometry, but could somebody explain why the obvious use of linear_extrude *isn't* a helix? Is the problem that if you want some particular vertical cross-section of the object to have a particular shape you have to generate the horizontal cross-section, and that's hard?  (e.g. to generate a circular cross-section you'd need something sort of kidney-bean shaped)
RD
Revar Desmera
Sun, Dec 10, 2017 12:48 AM

I’m unclear if this is quite what the original poster wants, but the BOSL library has, as part of its BOSL/paths.scad library, a module to sweep a polyline (array of 2D points) perpendicularly along a helical path:

extrude_2dpath_along_spiral(polyline, h, r, twist=360);

It makes a polygon directly, though it won’t deal with self intersection.
// Takes a closed 2D polyline path, centered on the XY plane, and
// extrudes it along a 3D spiral path of a given radius, height and twist.
//  polyline = Array of points of a polyline path, to be extruded.
//  h = height of the spiral to extrude along.
//  r = radius of the spiral to extrude along.
//  twist = number of degrees of rotation to spiral up along height.
// Example:
//  poly = [[-10,0], [-3,-5], [3,-5], [10,0], [0,-30]];
//  extrude_2dpath_along_spiral(poly, h=200, r=50, twist=1000, $fn=36);

You can find BOSL at:

https://github.com/revarbat/BOSL

-Revar

On Dec 9, 2017, at 3:43 PM, Jordan Brown openscad@jordan.maileater.net wrote:

Pardon my ignorance of geometry, but could somebody explain why the obvious use of linear_extrude isn't a helix?

Is the problem that if you want some particular vertical cross-section of the object to have a particular shape you have to generate the horizontal cross-section, and that's hard?  (e.g. to generate a circular cross-section you'd need something sort of kidney-bean shaped)


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I’m unclear if this is quite what the original poster wants, but the BOSL library has, as part of its BOSL/paths.scad library, a module to sweep a polyline (array of 2D points) perpendicularly along a helical path: extrude_2dpath_along_spiral(polyline, h, r, twist=360); It makes a polygon directly, though it won’t deal with self intersection. // Takes a closed 2D polyline path, centered on the XY plane, and // extrudes it along a 3D spiral path of a given radius, height and twist. // polyline = Array of points of a polyline path, to be extruded. // h = height of the spiral to extrude along. // r = radius of the spiral to extrude along. // twist = number of degrees of rotation to spiral up along height. // Example: // poly = [[-10,0], [-3,-5], [3,-5], [10,0], [0,-30]]; // extrude_2dpath_along_spiral(poly, h=200, r=50, twist=1000, $fn=36); You can find BOSL at: https://github.com/revarbat/BOSL -Revar > On Dec 9, 2017, at 3:43 PM, Jordan Brown <openscad@jordan.maileater.net> wrote: > > Pardon my ignorance of geometry, but could somebody explain why the obvious use of linear_extrude *isn't* a helix? > > Is the problem that if you want some particular vertical cross-section of the object to have a particular shape you have to generate the horizontal cross-section, and that's hard? (e.g. to generate a circular cross-section you'd need something sort of kidney-bean shaped) > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
RP
Ronaldo Persiano
Sun, Dec 10, 2017 1:33 AM

The twisted linear_extrude follows a helicoidal path indeed but its sweep
is done by translating the initial 2D shape without rotations. So the
orthogonal section of the result is not the linear_extrude shape. And yes,
If you deform appropriately the 2D shape to be extruded you may get the
expected result.

difference(){
linear_extrude(height=10,twist=720,$fn=24)
translate([-5,0,0])
circle(3);
cube(20);
}

2017-12-09 21:43 GMT-02:00 Jordan Brown openscad@jordan.maileater.net:

Pardon my ignorance of geometry, but could somebody explain why the
obvious use of linear_extrude isn't a helix?

Is the problem that if you want some particular vertical cross-section of
the object to have a particular shape you have to generate the horizontal
cross-section, and that's hard?  (e.g. to generate a circular cross-section
you'd need something sort of kidney-bean shaped)

The twisted linear_extrude follows a helicoidal path indeed but its sweep is done by translating the initial 2D shape without rotations. So the orthogonal section of the result is not the linear_extrude shape. And yes, If you deform appropriately the 2D shape to be extruded you may get the expected result. difference(){ linear_extrude(height=10,twist=720,$fn=24) translate([-5,0,0]) circle(3); cube(20); } ​ 2017-12-09 21:43 GMT-02:00 Jordan Brown <openscad@jordan.maileater.net>: > Pardon my ignorance of geometry, but could somebody explain why the > obvious use of linear_extrude *isn't* a helix? > > Is the problem that if you want some particular vertical cross-section of > the object to have a particular shape you have to generate the horizontal > cross-section, and that's hard? (e.g. to generate a circular cross-section > you'd need something sort of kidney-bean shaped) >
HL
Hans L
Sun, Dec 10, 2017 3:16 AM

You might be interesed in the helical coil implementation using
linear_extrude that I came up with a while ago:
https://www.thingiverse.com/thing:1098806

Explanation of how it works is in the description, with a graphic showing
the steps.

Hans

On Sat, Dec 9, 2017 at 7:33 PM, Ronaldo Persiano rcmpersiano@gmail.com
wrote:

The twisted linear_extrude follows a helicoidal path indeed but its sweep
is done by translating the initial 2D shape without rotations. So the
orthogonal section of the result is not the linear_extrude shape. And yes,
If you deform appropriately the 2D shape to be extruded you may get the
expected result.

difference(){
linear_extrude(height=10,twist=720,$fn=24)
translate([-5,0,0])
circle(3);
cube(20);
}

2017-12-09 21:43 GMT-02:00 Jordan Brown openscad@jordan.maileater.net:

Pardon my ignorance of geometry, but could somebody explain why the
obvious use of linear_extrude isn't a helix?

Is the problem that if you want some particular vertical cross-section of
the object to have a particular shape you have to generate the horizontal
cross-section, and that's hard?  (e.g. to generate a circular cross-section
you'd need something sort of kidney-bean shaped)

You might be interesed in the helical coil implementation using linear_extrude that I came up with a while ago: https://www.thingiverse.com/thing:1098806 Explanation of how it works is in the description, with a graphic showing the steps. Hans On Sat, Dec 9, 2017 at 7:33 PM, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > The twisted linear_extrude follows a helicoidal path indeed but its sweep > is done by translating the initial 2D shape without rotations. So the > orthogonal section of the result is not the linear_extrude shape. And yes, > If you deform appropriately the 2D shape to be extruded you may get the > expected result. > > difference(){ > linear_extrude(height=10,twist=720,$fn=24) > translate([-5,0,0]) > circle(3); > cube(20); > } > > > ​ > > 2017-12-09 21:43 GMT-02:00 Jordan Brown <openscad@jordan.maileater.net>: > >> Pardon my ignorance of geometry, but could somebody explain why the >> obvious use of linear_extrude *isn't* a helix? >> >> Is the problem that if you want some particular vertical cross-section of >> the object to have a particular shape you have to generate the horizontal >> cross-section, and that's hard? (e.g. to generate a circular cross-section >> you'd need something sort of kidney-bean shaped) >> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
S
Still_learning
Tue, Dec 12, 2017 10:45 PM

I’m unclear if this is quite what the original poster wants

The easiest way to describe what I want to achieve would be comparable to
taking a dowel and wrapping a length of round wire around it.  The wire
remains round and bent into a helical configuration.

The wire is the cylinder (circle with defined radius).

The overall length of the helix is the "height"

The number of revolutions is governed by "twist"

Sorry for the delay in getting back to the list.


The more I learn, the more I get curious about.

Sent from: http://forum.openscad.org/

I’m unclear if this is quite what the original poster wants The easiest way to describe what I want to achieve would be comparable to taking a dowel and wrapping a length of round wire around it. The wire remains round and bent into a helical configuration. The wire is the cylinder (circle with defined radius). The overall length of the helix is the "height" The number of revolutions is governed by "twist" Sorry for the delay in getting back to the list. ----- The more I learn, the more I get curious about. -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Tue, Dec 12, 2017 11:11 PM

It was clear to me. What you want is called a sweep which is not a built-in
operation in OpenSCAD. There is many codes to do this and they usually do
it either by the lengthy union of short cylinders or using polyhedron
primitive which is a lot faster. The referred extrude_2dpath_along_spiral
of BSOL library uses polyhedron and may solve your problem. I have never
use it though.

2017-12-12 20:45 GMT-02:00 Still_learning sprocketsjohn@gmail.com:

I’m unclear if this is quite what the original poster wants

The easiest way to describe what I want to achieve would be comparable to
taking a dowel and wrapping a length of round wire around it.  The wire
remains round and bent into a helical configuration.

The wire is the cylinder (circle with defined radius).

The overall length of the helix is the "height"

The number of revolutions is governed by "twist"

Sorry for the delay in getting back to the list.


The more I learn, the more I get curious about.

Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

It was clear to me. What you want is called a sweep which is not a built-in operation in OpenSCAD. There is many codes to do this and they usually do it either by the lengthy union of short cylinders or using polyhedron primitive which is a lot faster. The referred extrude_2dpath_along_spiral of BSOL library uses polyhedron and may solve your problem. I have never use it though. 2017-12-12 20:45 GMT-02:00 Still_learning <sprocketsjohn@gmail.com>: > > I’m unclear if this is quite what the original poster wants > > The easiest way to describe what I want to achieve would be comparable to > taking a dowel and wrapping a length of round wire around it. The wire > remains round and bent into a helical configuration. > > The wire is the cylinder (circle with defined radius). > > The overall length of the helix is the "height" > > The number of revolutions is governed by "twist" > > Sorry for the delay in getting back to the list. > > > > > > ----- > The more I learn, the more I get curious about. > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >