-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriangles.scad
67 lines (56 loc) · 1.84 KB
/
triangles.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
/**
Makes a right triangle with the desired side lengths and thickness (z)
**** Deprecated
*/
module rightTriangle(horizontalLength, verticalLength, thickness) {
hull() {
cube([horizontalLength, thickness, 0.01]);
cube([0.01, thickness, verticalLength]);
}
}
module rightTriangle3d(a = 10, b = 10, length = 5) {
echo("***** RightTriangle3d *****");
echo("Length: ", length);
translate([0, length, 0]) rotate([90, 0, 0]) linear_extrude(length) rightTriangle2d(a = a, b = b);
}
module rightTriangle2d(a = 10, b = 20) {
echo("***** RightTriangle2d *****");
points = [[0, 0], [a, 0], [0, b]];
echo(str("Points: ", points, ", a: ", a, ", b: ", b, ", c (calculated): ", c(a, b)));
polygon(points = points);
}
module objectAtEquilateralPoints(baseLength = 10) {
points = equilateralTrianglePoints(baseLength);
for (point = points) {
translate(point) children();
}
}
module equilateralTriangle2d(baseLength = 10) {
height = baseLength * sqrt(3) / 2;
points = [
[0, 0],
[baseLength, 0],
[baseLength / 2, height]
];
// Create the polygon (equilateral triangle) using the points
polygon(points);
}
function equilateralTrianglePoints(baseLength = 10) = [
[0, 0],
[baseLength, 0],
[baseLength / 2, baseLength * sqrt(3) / 2]
];
// ======================== Functions ================
//Calculates the hyponetuse of a right triangle given the two sides a and b
function c(a, b) = sqrt(pow(a, 2) + pow(b, 2));
//Equilateral Triangle
//size = 10;
//points = [[0, 0], [size, 0], [size / 2, size]];
//rightTriangle2d(a = 10, b = 10);
//rightTriangle3d(a = 10, b = 10, length = 20);
//equilateralTriangle2d(20);
//echo(equilateralTrianglePoints(20));
//$fn = 100;
//hull() objectAtEquilateralPoints(13.5) {
// circle(1);
//}