コード例 #1
0
    def destination(self, distance, bearing, radius=R_M, height=None):
        '''Locate the destination from this point after having
           travelled the given distance on the given bearing.

           @param distance: Distance travelled (same units radius).
           @param bearing: Bearing from this point (compass degrees).
           @keyword radius: Optional, mean earth radius (meter).
           @keyword height: Optional height at destination, overriding
                            the default height (meter).

           @return: Destination point (L{LatLon}).

           @raise Valuerror: Polar coincidence.

           @example:

           >>> p = LatLon(51.4778, -0.0015)
           >>> q = p.destination(7794, 300.7)
           >>> q.toStr()  # 51.513546°N, 000.098345°W

           @JSname: I{destinationPoint}.
        '''
        p = self.toNvector()

        e = NorthPole.cross(p, raiser='pole').unit()  # east vector at p
        n = p.cross(e)  # north vector at p

        t = radians(bearing)
        q = n.times(cos(t)).plus(e.times(sin(t)))  # direction vector @ p

        r = float(distance) / float(radius)  # angular distance in radians
        n = p.times(cos(r)).plus(q.times(sin(r)))
        return n.toLatLon(
            height=height,
            LatLon=self.classof)  # Nvector(n.x, n.y, n.z).toLatLon(...)
コード例 #2
0
    def greatCircle(self, bearing):
        '''Compute the n-vector normal to great circle obtained by
           heading on given compass bearing from this point as its
           n-vector.

           Direction of vector is such that initial bearing vector
           b = c × p.

           @param bearing: Initial compass bearing (C{degrees}).

           @return: N-vector representing great circle (L{Nvector}).

           @raise Valuerror: Polar coincidence.

           @example:

           >>> n = LatLon(53.3206, -1.7297).toNvector()
           >>> gc = n.greatCircle(96.0)  # [-0.794, 0.129, 0.594]
        '''
        s, c = sincos2d(bearing)

        e = NorthPole.cross(self, raiser='pole')  # easting
        n = self.cross(e, raiser='point')  # northing

        e = e.times(c / e.length)
        n = n.times(s / n.length)
        return n.minus(e)
コード例 #3
0
    def destination(self, distance, bearing, radius=R_M):
        '''Locates the destination from this point after having
           travelled the given distance on the given bearing.

           @param distance: Distance travelled (same units radius).
           @param bearing: Bearing from this point (compass degrees).
           @keyword radius: Mean earth radius (meter).

           @return: Destination point (L{LatLon}).

           @example:

           >>> p = LatLon(51.4778, -0.0015)
           >>> q = p.destination(7794, 300.7)
           >>> q.toStr()  # 51.513546°N, 000.098345°W

           @JSname: I{destinationPoint}.
        '''
        p = self.toNvector()
        e = NorthPole.cross(p).unit()  # east vector at p
        n = p.cross(e)  # north vector at p

        t = radians(bearing)
        q = n.times(cos(t)).plus(e.times(sin(t)))  # direction vector @ p

        r = float(distance) / float(radius)  # angular distance in radians
        n = p.times(cos(r)).plus(q.times(sin(r)))
        return Nvector(n.x, n.y, n.z).toLatLon()
コード例 #4
0
 def _gc(p, b):
     n, t = p.toNvector(), radians(b)
     de = NorthPole.cross(n, raiser='pole').unit()  # east vector @ n
     dn = n.cross(de)  # north vector @ n
     dest = de.times(sin(t))
     dnct = dn.times(cos(t))
     d = dnct.plus(dest)  # direction vector @ n
     return n.cross(d)  # great circle point + bearing
コード例 #5
0
 def _gc(p, b):
     n = p.toNvector()
     de = NorthPole.cross(n, raiser='pole').unit()  # east vector @ n
     dn = n.cross(de)  # north vector @ n
     s, c = sincos2d(b)
     dest = de.times(s)
     dnct = dn.times(c)
     d = dnct.plus(dest)  # direction vector @ n
     return n.cross(d)  # great circle point + bearing
コード例 #6
0
    def _rotation3(self):
        '''(INTERNAL) Build the rotation matrix from n-vector
           coordinate frame axes.
        '''
        if self._r3 is None:
            nv = self.toNvector()  # local (n-vector) coordinate frame

            d = nv.negate()  # down (opposite to n-vector)
            e = NorthPole.cross(nv, raiser='pole').unit()  # east (pointing perpendicular to the plane)
            n = e.cross(d)  # north (by right hand rule)

            self._r3 = n, e, d  # matrix rows
        return self._r3
コード例 #7
0
    def greatCircle(self, bearing):
        '''Computes n-vector normal to great circle obtained by heading
           on given compass bearing from this point as its n-vector.

           Direction of vector is such that initial bearing vector b =
           c × p.

           @param bearing: Initial compass bearing (degrees).

           @return: N-vector representing great circle (L{Nvector}).

           @example:

           >>> n = LatLon(53.3206, -1.7297).toNvector()
           >>> gc = n.greatCircle(96.0)  # [-0.794, 0.129, 0.594]
        '''
        t = radians(bearing)

        e = NorthPole.cross(self)  # easting
        n = self.cross(e)  # northing

        e = e.times(cos(t) / e.length())
        n = n.times(sin(t) / n.length())
        return n.minus(e)