-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyramid_four.py
More file actions
executable file
·73 lines (72 loc) · 2.61 KB
/
pyramid_four.py
File metadata and controls
executable file
·73 lines (72 loc) · 2.61 KB
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
71
72
73
__author__ = 'tobias'
import math as m
import turtle as t
import rotation_matrix_3D as rm3D
def pyramid():
print("\n\n****************************************************************************\n\n")
#requesting the variables
edge_a = float(input("edge a [mm] : "))
edge_b = float(input("edge b [mm] : "))
height = float(input("height h [mm] : "))
Volume = float(input("volume [mm^3] : "))
alpha_grad = float(input("angle alpha [°] : "))
beta_grad = float(input("angle beta [°] : "))
gamma_grad = float(input("angle gamma [°] : "))
print("\n\n****************************************************************************\n\n")
#calculation
if Volume == 0:
W = (edge_a*edge_b*height)/6
print("Ergebnis: volume = %.5f" % W, "[mm^3]")
print("\n\n****************************************************************************\n\n")
elif edge_a == 0:
d = (3*Volume)/edge_b/height
print("Ergebnis: edge a = %.20f" % d, "[mm]")
print("\n\n****************************************************************************\n\n")
edge_a = d
elif edge_b == 0:
e = (3*Volume)/edge_a/height
print("Ergebnis: edge b = %.20f" % e, "[mm]")
print("\n\n****************************************************************************\n\n")
edge_b = e
elif height == 0:
f = (3*Volume)/edge_a/edge_b
print("Ergebnis: height h = %.20f" % f, "[mm]")
print("\n\n****************************************************************************\n\n")
height = f
else:
print(":-(")
print("\n\n****************************************************************************\n\n")
#transform from degree to radiant
alpha = m.radians(alpha_grad)
beta = m.radians(beta_grad)
gamma = m.radians(gamma_grad)
#define the points
Ap = [0, 0, 0]
Bp = [edge_b, 0, 0]
Cp = [edge_b, 0, -edge_a]
Dp = [0, 0, -edge_a]
Ep = [edge_b/2, height, -edge_a/2]
corner_points = [Ap, Bp, Cp, Dp, Ep]
#rotate the points
corner_points3 = rm3D.rotation_matrix_3D(alpha, beta, gamma, corner_points)
#draw the pyramid
window = t.Screen()
t.ht()
t.speed(2)
for pointk1 in corner_points3[1:4]:
t.goto(pointk1[0:2])
t.goto(corner_points3[0][0:2])
t.goto(corner_points3[4][0:2])
t.pu()
t.goto(corner_points3[1][0:2])
t.pd()
t.goto(corner_points3[4][0:2])
t.pu()
t.goto(corner_points3[2][0:2])
t.pd()
t.goto(corner_points3[4][0:2])
t.pu()
t.goto(corner_points3[3][0:2])
t.pd()
t.goto(corner_points3[4][0:2])
window.exitonclick()