-
Notifications
You must be signed in to change notification settings - Fork 0
/
wedges.scad
70 lines (55 loc) · 2.04 KB
/
wedges.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$fn=100;
//Create a prism based on a right angled triangle rotated to form a wedge.
//There is a raised_edge version which puts a small base underneath
//x - x-dimension length
//y - y-dimension length
//h - height of wedge
//b - height of rectangular base in raised version
//center=true or false (false is default)
//based on https://github.com/dannystaple/OpenSCAD-Parts-Library/blob/master/prism.scad
module wedge(x, y, h, center=false) {
if (center) {
polyhedron(points=[
[0,-y/2,h], // 0 front top corner
[0,-y/2,0],[x,-y/2,0], // 1, 2 front left & right bottom corners
[0,y/2,h], // 3 back top corner
[0,y/2,0],[x,y/2,0] // 4, 5 back left & right bottom corners
], faces=[ // points for all faces must be ordered clockwise when looking in
[0,2,1], // top face
[3,4,5], // base face
[0,1,4,3], // h face
[1,2,5,4], // w face
[0,3,5,2], // hypotenuse face
]);
}
else
{
polyhedron(points=[
[0,0,h], // 0 front top corner
[0,0,0],[x,0,0], // 1, 2 front left & right bottom corners
[0,y,h], // 3 back top corner
[0,y,0],[x,y,0] // 4, 5 back left & right bottom corners
], faces=[ // points for all faces must be ordered clockwise when looking in
[0,2,1], // top face
[3,4,5], // base face
[0,1,4,3], // h face
[1,2,5,4], // w face
[0,3,5,2], // hypotenuse face
]);
}
}
module raised_wedge(x,y,h,b,center=false){
if (center) {
translate([0,-y/2,0])
cube([x,y,b]);
}
else {
cube([x,y,b]);
}
translate([0,0,b])
wedge(x,y,h,center=center);
}
// Example usage
//wedge(5,3,2);
//wedge(5, 3, 2,center=true);
//raised_wedge(5,3,2,1,center=false);