My apologies for not contributing fully. I believe the original intent would be to have a flat bottom, perpendicular rear and tilted only on the front wall. If I had more time, I'd provide the modified code to accomplish that, but I also think Eric's entry should provide a foundation for the solution.
// the magnet holes are substracted from the cube (rear)
// I made the cylinders 1mm higher than the variable because they have to break through the wall. so the translate moved the Y axis of the cylinder into the wall, but the cylinder is actually sticking out of the cube, but you cannot see the difference object
translate([magdistance,magheight,magdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //left
translate([width-magdistance,magheight,magdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //right
translate([width/2,magheight,magdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //middle
I think I would choose for a cube and a triangle where the triangle is made of the difference between two cubes. Some trigonometry is needed. The code could use some functions I suppose but this is just a quick example where one side is closed.
Sebastian, your post is still flagged as "This post has NOT been accepted by the mailing list yet", so nobody gets it unless they look.
You need to subscribe to the mailing list, and CLICK THE LINK in the registration email (check your spam folder).
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
The TPP is no simple “trade agreement.”Fight it! http://www.ourfairdeal.org/ time is running out!
Sebastian, sorry I didn't want to confuse you (and it was kind of late when I posted yesterday). I simplified the code by removing some redundancy and it looks less horrifying now. Start at the bottom of the code and add an exclamation mark before the last line and work your way up removing the previous exclamation mark. This gives a good idea of what’s going on. I already inserted the first exclamation mark below.
The difference() calculates the triangle. One cube is rotated over a second one resulting in a triangle. The part ‘sqrt(pow(abs(tan(angle))*height,2)+pow(height,2))’ is Pythagoras to calculate the length of the hypotenuse of the triangle that is rotated over the first.
The abs(tan(angle))*height calculates the length of the side opposite of the variable angle. The larger the angle the larger the opposite side.