-
Notifications
You must be signed in to change notification settings - Fork 0
/
areacalc.py
88 lines (86 loc) · 2.11 KB
/
areacalc.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
coords =[[120.000000,0.000001]
,[119.586000,0.190800]
,[118.447200,0.780000]
,[116.764800,1.720800]
,[114.636000,2.857200]
,[112.029600,4.051200]
,[108.880800,5.280000]
,[105.205200,6.577200]
,[101.065200,7.944000]
,[96.523200,9.363600]
,[91.647600,10.812000]
,[86.508000,12.258000]
,[81.172800,13.669200]
,[75.710400,15.007200]
,[70.189200,16.228800]
,[64.671600,17.292000]
,[59.216400,18.139200]
,[53.844000,18.711600]
,[48.556800,18.993600]
,[43.378800,18.988800]
,[38.336400,18.708000]
,[33.462000,18.165600]
,[28.784400,17.382000]
,[24.343200,16.388400]
,[20.179200,15.211200]
,[16.333200,13.874400]
,[12.840000,12.404400]
,[9.727200,10.827600]
,[7.022400,9.175200]
,[4.743600,7.478400]
,[2.905200,5.774400]
,[1.514400,4.102800]
,[0.577200,2.511600]
,[0.085200,1.054800]
,[0.002400,0.105600]
,[0.039600,-0.230400]
,[0.085200,-0.434400]
,[0.150000,-0.621600]
,[0.188400,-0.708000]
,[0.232800,-0.787200]
,[0.284400,-0.860400]
,[0.345600,-0.925200]
,[0.417600,-0.987600]
,[0.498000,-1.048800]
,[0.685200,-1.162800]
,[0.901200,-1.268400]
,[1.278000,-1.412400]
,[1.638000,-1.519200]
,[3.470400,-1.782000]
,[5.936400,-1.778400]
,[9.039600,-1.483200]
,[12.804000,-0.888000]
,[17.262000,-0.002400]
,[22.472400,1.106400]
,[28.425600,2.295600]
,[35.035200,3.438000]
,[42.195600,4.424400]
,[49.738800,5.139600]
,[57.440400,5.551200]
,[65.130000,5.712000]
,[72.694800,5.658000]
,[80.028000,5.401200]
,[87.003600,4.951200]
,[93.494400,4.350000]
,[99.403200,3.660000]
,[104.662800,2.932800]
,[109.214400,2.212800]
,[113.014800,1.543200]
,[116.030400,0.952800]
,[118.222800,0.468000]
,[119.554800,0.127200]
,[120.000000,0.000000]]
areas = []
try:
for i in range(int(len(coords))):
base = abs(coords[i][0] - coords[i+1][0])
heightDifference = abs(coords[i][1] - coords[i+1][1])
if coords[i][1] < coords[i+1][1]:
rectHeight = coords[i][1]
else:
rectHeight = coords[i+1][1]
totalArea = (base*rectHeight)+(0.5*base*heightDifference)
areas.append(abs(totalArea))
except IndexError:
pass
print(sum(areas))