Parabolic tube.

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

Parabolic tube.

rew

Hi,

Does anybody know an elegant way to create a tube with a parabolic
form? I can manually create a bunch of spheres on the curve and HULL
those pair-by-pair and union the hulls. Does anybody know a more
elegant way?

        Roger.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Parabolic tube.

TLC123
Can you clarify what you mean.
Parabolic form in what way?
parabolic along: profile, radius, outside, inside or maybe parabolic
thickness?




--
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: Parabolic tube.

nophead
A parabola is a conic section so you could rotate a cone and use projection(cut = true) it to get one. If you want a hollow tube you could subtract an offset version of it and then linear_extrude it.

On Tue, 14 Apr 2020 at 15:02, TLC123 <[hidden email]> wrote:
Can you clarify what you mean.
Parabolic form in what way?
parabolic along: profile, radius, outside, inside or maybe parabolic
thickness?




--
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: Parabolic tube.

nophead
image.png

On Tue, 14 Apr 2020 at 15:21, nop head <[hidden email]> wrote:
A parabola is a conic section so you could rotate a cone and use projection(cut = true) it to get one. If you want a hollow tube you could subtract an offset version of it and then linear_extrude it.

On Tue, 14 Apr 2020 at 15:02, TLC123 <[hidden email]> wrote:
Can you clarify what you mean.
Parabolic form in what way?
parabolic along: profile, radius, outside, inside or maybe parabolic
thickness?




--
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
rew
Reply | Threaded
Open this post in threaded view
|

Re: Parabolic tube.

rew
In reply to this post by nophead
On Tue, Apr 14, 2020 at 03:21:02PM +0100, nop head wrote:

> A parabola is a conic section so you could rotate a cone and use
> projection(cut = true) it to get one. If you want a hollow tube you could
> subtract an offset version of it and then linear_extrude it.
>
> On Tue, 14 Apr 2020 at 15:02, TLC123 <[hidden email]> wrote:
>
> > Can you clarify what you mean.
> > Parabolic form in what way?
> > parabolic along: profile, radius, outside, inside or maybe parabolic
> > thickness?

What Nop Head did is not what I meant.

Think of plotting a parabola like in highschool. But now I want to 3D
print that curve, so instead of the line on the paper, I want to give
it some thickness. For my current project I don't need it hollowed
out. But if we specifiy the parabola and an R, specifying the same
parabola and R- wall_thickness you can subtract that to get a tube.

module parabola (p1, p2, p3, r, x0, x1, fn )
{
  s = (x1-x0)/fn;

  for (x=[x0:s:x1-s]) {
    hull () {
      xs = x+s;
      translate ([x,p1*x*x+p2*x+p3,0]) sphere (r=r);
      translate ([xs,p1*xs*xs+p2*xs+p3,0]) sphere (r=r);
    }
  }
}

$fn = 20;

parabola (1,0,0, .3, -2, 2, 20);



        Roger.

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Parabolic tube.

Parkinbot
instead of unioning pairs of hulled spheres you could use a union of pairs of
hulled "short" cylinders. Of course each cylinder must be properly rotated.

The best and fastest way to realise your design is a sweep:


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

a = 1;
x0 = -2;
x1 = 2;
N = 30;
P = parabola(a, x0, x1, N);
sweep(tube_dat(P));

function tube_dat(P) =
[
  for(i=[0:len(P)-1])
    let(w = atan(2*a*P[i][0]))  // f'(x) = 2ax
    T(P[i][0], P[i][1], 0,
      Rz(w, Ry(-90, circle(.3, N))))
];
 

// symmetric parabola: f(x)= a*x²
function parabola(a=.005, x0=-100, x1=100, N=10) =
  [for(i=[0:N-1]) let(x = x0+i/(N-1)*(x1-x0)) [x, a*x*x]];

function circle(r, N) = [for(i=[0:N-1]) let(a= 360/N*i)
  r*[sin(a), cos(a), 0]];



--
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: Parabolic tube.

JordanBrown
In reply to this post by rew
When I've wanted something like that, I connect up a bunch of cylinderoids and spheroids using a module called pipe_polygon.

Here's an implementation using my current pipe_polygon.  It's got several more features than you're asking for, like the ability to justify the polygon relative to the origin.

Notes:
  • I don't remember why I insist on setting $fn rather than letting $fa and $fs work.  Maybe it was to default $fnz, or maybe it was just because I forgot about them.
  • It looks like I planned to generate just a slice at a corner and then rotate into place, rather than generating a full spheroid.  I don't remember why I didn't follow through.  As a result the joints are not quite perfect.
  • There's probably a problem at the ends if the last segment is shorter than the radius and round ends are turned off.

