

This post has NOT been accepted by the mailing list yet.
hi there,
my very first own design will be a envelope holder.
i want the front wall to be tilted in an adjustable angle. however I dont seem to understand the rotate function
can anyone help me?
$fn=30;
//rear wall
height=100;
width=130;
wall_thickness=6;
bottom_width=50;
//rear wall
cube([width,wall_thickness,height]);
//bottom wall
translate([0,wall_thickness1,0]) cube([width,bottom_width,wall_thickness]);
//front wall
frontwall_y=wall_thickness+bottom_width1;
translate([0,frontwall_y,0]) rotate([0,0,0]) cube([width,wall_thickness,height]);


Does this help?
$fn=30;
//rear wall
height=100;
width=130;
wall_thickness=6;
bottom_width=50;
angle=30;
module holder() {
//rear wall
cube([width,wall_thickness,height]);
//bottom wall
translate([0,wall_thickness1,0]) cube([width,bottom_width,wall_thickness]);
//front wall
frontwall_y=wall_thickness+bottom_width1;
translate([0,frontwall_y,0]) rotate([0,0,0]) cube([width,wall_thickness,height]);
}
rotate([angle,0,0])
translate([width/2,0,0])
translate([0,(bottom_width/2+wall_thickness),0])
holder();


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.


I should have read that post better. A second try.
width=160;
height=100;
thickness=6;
bottom=50;
angle=15;
cube([width,thickness,height]);
cube([width,bottom+thickness,thickness]);
translate([0,bottom,sin(angle)*thickness]) rotate([angle,0,0]) cube([width,thickness,height]);
The sine(angle)*thickness is for the front wall not going 'through' the bottom.


This post has NOT been accepted by the mailing list yet.
Excellent, thanks. Its still a bit hard to go from 2d to 3d programming. So learning by doing.
Thanks so much.
if I wanted to close the sides, i need to make a polygon right? is there a function to do that  or do i need to make a large cube and substract from that?


This post has NOT been accepted by the mailing list yet.
btw. here is the work in progress. now only need some help for the sides ;)
//object
width=130;
height=100;
thickness=6;
bottom=50;
//front wall
angle=15;
//magnets
magdiameter=8;
magheight=5.1; // please add 0.1mm or something in order to add some glue behinde the object
magdistance=magdiameter*1.8; //distance from wall edge
//rear
difference() {
cube([width,thickness,height]);
// 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([widthmagdistance,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
translate([magdistance,magheight,heightmagdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //left
translate([widthmagdistance,magheight,heightmagdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //right
translate([width/2,magheight,heightmagdistance]) rotate([90,0,0]) cylinder(magheight+1,magdiameter,magdiameter, $fn=100); //middle
}
//bottom
cube([width,bottom+thickness,thickness]);
//angled front wall
//The sine(angle)*thickness is for the front wall not going 'through' the bottom.
translate([0,bottom,sin(angle)*thickness]) rotate([angle,0,0]) cube([width,thickness,height]);


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.
width=160;
height=100;
thickness=6;
bottom=50;
angle=15;
cube([width,thickness,height]);
cube([width,bottom+thickness,thickness]);
translate([0,bottom,sin(angle)*thickness]) rotate([angle,0,0]) cube([width,thickness,height]);
cube([thickness,bottom+thickness,height]);
translate([thickness,bottom+thickness,0])
rotate([0,90,0])
difference() {
cube([height,abs(tan(angle))*height,thickness]);
rotate([0,0,atan(abs(tan(angle))*height/height)]) cube([sqrt(pow(abs(tan(angle))*height,2)+pow(height,2)),abs(tan(angle))*height,thickness]);
}

Administrator

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  email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.
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,
You may think in 2D for most part of your job and use linear_extrude to jump into the 3D world. Here is my approach that starts from the sides:
// the 2D profile of a side
module side_profile(w, h, b){
tg = (wb)/h; // trig math
a = atan2(wb,h);
cs = cos(a);
difference(){
square([w, h]);
translate([b,0])
rotate(a)
square([h*tg*cs,h/cs]);
}
}
// the 2D profile of the walls
module wall_profile(w, h, b, t) {
difference(){
side_profile(w, h, b);
translate([t,t]) side_profile(w2*t, h, b2*t);
}
}
module holder(w,h,b,t,l)
rotate([90,0,0]) {
// channel walls
translate([0,0,t])
linear_extrude(height=l2*t)
wall_profile(w, h, b, t);
// sides
color("blue")
linear_extrude(height=t)
side_profile(w, h, b);
color("red")
translate([0,0,lt])
linear_extrude(height=t)
side_profile(w, h, b);
}
width = 40;
height = 40;
bottom = 20;
thickness = 3;
length = 60;
holder(width,height,bottom,thickness,length);


MichaelAtOz: Thanks for pointing this out. I now subscribed


thanks for that  and it got me completely confused. LOL


Eric, there are alot of trigonometrical functions in there that i havent seen since I left school 20 years ago. And to cascade them even confuses me more. LOL. I need to do some studying now :(


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.
width=160;
height=100;
thickness=6;
bottom=50;
angle=20;
cube([width,thickness,height]);
cube([width,bottom+thickness,thickness]);
translate([0,bottom,sin(angle)*thickness]) rotate([angle,0,0]) cube([width,thickness,height]);
cube([thickness,bottom+thickness,height]);
translate([thickness,bottom+thickness,0])
rotate([0,90,0])
difference() {
cube([height,abs(tan(angle))*height,thickness]);
!rotate([0,0,abs(angle)]) cube([sqrt(pow(abs(tan(angle))*height,2)+pow(height,2)),abs(tan(angle))*height,thickness]);
}
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.
I hope this help.

