discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] tilt a wall

R
Ronaldo
Wed, Jun 21, 2017 12:33 AM

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 = (w-b)/h; // trig math
a  = atan2(w-b,h);
cs = cos(a);
difference(){
square([w, h]);
translate([b,0])
rotate(-a)
square([htgcs,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(w-2t, h, b-2t);
}
}

module holder(w,h,b,t,l)
rotate([90,0,0]) {
// channel walls
translate([0,0,t])
linear_extrude(height=l-2*t)
wall_profile(w, h, b, t);
// sides
color("blue")
linear_extrude(height=t)
side_profile(w, h, b);
color("red")
translate([0,0,l-t])
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);

--
View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21733.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

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 = (w-b)/h; // trig math > a = atan2(w-b,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(w-2*t, h, b-2*t); > } > } > > module holder(w,h,b,t,l) > rotate([90,0,0]) { > // channel walls > translate([0,0,t]) > linear_extrude(height=l-2*t) > wall_profile(w, h, b, t); > // sides > color("blue") > linear_extrude(height=t) > side_profile(w, h, b); > color("red") > translate([0,0,l-t]) > 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); -- View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21733.html Sent from the OpenSCAD mailing list archive at Nabble.com.
SH
Sebastian Heyn
Wed, Jun 21, 2017 7:08 AM

thanks for that - and it got me completely confused. LOL

--
View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21735.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

thanks for that - and it got me completely confused. LOL -- View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21735.html Sent from the OpenSCAD mailing list archive at Nabble.com.