parabola(1,0,0, .3, -2, 2, 20);

module parabola (p1, p2, p3, r, x0, x1, fn )
{
    s = (x1-x0)/fn;

    points = [ for (x=[x0:s:x1]) [x,p1*x*x+p2*x+p3,0] ];
    pipe_polygon(points, r=r, open=true, round_ends=false);
}

// OpenSCAD polygons have their radius/diameter
// measured to the vertices.  These functions
// give you adjusted r/d that will yield the
// specified r/d to the edges.
function adjustr(r, n) = r / cos(360/n/2);
function adjustd(d, n) = 2*adjustr(d/2, n);

function default(val, def) = (val != undef) ? val : def;

// @brief    Justify children as specified by argument.
// @param center   Equivalent to justify=[0,0,0].
// @param justify  [jx,jy,jz]:  1=toward-positive, 0=center, -1=toward-negative
// @param dims     Dimensions of child to justify
module justify(center, justify, dims) {
    function o(flag, dim) = flag > 0 ? 0 :
        flag < 0 ? -dim :
        -dim/2;
    j = default(justify, center ? [0,0,0] : [1,1,1]);
    translate([o(j[0], dims[0]),
        o(j[1], dims[1]),
        o(j[2], dims[2])]) children();
}

// Given a series of points, connect them with a pipe.
// This module has more features than are used in this model.
// poly - the array of points.
// r, d - the radius or diameter of the pipe.  Defaults to d=1.  (NB this is measured to the edges.)
// fill - if true, fill the interior of the figure, yielding a
// filled polygon with rounded edges.  Requires open=false.  Defaults to false.
// open - if false, connect the start and end points to close
// the polygon.  Defaults to false.
// justify - justify the polygon as specified.  Defaults to [1,1,1].
// round_ends - if true, cap the ends.  Defaults to true.
// $fn - controls smoothness at corners.  Defaults to 32.
// $fnz - the $fn value to use for the cylinder and the z-curves at the
// corners.  This lets you make pipes with polygonal cross-sections.  Defaults to $fn.
// NEEDSWORK:  $fa, $fs, and $fn should control the smoothness at corners.
module pipe_polygon(poly, r, d, fill=false, open=false, justify=[1,1,1], round_ends=true) {
    fn = $fn ? $fn : 32;
    fnz = is_undef($fnz) ? fn : $fnz;
    dims = [
        max([for (p=poly) p[0]]),
        max([for (p=poly) p[1]]),
        0
    ];
    _r = default(r, default(d,1)/2);
    radjusted = adjustr(_r, fnz);
    justify(justify=justify, dims=dims) {
        $fn = fn;
        $fnz = fnz;
        for (i = [(round_ends ? 0 : 1) : len(poly)-(round_ends ? 1 : 2)]) {
            p = poly[i];
            translate([p[0], p[1], 0]) corner(r=radjusted);
        }
        poly2 = open ? poly : concat(poly, [poly[0]]);
        for (i=[0:len(poly2)-2]) {
            p1 = poly2[i];
            p2 = poly2[i+1];
            dy = p2[1] - p1[1];
            dx = p2[0] - p1[0];
            translate([p1[0], p1[1], 0]) {
                rotate([0,90,atan2(dy, dx)])
                rotate([0,0,360/fnz/2])
                    cylinder(r=radjusted, h=norm([dx, dy]), $fn=$fnz);
            }
        }
        if (fill) linear_extrude(_r*2, center=true) polygon(poly);
    }
    // corner() defaults to a slice of a spheroid.  It's done
    // this way so that it can have different smoothing in x-y
    // and z, so that it can mate with a polygonal pipe.
    module corner(r, a) {
        rotate_extrude(angle=a) {
            intersection() {
                rotate([0,0,360/$fnz/2])
                    circle(r=r, $fn=$fnz);
                translate([0,-r*2])
                    square([r*2, r*4]);
            }
        }
    }
}


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

Re: Parabolic tube.

adrianv
Here's another option for sweep using BOSL2 (though be warned that BOSL2 is
under development):

https://github.com/revarbat/BOSL2/wiki/skin.scad#path_sweep

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

curve = [for(x=[-2:.1:2]) [x,x*x,0]];
path_sweep(circle(r=.1, $fn=16), curve);


The result looks like this:

<http://forum.openscad.org/file/t2477/parabola.png>



--
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: Parabolic tube.

