-
Notifications
You must be signed in to change notification settings - Fork 1
/
Geography: Estimate Areas
87 lines (70 loc) · 3.39 KB
/
Geography: Estimate Areas
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
# -*- coding: utf-8 -*-
"""
Larry McQuaid
MET CS 521
9/15/18
Homework 2, Question 3.3
Geography: estimate areas
"""
import math
atlanta_latitude = 33.7489954
atlanta_longitude = -84.3879824
orlando_latitude = 28.5383355
orlando_longitude = -81.37923649999999
savannah_latitude = 32.0808989
savannah_longitude = -81.09120300000001
charlotte_latitude = 35.2270869
charlotte_longitude = -80.84312669999997
atlanta_to_orlando = 6371.01 * (math.acos(
(math.sin(math.radians(atlanta_latitude)))
* (math.sin(math.radians(orlando_latitude)))
+ (math.cos(math.radians(atlanta_latitude)))
* (math.cos(math.radians(orlando_latitude)))
* (math.cos(math.radians(atlanta_longitude - orlando_longitude)))))
orlando_to_savannah = 6371.01 * (math.acos(
(math.sin(math.radians(orlando_latitude)))
* (math.sin(math.radians(savannah_latitude)))
+ (math.cos(math.radians(orlando_latitude)))
* (math.cos(math.radians(savannah_latitude)))
* (math.cos(math.radians(orlando_longitude - savannah_longitude)))))
savannah_to_atlanta = 6371.01 * (math.acos(
(math.sin(math.radians(savannah_latitude)))
* (math.sin(math.radians(atlanta_latitude)))
+ (math.cos(math.radians(savannah_latitude)))
* (math.cos(math.radians(atlanta_latitude)))
* (math.cos(math.radians(savannah_longitude - atlanta_longitude)))))
atlanta_to_charlotte = 6371.01 * (math.acos(
(math.sin(math.radians(atlanta_latitude)))
* (math.sin(math.radians(charlotte_latitude)))
+ (math.cos(math.radians(atlanta_latitude)))
* (math.cos(math.radians(charlotte_latitude)))
* (math.cos(math.radians(atlanta_longitude - charlotte_longitude)))))
charlotte_to_savannah = 6371.01 * (math.acos(
(math.sin(math.radians(charlotte_latitude)))
* (math.sin(math.radians(savannah_latitude)))
+ (math.cos(math.radians(charlotte_latitude)))
* (math.cos(math.radians(savannah_latitude)))
* (math.cos(math.radians(charlotte_longitude - savannah_longitude)))))
triangle_1_side_length = ((atlanta_to_orlando
+ orlando_to_savannah
+ savannah_to_atlanta)/2)
triangle_1_area = (math.sqrt((triangle_1_side_length
* (triangle_1_side_length
- atlanta_to_orlando)
* (triangle_1_side_length
- orlando_to_savannah)
* (triangle_1_side_length
- savannah_to_atlanta))))
triangle_2_side_length = ((atlanta_to_charlotte
+ charlotte_to_savannah
+ savannah_to_atlanta)/2)
triangle_2_area = (math.sqrt((triangle_2_side_length
* (triangle_2_side_length
- atlanta_to_charlotte)
* (triangle_2_side_length
- charlotte_to_savannah)
* (triangle_2_side_length
- savannah_to_atlanta))))
total_area_estimate = triangle_1_area + triangle_2_area
print('The estimated area enclosed by these four cities is {} km'\
.format(total_area_estimate))