discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] tilt a wall

EB
Eric Buijs
Tue, Jun 20, 2017 10:37 PM

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]);
}

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

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]); } -- View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21731.html Sent from the OpenSCAD mailing list archive at Nabble.com.
SH
Sebastian Heyn
Wed, Jun 21, 2017 7:09 AM

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 :-(

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

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 :-( -- View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21736.html Sent from the OpenSCAD mailing list archive at Nabble.com.
EB
Eric Buijs
Wed, Jun 21, 2017 8:55 AM

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.

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

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. -- View this message in context: http://forum.openscad.org/tilt-a-wall-tp21725p21737.html Sent from the OpenSCAD mailing list archive at Nabble.com.