Curved linear extrude

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

Curved linear extrude

alexgibson

Hi all,

 

I am modelling a top hat, and would be grateful for suggestions as to the most efficient way to extrude the basic oval shape of the hat over an arc.

 

I am most of the way there with the basic shape with this:

 

linear_extrude(height = 153, center = true, convexity = 10, scale=1.19875)

scale([1,1.19255])

                                circle(161/2);

 

The change I need to make is that the scale factor of the linear_extrude needs to increase from bottom to top, so it widens out over a curve – and the top of the hat flares out a little.

 

I’ve done a lot of modelling in OpenSCAD but not played much with mathematical functions, so any pointers would be appreciated.  I’d like to take this further, to also twisting the top of the hat, based on what I learn from this.

 

Many thanks,

Alex


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

Re: Curved linear extrude

Parkinbot
Have a look at this code. It uses an exponential funktion.

pf = 1.004;  

for (i=[0:153])
hull()
{
  translate([0, 0, i])
  scale(pow(pf, i)*[1,1.19255])
    cylinder(r=161/2, h = .01);
   translate([0, 0, i+1])
 scale(pow(pf, i+1)*[1,1.19255])
    cylinder(r=161/2, h = .01);
}
in a more general formulation you would write your own function f to describe the trajectory. E.g.

step = 10;
for (i=[0:step:153])
hull()
{
  translate([0, 0, i])
    scale(f(i)*[1,1.19255])
      cylinder(r=161/2, h = .01);
  translate([0, 0, i+step])
    scale(f(i+step)*[1,1.19255])
      cylinder(r=161/2, h = .01);
}

function f(i) = 1+ pow(i/200,2);

Reply | Threaded
Open this post in threaded view
|

Re: Curved linear extrude

Neon22
In reply to this post by alexgibson
Also consider approach where you draw the profile and build a volume of revolution
Check this code for example to make handles:
- http://www.thingiverse.com/thing:923244
(tricky to ensure they meet perfectly in the mifddle)

Use inkscape to draw the profile:
- http://www.thingiverse.com/thing:1065500

Reply | Threaded
Open this post in threaded view
|

Re: Curved linear extrude

Ronaldo
In reply to this post by alexgibson
I would use another approach. For curved surfaces I generally prefer to build the form from meshes of calculated points and compose everything with polyhedron. Here is a possible code:
n   = 22;       // oval points
h   = 153;      // form height
f   = 1.19255;  // oval factor
rad = 161/2;
// a simple oval shape in the xy plane
oval    = [ for(ang=[0:360/n:361]) [rad*cos(ang), rad*f*sin(ang), 0] ];
// a profile to be taken as a scale factor: change the function to your taste
a = 0.1;   b = 5;   c = 3;   m = 10;
profiler = [ for(i=[0:m]) 1+a*pow((i/b),c) ];
// a rectangular mesh of points around the form
surface = [ for(i=[0:m]) [for(p=oval) profiler[i]*p+[0,0,h*i/m] ] ];

show_closed_mesh(surface);
//translate([2*rad,0,0]) cube(100); // just to confirm that CGAL consider it a manyfold

// generates a solid for a closed mesh adding two faces to close the top and bottom
module show_closed_mesh(mesh) {
    function mesh_faces(mesh) =  let( n = len(mesh), m = len(mesh[0]) )
        concat( [ for(i=[0:n-2]) for(j=[0:m-2])
                   [ i*m+j+1, i*m+j  , (i+1)*m+j ] ] ,
                [ for(i=[0:n-2]) for(j=[0:m-2])
                   [ (i+1)*m+j, (i+1)*m+j+1, i*m+j+1 ] ]
              ) ;

    // process mesh
    mesh_vertices = [ for(line=mesh) for(pt=line) pt ];
    mesh_faces    = mesh_faces(mesh);
    mv            = len(mesh_vertices);
    mvlen         = mv + len(mesh[0]);
    mv2len        = mvlen + len(mesh[0]);
    // process faces
    face_vertices = concat(mesh[0], mesh[len(mesh)-1]) ;
    face_polygons = [ [for(i=[mv:mvlen-1]) i ],
                      [for(i=[mv2len-1:-1:mvlen]) i ] ];
    polyhedron(
        points = concat(mesh_vertices, face_vertices),
        faces  = concat(mesh_faces,    face_polygons),
        convexity = 10
    );
}

The form is based on an elliptic oval and a scale profile. A mesh is built from them.
The show_closed_mesh module is a very simple version of a more general version I coded. It takes only one envelope in the form of a (closed) mesh and closes it with two planar faces. If needed this two faces may be triangulated.
Reply | Threaded
Open this post in threaded view
|

Re: Curved linear extrude

alexgibson
In reply to this post by Parkinbot
Yes - this is exactly it, thanks very much.  I will play about with it until
I can properly use all aspects.

Many thanks!

-----Original Message-----
From: Discuss [mailto:[hidden email]] On Behalf Of
Parkinbot
Sent: 24 May 2016 00:04
To: [hidden email]
Subject: Re: [OpenSCAD] Curved linear extrude

Have a look at this code. It uses an exponential funktion.


> pf = 1.004;
>
> for (i=[0:153])
> hull()
> {
>   translate([0, 0, i])
>   scale(pow(pf, i)*[1,1.19255])
>     cylinder(r=161/2, h = .01);
>    translate([0, 0, i+1])
>  scale(pow(pf, i+1)*[1,1.19255])
>     cylinder(r=161/2, h = .01);
> }

in a more general formulation you would write your own function f to
describe the trajectory. E.g.


> step = 10;
> for (i=[0:step:153])
> hull()
> {
>   translate([0, 0, i])
>     scale(f(i)*[1,1.19255])
>       cylinder(r=161/2, h = .01);
>   translate([0, 0, i+step])
>     scale(f(i+step)*[1,1.19255])
>       cylinder(r=161/2, h = .01);
> }
>
> function f(i) = 1+ pow(i/200,2);

<http://forum.openscad.org/file/n17409/hat.png>




--
View this message in context:
http://forum.openscad.org/Curved-linear-extrude-tp17407p17409.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6201 / Virus Database: 4568/12284 - Release Date: 05/23/16


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

Re: Curved linear extrude

alexgibson
In reply to this post by Neon22
Thanks Neon22 this is also a very useful approach.  

-----Original Message-----
From: Discuss [mailto:[hidden email]] On Behalf Of
Neon22
Sent: 24 May 2016 00:18
To: [hidden email]
Subject: Re: [OpenSCAD] Curved linear extrude

Also consider approach where you draw the profile and build a volume of
revolution Check this code for example to make handles:
- http://www.thingiverse.com/thing:923244
(tricky to ensure they meet perfectly in the mifddle)

Use inkscape to draw the profile:
- http://www.thingiverse.com/thing:1065500





--
View this message in context:
http://forum.openscad.org/Curved-linear-extrude-tp17407p17410.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.6201 / Virus Database: 4568/12284 - Release Date: 05/23/16


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org