Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def bilateration(latA, lonA, distA, latB, lonB, distB):
- """
- @param latA: latitude of point 1
- @type latA: C{float}
- @param lonA: longitude of point 1
- @type lonA: C{float}
- @param distA: distance from point1 to the third point in miles
- @type distA: C{int}
- @param latB: latitude of point 1
- @type latB: C{float}
- @param lonB: longitude of point 1
- @type lonB: C{float}
- @param distB: distance from point2 to the third point in miles
- @type distB: C{int}
- """
- #Converting miles to nautical miles
- distA *= 0.868976
- distB *= 0.868976
- xA = math.cos(lonA)*math.cos(latA)
- yA = math.sin(lonA)*math.cos(latA)
- zA = math.sin(latA)
- xB = math.cos(lonB)*math.cos(latB)
- yB = math.sin(lonB)*math.cos(latB)
- zB = math.sin(latB)
- x1 = numpy.array([xA, yA, zA])
- x2 = numpy.array([xB, yB, zB])
- #Converting from nautical miles to radians
- r1 = distA*math.pi/(60*180)
- r2 = distB*math.pi/(60*180)
- q = numpy.dot(x2, x1)
- a = (math.cos(r1) - math.cos(r2)*q) / (1 - pow(q,2))
- b = (math.cos(r2) - math.cos(r1)*q) / (1 - pow(q,2))
- n = numpy.cross(x1,x2)
- x0 = (a*x1 + b*x2)
- t = math.sqrt((1 - numpy.dot(x0, x0))/numpy.dot(n, n))
- coords1 = x0 + t*n
- coords2 = x0 - t*n
- x1 = coords1[0]
- y1 = coords1[1]
- z1 = coords1[2]
- x2 = coords2[0]
- y2 = coords2[1]
- z2 = coords2[2]
- lon1 = math.atan(x1,y1)
- lat1 = math.atan(math.sqrt[pow(x1,2)+pow(y1,2)], z1)
- lon2 = math.atan(x2,y2)
- lat2 = math.atan(math.sqrt[pow(x2,2)+pow(y2,2)], z2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement