discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Generating cylindical shape using linear_extrude or other command

S
Still_learning
Wed, Dec 20, 2017 2:52 AM

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/

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/
P
Parkinbot
Wed, Dec 20, 2017 12:23 PM

@ 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/Ni) r[sin(w), cos(w)]];
}

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

@ 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/
S
Still_learning
Wed, Dec 20, 2017 11:20 PM

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/

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/