Wednesday, February 26, 2014

Day 184 - Mystery pyramids

Today we made a lot of little pyramids and a box. Why? Can't tell you that right now, it's for a friend and we'll follow up later on this year with a reason.


Settings: As usual, MakerWare .3mm/low on a Replicator 2. We printed the pyramids three at a time at 80% and the box at 81% to add a little clearance that was missing in our first trial run. You could probably print more pyramids at a time but our build plate is a little warpy so we are currently trying to keep our prints small and near the center of the plate.

Technical notes: The OpenSCAD code is really simple; the only part to think about is how to find the height of a square-based pyramid with sides all of equal length. Get out your trigonometry hat: Given that the sides of the square are 30mm (based on our coordinates for those vertices in the code below), the Pythagorean theorem tells us that the diagonal of the base is 30*sqrt(2). Then the height of the pyramid is one leg of a right triangle whose other leg is length 30*sqrt(2)/2 (halfway across the diagonal) and whose hypotenuse is 30 (one of the slanted sides of the pyramid), so another application of the Pythagorean theorem gives us a height of 30/sqrt(2). Or you could just memorize that the height of an equilateral square pyramid is the side length divided by sqrt(2).

// mathgrrl packing problem

////////////////////////////////////////////////////////////////////
// renders
////////////////////////////////////////////////////////////////////

the_box();

//square_pyramid();

////////////////////////////////////////////////////////////////////
// module for square pyramid 
// from OpenSCAD manual example
// http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Primitive_Solids
////////////////////////////////////////////////////////////////////

module square_pyramid(){
polyhedron(
 points= [[15,15,0], [15,-15,0], [-15,-15,0], [-15,15,0], 
          [0,0,30/sqrt(2)] // top point
],                                 
 triangles=[ [0,1,4],[1,2,4],[2,3,4],[3,0,4], // each triangle side
             [1,0,3],[2,1,3] ] // two triangles for square base
);
}

////////////////////////////////////////////////////////////////////
// module for the box
////////////////////////////////////////////////////////////////////

module the_box(){
translate([0,0,76])
difference(){
cube([92,92,92],center=true);
translate([0,0,6]) cube([90,90,100],center=true);
}
}

3 comments:

  1. I suspected this was some kind of packing puzzle, even before seeing the comment in the OpenSCAD code ;)

    ReplyDelete
    Replies
    1. Oops, the cat is out of the bag

      Delete
    2. As long as the cat's not in the box, because then the pyramids definitely won't fit!

      Delete