Skip to content

Commit

Permalink
Minor edits to helper method calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestaylr committed Jun 10, 2015
1 parent 4483489 commit e27a69d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/modules/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def direction_to_point(current_point, target_point):
y = math.sin(d) * math.cos(b)
x = math.cos(a) * math.sin(b) - math.sin(a) * math.cos(b) * math.cos(d)

return 360 - ((math.degrees(math.atan2(y, x)) + 360) % 360)
return (math.degrees(math.atan2(y, x)) + 360) % 360

def get_heading_angle(heading, current_point, target_point):
angle = direction_to_point(current_point, target_point)
Expand All @@ -35,5 +35,13 @@ def point_proximity(current_point, target_point):

return (distance <= point_proximity_radius)

def distance(point1, point2):
a = math.sin(math.radians(point1.latitude))
b = math.sin(math.radians(point2.latitude))
c = math.cos(math.radians(point1.latitude))
d = math.cos(math.radians(point2.latitude))


e = a * b + c * d * math.cos((math.radians(point2.longitude - point1.longitude)))
f = math.acos(e)

return f * 6371 * 1000

0 comments on commit e27a69d

Please sign in to comment.