Advertisement
Guest User

Untitled

a guest
Jun 20th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. def bilateration(latA, lonA, distA, latB, lonB, distB):
  2.     """
  3.    @param latA: latitude of point 1
  4.    @type latA: C{float}
  5.    @param lonA: longitude of point 1
  6.    @type lonA: C{float}
  7.    @param distA: distance from point1 to the third point in miles
  8.    @type distA: C{int}
  9.    @param latB: latitude of point 1
  10.    @type latB: C{float}
  11.    @param lonB: longitude of point 1
  12.    @type lonB: C{float}
  13.    @param distB: distance from point2 to the third point in miles
  14.    @type distB: C{int}
  15.    """
  16.     #Converting miles to nautical miles
  17.     distA *= 0.868976
  18.     distB *= 0.868976
  19.  
  20.     xA = math.cos(lonA)*math.cos(latA)
  21.     yA = math.sin(lonA)*math.cos(latA)
  22.     zA = math.sin(latA)
  23.  
  24.     xB = math.cos(lonB)*math.cos(latB)
  25.     yB = math.sin(lonB)*math.cos(latB)
  26.     zB = math.sin(latB)
  27.  
  28.     x1 = numpy.array([xA, yA, zA])
  29.     x2 = numpy.array([xB, yB, zB])
  30.  
  31.     #Converting from nautical miles to radians
  32.     r1 = distA / 60
  33.     r2 = distB / 60
  34.  
  35.     q = numpy.dot(x2, x1)
  36.     a = (math.cos(r1) - math.cos(r2)*q) / (1 - pow(q,2))
  37.     b = (math.cos(r2) - math.cos(r1)*q) / (1 - pow(q,2))
  38.  
  39.     n = numpy.cross(x1,x2)
  40.  
  41. bilateration(37.673442, -90.234036, 123.709, 36.109997, -90.953669, 166.863)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement