def isantipode_(phi1, lam1, phi2, lam2, eps=EPS): '''Check whether two points are antipodal, on diametrically opposite sides of the earth. @arg phi1: Latitude of one point (C{radians}). @arg lam1: Longitude of one point (C{radians}). @arg phi2: Latitude of the other point (C{radians}). @arg lam2: Longitude of the other point (C{radians}). @kwarg eps: Tolerance for near-equality (C{radians}). @return: C{True} if points are antipodal within the B{C{eps}} tolerance, C{False} otherwise. @see: U{Geosphere<https://CRAN.R-Project.org/web/packages/geosphere/geosphere.pdf>}. ''' return abs(wrapPI_2(phi1) + wrapPI_2(phi2)) < eps and \ abs(abs(wrapPI(lam1) - wrapPI(lam2)) % PI2 - PI) < eps
def antipode_(phi, lam): '''Return the antipode, the point diametrically opposite to a given point in C{radians}. @arg phi: Latitude (C{radians}). @arg lam: Longitude (C{radians}). @return: A L{PhiLam2Tuple}C{(phi, lam)}. @see: U{Geosphere<https://CRAN.R-Project.org/web/packages/geosphere/geosphere.pdf>}. ''' return PhiLam2Tuple(-wrapPI_2(phi), wrapPI(lam + PI))
def _rhumb3(self, other): '''(INTERNAL) Rhumb_ helper function. @param other: The other point (spherical C{LatLon}). ''' self.others(other) a1, b1 = self.to2ab() a2, b2 = other.to2ab() # if |db| > 180 take shorter rhumb # line across the anti-meridian db = wrapPI(b2 - b1) dp = log(tanPI_2_2(a2) / tanPI_2_2(a1)) return (a2 - a1), db, dp
def _xb(a1, b1, end, a, b, wrap): # difference between the bearing to (a, b) and the given # bearing is negative if both are in opposite directions r = bearing_(a1, b1, radians(a), radians(b), wrap=wrap) return PI_2 - abs(wrapPI(r - radians(end)))