Generating cylindical shape using linear_extrude or other command

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating cylindical shape using linear_extrude or other command

Still_learning

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The more I learn, the more I get curious about.
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

codifies

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

cacb
In reply to this post by Still_learning
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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Parkinbot
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

JordanBrown
In reply to this post by cacb
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

RevarBat
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: 


-Revar



On Dec 9, 2017, at 3:43 PM, Jordan Brown <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Ronaldo
In reply to this post by JordanBrown
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 <[hidden email]>:
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

thehans
You might be interesed in the helical coil implementation using linear_extrude that I came up with a while ago:

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 <[hidden email]> 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 <[hidden email]>:
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Still_learning
In reply to this post by RevarBat

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The more I learn, the more I get curious about.
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Ronaldo
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 <[hidden email]>:

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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Still_learning
Thanks for the referral on "extrude_2d_path..."

I will check it out.



-----
The more I learn, the more I get curious about.
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The more I learn, the more I get curious about.
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Parkinbot
@ Still_learning: this is a fully functional sweep code with a small
footprint. Note that it is essential to avoid self-intersection. Try out by
uncommenting each of the 3 example calls.
@ JordanBrown: Test the code. If this was the default behaviour of
linear_extrude when a twist parameter is given, linear_extrude could easily
run into trouble. The current implementation of linear_extrude is fail-safe
by specification.


use <Naca_sweep.scad>  // https://www.thingiverse.com/thing:900137

// helix();  // default
// helix(r=10, R=40, windings = 2, h=50);  cube(100);  // no self
intersection
// helix(r=10, R=40, windings = 2, h=30);  cube(100);  //
self-intersection!!! F6: CGAL complains

module helix(r=4, R=40, windings=5, h=150, M=40, N=40)
{
  M_ = ceil(M*windings); // slices
  slope = atan(h/windings/2/R/PI);
  sweep(trajectory());   //
 
  function trajectory() =  // prepare data for sweep()
  [for (i=[0:M_]) let(w = 360*windings/M_*i)
    Rz_(w,
      T_(R, 0, h/M_*i,
        Rx_(slope-90,
          vec3D(circle2D()))))];
 
  function circle2D() =  // polygon for cross section
  [for (i=[0:N]) let(w = 360/N*i) r*[sin(w), cos(w)]];
}




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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Generating cylindical shape using linear_extrude or other command

Still_learning
Thanks Parkinbot!

Great stuff.  Exactly what I was looking for.



-----
The more I learn, the more I get curious about.
--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
The more I learn, the more I get curious about.