Ronaldo
In reply to this post by rew
Think of plotting a parabola like in highschool. But now I want to 3D
print that curve, so instead of the line on the paper, I want to give
it some thickness. For my current project I don't need it hollowed
out. But if we specifiy the parabola and an R, specifying the same
parabola and R- wall_thickness you can subtract that to get a tube.

module parabola (p1, p2, p3, r, x0, x1, fn )
{
  s = (x1-x0)/fn;

  for (x=[x0:s:x1-s]) {
    hull () {
      xs = x+s;
      translate ([x,p1*x*x+p2*x+p3,0]) sphere (r=r);
      translate ([xs,p1*xs*xs+p2*xs+p3,0]) sphere (r=r);
    }
  }
}

$fn = 20;

parabola (1,0,0, .3, -2, 2, 20);


As an alternative of using a library you might create a more general module to draw curves specified by a list of points. I often use the following module to draw polygonal that approximate of curves:

module line(p, t=0.02, closed=false, dots=false) {
  p = closed? concat(p, [p[0]]): p;
  if(dots)  for(pi=p) translate(pi) cube(2.5*t);
  for(i=[0:len(p)-2])
    hull() {
      translate(p[i])   sphere(t);
      translate(p[i+1]) sphere(t);
    }
  }


It is basically what you have done but not specialized for any specific curve. To draw you parabola just compute some points in it:

module parabola (p1, p2, p3, r, x0, x1, fn )
{
  s = (x1-x0)/fn;
  p = [ for (x=[x0:s:x1]) [x, p1*x*x+p2*x+p3,0] ];
  line(p, t=r);
}

$fn = 20;

parabola (1,0,0, .3, -2, 2, 20);

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

Re: Parabolic tube.

rew
In reply to this post by adrianv


I think this one takes the cake!

As to openscad... wouldn't the "path-sweep" be something that could be
considered a "core-item"?

This can be accomplished in two ways. The first would be to add a
path_sweep to the language and to implement linear extrude and
rotate-extrude as special cases of the path_sweep from now on...

On the other hand... (or maybe in any case)...

... would it be an idea to have some system scad "library" files that
come with openscad so that this path-sweep might be kept there so that
we can say that "path-sweep" is supported by openscad.  

The "in any case" situation arises when it would be chosen to
implement the path-sweep as a primitive. In that case linear_extrude
would become an easy small scad source to provide backward
compatibility and ease-of-use for a common case....

        Roger.


On Tue, Apr 14, 2020 at 03:39:14PM -0700, adrianv wrote:

> Here's another option for sweep using BOSL2 (though be warned that BOSL2 is
> under development):
>
> https://github.com/revarbat/BOSL2/wiki/skin.scad#path_sweep
>
> include<BOSL2/std.scad>
> include<BOSL2/skin.scad>
>
> curve = [for(x=[-2:.1:2]) [x,x*x,0]];
> path_sweep(circle(r=.1, $fn=16), curve);
>
>
> The result looks like this:
>
> <http://forum.openscad.org/file/t2477/parabola.png>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

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

Re: Parabolic tube.

nophead
There is already a PR for generalised extruding 2D shapes  https://github.com/openscad/openscad/pull/2796

On Thu, 16 Apr 2020 at 10:15, Rogier Wolff <[hidden email]> wrote:


I think this one takes the cake!

As to openscad... wouldn't the "path-sweep" be something that could be
considered a "core-item"?

This can be accomplished in two ways. The first would be to add a
path_sweep to the language and to implement linear extrude and
rotate-extrude as special cases of the path_sweep from now on...

On the other hand... (or maybe in any case)...

... would it be an idea to have some system scad "library" files that
come with openscad so that this path-sweep might be kept there so that
we can say that "path-sweep" is supported by openscad. 

The "in any case" situation arises when it would be chosen to
implement the path-sweep as a primitive. In that case linear_extrude
would become an easy small scad source to provide backward
compatibility and ease-of-use for a common case....

        Roger.


On Tue, Apr 14, 2020 at 03:39:14PM -0700, adrianv wrote:
> Here's another option for sweep using BOSL2 (though be warned that BOSL2 is
> under development):
>
> https://github.com/revarbat/BOSL2/wiki/skin.scad#path_sweep
>
> include<BOSL2/std.scad>
> include<BOSL2/skin.scad>
>
> curve = [for(x=[-2:.1:2]) [x,x*x,0]];
> path_sweep(circle(r=.1, $fn=16), curve);
>
>
> The result looks like this:
>
> <http://forum.openscad.org/file/t2477/parabola.png>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>

--
** [hidden email] ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

_______________________________________________
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