In mathematics, the convex hull of X is the smallest convex polygon that contains all the points of X. Imagine the points of X as being pegs; the convex hull of X is the shape of a rubber band stretched around the pegs.
  

A polygon is said to be convex if:
  1. it is non-intersecting; and
  2. for any two points p and q on the boundary of the polygon, segment pq lies entirely inside polygon


The algorithmic problem of finding the convex hull of a finite set of points in the plane or in low-dimensional Euclidean spaces is one of the fundamental problems of computational geometry. Basically, the algorithm needs to eliminate all the interior points and focus on the perimeter.


  1. If you do not have OpenSCAD installed, download the application from openscad.org. You'll also need the latest version of OpenSCAD, as previous versions did not support hull() on 3D objects. So now might be the time to update your version of OpenSCAD.


  2. So how does hull() help you in OpenSCAD?

    The polygon function is difficult to use in OpenSCAD

    Here is a simple polygon.
    To create a polygon( points=[[0,0],[10,0],[5,10]] );
    
    Here is the same polygon, but using hull()
    hull(){
        cube([.0001,.0001,1],center=true);
        translate([10,0,0])
        cube([.0001,.0001,1],center=true);
        translate([5,10,0])
        cube([.0001,.0001,1],center=true);
    }
    





  3. To create a flat triangle:
    hull(){
        cube([.0001,.0001,.0001],center=true);
        translate([10,0,0])
        cube([.0001,.0001,.0001],center=true);
        translate([5,0,10])
        cube([.0001,.0001,.0001],center=true);
    }
      


  4. hull() works with both 2D and 3D shapes:
    hull(){
        circle(r=10);
        translate([0,20,0])circle(r=20);
        translate([0,50,0]) circle(r=10);
    }
      
    $fn=64;
    hull(){
        sphere(r=10);
        translate([0,20,0])sphere(r=20);
        translate([0,50,0]) sphere(r=10);
    }
      



  5. You can use rotate_extrude() with hull() and 2D shapes:
    rotate_extrude($fn=100)
    hull(){
        circle(r=10);
        translate([0,20,0])circle(r=20);
        translate([0,50,0]) circle(r=10);
    }


  6. You can use linear_extrude() with hull() and 2D shapes:
    linear_extrude(height=12)
    hull(){
        circle(r=10);
        translate([0,20,0])circle(r=25);
        translate([0,40,0]) circle(r=20);
    }



  7. You can use difference() with hull():
    thing(6);
    
    module thing(s=4){
    
        difference(){
            hull(){
                sphere(r=s);
                translate([0,s*5,0])sphere(r=s*6);
                translate([0,s*10,0]) sphere(r=s*5);
            }
            translate([0,-s,0])
            hull(){
                sphere(r=s*2);
                translate([0,s*5,0])sphere(r=s*5);
            }
        }
        translate([0,s*3,0])
        sphere(r=s*4);
    }
    



  8. Make an interesting organic shape that uses 2D and or 3D shapes and hull()