Example #1
0
 def format_coord(self, xd, yd):
     """
     Given the 2D view coordinates attempt to guess a 3D coordinate.
     Looks for the nearest edge to the point and then assumes that
     the point is at the same z location as the nearest point on the edge.
     """
     if self.M is None:
         return ''
     if self.button_pressed == 1:
         return 'azimuth=%d deg, elevation=%d deg ' % (self.azim, self.elev)
     p = (xd, yd)
     edges = self.tunit_edges()
     ldists = [(proj3d.line2d_seg_dist(p0, p1, p), i) for \
             i, (p0, p1) in enumerate(edges)]
     ldists.sort()
     edgei = ldists[0][1]
     p0, p1 = edges[edgei]
     x0, y0, z0 = p0
     x1, y1, z1 = p1
     d0 = np.hypot(x0-xd, y0-yd)
     d1 = np.hypot(x1-xd, y1-yd)
     dt = d0+d1
     z = d1/dt * z0 + d0/dt * z1
     x, y, z = proj3d.inv_transform(xd, yd, z, self.M)
     xs = self.format_xdata(x)
     ys = self.format_ydata(y)
     zs = self.format_ydata(z)
     return 'x=%s, y=%s, z=%s' % (xs, ys, zs)
Example #2
0
    def format_coord(self, xd, yd):
        """Given the 2D view coordinates attempt to guess a 3D coordinate

        Looks for the nearest edge to the point and then assumes that the point is
        at the same z location as the nearest point on the edge.
        """
        p = (xd,yd)
        edges = self.tunit_edges()
        #lines = [proj3d.line2d(p0,p1) for (p0,p1) in edges]
        ldists = [(proj3d.line2d_seg_dist(p0,p1,p),i) for i,(p0,p1) in enumerate(edges)]
        ldists.sort()
        # nearest edge
        edgei = ldists[0][1]
        #
        p0,p1 = edges[edgei]

        # scale the z value to match
        x0,y0,z0 = p0
        x1,y1,z1 = p1
        d0 = nx.hypot(x0-xd,y0-yd)
        d1 = nx.hypot(x1-xd,y1-yd)
        dt = d0+d1
        z = d1/dt * z0 + d0/dt * z1
        #print 'mid', edgei, d0, d1, z0, z1, z

        x,y,z = proj3d.inv_transform(xd,yd,z,self.M)

        xs = self.format_xdata(x)
        ys = self.format_ydata(y)
        zs = self.format_ydata(z)
        return  'x=%s, y=%s z=%s'%(xs,ys,zs)
Example #3
0
    def format_coord(self, xd, yd):
        """
        Given the 2D view coordinates attempt to guess a 3D coordinate.
        Looks for the nearest edge to the point and then assumes that
        the point is at the same z location as the nearest point on the edge.
        """

        if self.M is None:
            return ''

        if self.button_pressed in self._rotate_btn:
            return 'azimuth=%d deg, elevation=%d deg ' % (self.azim, self.elev)
            # ignore xd and yd and display angles instead

        p = (xd, yd)
        edges = self.tunit_edges()
        #lines = [proj3d.line2d(p0,p1) for (p0,p1) in edges]
        ldists = [(proj3d.line2d_seg_dist(p0, p1, p), i) for \
                i, (p0, p1) in enumerate(edges)]
        ldists.sort()
        # nearest edge
        edgei = ldists[0][1]

        p0, p1 = edges[edgei]

        # scale the z value to match
        x0, y0, z0 = p0
        x1, y1, z1 = p1
        d0 = np.hypot(x0-xd, y0-yd)
        d1 = np.hypot(x1-xd, y1-yd)
        dt = d0+d1
        z = d1/dt * z0 + d0/dt * z1

        x, y, z = proj3d.inv_transform(xd, yd, z, self.M)

        xs = self.format_xdata(x)
        ys = self.format_ydata(y)
        zs = self.format_ydata(z)
        return 'x=%s, y=%s, z=%s' % (xs, ys, zs)
Example #4
0
    def format_coord(self, xd, yd):
        """
        Given the 2D view coordinates attempt to guess a 3D coordinate.
        Looks for the nearest edge to the point and then assumes that
        the point is at the same z location as the nearest point on the edge.
        """

        if self.M is None:
            return ""

        if self.button_pressed in self._rotate_btn:
            return "azimuth=%d deg, elevation=%d deg " % (self.azim, self.elev)
            # ignore xd and yd and display angles instead

        p = (xd, yd)
        edges = self.tunit_edges()
        # lines = [proj3d.line2d(p0,p1) for (p0,p1) in edges]
        ldists = [(proj3d.line2d_seg_dist(p0, p1, p), i) for i, (p0, p1) in enumerate(edges)]
        ldists.sort()
        # nearest edge
        edgei = ldists[0][1]

        p0, p1 = edges[edgei]

        # scale the z value to match
        x0, y0, z0 = p0
        x1, y1, z1 = p1
        d0 = np.hypot(x0 - xd, y0 - yd)
        d1 = np.hypot(x1 - xd, y1 - yd)
        dt = d0 + d1
        z = d1 / dt * z0 + d0 / dt * z1

        x, y, z = proj3d.inv_transform(xd, yd, z, self.M)

        xs = self.format_xdata(x)
        ys = self.format_ydata(y)
        zs = self.format_ydata(z)
        return "x=%s, y=%s, z=%s" % (xs, ys, zs)