-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProjectileLocation.py
executable file
·116 lines (89 loc) · 3.21 KB
/
ProjectileLocation.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""
The ProjectileLocation translates the the location of a projectile in Latitude and Longitude into a coordinate system.
This class should be run in tandem with the ProjectileDrop file.
@author: rishthak
"""
import math
"""
The point class specifies a point in three dimensions
@param xComp The X Component running laterally to the ground
@param xComp The Y Component perpendicular to the ground. The ground is presumed to be 0
@param xComp The Z Component longitudinal to the ground
"""
class point:
def __init__(self, xComp: float, yComp: float, zComp: float):
self.x = xComp
self.y = yComp
self.z = zComp
def __str__(self):
return ("X: " + str(self.x) + " Y: " + str(self.y) + " Z: " + str(self.z))
def getX(self):
return self.x
def getY(self):
return self.y
def getZ(self):
return self.z
def setX(self, newX: float):
self.x = newX
def setY(self, newY: float):
self.y = newY
def setZ(self, newZ: float):
self.z = newZ
"""
The vector class specifies a vector in three dimensions
@param xComp The X Component running laterally to the ground
@param yComp The Y Component longitudinal to the ground
@param ZComp The Z Component perpendicular to the ground. The ground is presumed to be 0. I.E height
"""
class vector:
def __init__(self, xComp: float, yComp: float, zComp: float):
self.x = xComp
self.y = yComp
self.z = zComp
def getX(self):
return self.x
def getY(self):
return self.y
def getZ(self):
return self.z
"""
The pointLatLon class specifies a vector in three dimensions
@param Latitude The latitude
@param Longitude The longitdue
@param Altitude The altitude
"""
class pointLatLon:
def __init__(self, Latitude: float, Longitude: float, Altitude: float):
self.lat = Latitude
self.lon = Longitude
self.alt = Altitude
def getLat(self):
return self.lat
def getLon(self):
return self.lon
def getAlt(self):
return self.alt
"""
The alignToOriginTool can be used to translate a pointLatLon to a point at a specified origin
@param observationPoint The pointLatLon defined as the observation location
@param originPoint The pointLatLon defined as the origin
"""
class alignToOriginTool:
def __init__(self, observationPoint: pointLatLon, originPoint: pointLatLon):
self.obsPoint = observationPoint
self.orgPoint = originPoint
self.rEarth = 6378137 #equatorial raidus Earth
def alignToOrigin(self, observationPoint: pointLatLon):
self.obsPoint = observationPoint
x = math.cos(self.obsPoint.getLat())*math.sin((self.obsPoint.getLon()-self.orgPoint.getLon())/2)
x = math.asin(x)
x = 2*self.rEarth*x
y =self.rEarth*(self.obsPoint.getLat() - self.orgPoint.getLat())
z = self.obsPoint.getAlt()
cartesPoint = point(x,y,z)
print("cartesian Point: " + str(cartesPoint))
return cartesPoint
def updateObsvPoint(self, observationPoint: pointLatLon):
self.obsPoint = observationPoint
def updateOrigin(self, originPoint: pointLatLon):
self.orgPoint = originPoint