当前位置: 首页>>代码示例>>Python>>正文


Python GeomUtils.linePointsTowards方法代码示例

本文整理汇总了Python中Utils.GeomUtils.linePointsTowards方法的典型用法代码示例。如果您正苦于以下问题:Python GeomUtils.linePointsTowards方法的具体用法?Python GeomUtils.linePointsTowards怎么用?Python GeomUtils.linePointsTowards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.GeomUtils的用法示例。


在下文中一共展示了GeomUtils.linePointsTowards方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: linesPointAtEachother

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import linePointsTowards [as 别名]
def linesPointAtEachother(linepair1, linepair2):
    ep1 = linepair1[1]
    ep2 = linepair2[1]
    pointsToRadius = max(15, 0.26 * GeomUtils.pointDistance(ep1.X, ep1.Y, ep2.X, ep2.Y) ) #Span out the valid radius at about 30 degrees
    l1_to_l2 = GeomUtils.linePointsTowards(linepair1[0], linepair1[1], linepair2[1], pointsToRadius)
    l2_to_l1 = GeomUtils.linePointsTowards(linepair2[0], linepair2[1], linepair1[1], pointsToRadius)
    ss_logger.debug("l1 points to l2: %s" % (l1_to_l2))
    ss_logger.debug("l2 points to l1: %s" % (l2_to_l1))
    return (l1_to_l2 and l2_to_l1)
开发者ID:loserpenguin15,项目名称:UCSBsketch,代码行数:11,代码来源:RaceTrackObserver.py

示例2: _matchHeadtoTail

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import linePointsTowards [as 别名]
    def _matchHeadtoTail(self, head = None, tail = None, point = None):
        """Input head stroke or tail stroke. If head is specified, match it to a tail. If tail is specified, match it to a head.
           Parameter 'point' should be the tip if head is specified, the end-point if tail is specified.
           Returns a list of tuples: (tip, head_stroke) if tail is specified, (endpoint, tail_stroke) if head is specified."""
        retlist = []
        if point is None:
            return retlist

            
        if head is not None and tail is None: #Head is specified, find the tail
            tip = point
            ep1, ep2 = head.Points[0], head.Points[-1]
            headBreadth = GeomUtils.pointDistance(ep1.X, ep1.Y, ep2.X, ep2.Y)
            for endpoint, tailStroke in self._endpoints:
                if GeomUtils.strokeLength(head) < GeomUtils.strokeLength(tailStroke) \
                and _isPointWithHead(endpoint, head, tip): #Make sure the proportions aren't totally off
                    logger.debug("Head stroke has a tail close and within cone")
                    pointingLength = len(tailStroke.Points) / 5
                    #headToTail
                    if endpoint == tailStroke.Points[0]:
                        linept1, linept2 = tailStroke.Points[pointingLength], endpoint
                    elif endpoint== tailStroke.Points[-1]:
                        linept1, linept2 = tailStroke.Points[-pointingLength], endpoint
                    pointsTo = GeomUtils.linePointsTowards(linept1, linept2, tip, headBreadth)
                    if pointsTo:
                        retlist.append( (endpoint, tailStroke) )

        elif tail is not None and head is None: #Find the head
            endpoint = point
            pointingLength = len(tail.Points) / 5
            #headToTail
            if endpoint == tail.Points[0]:
                linept1, linept2 = tail.Points[pointingLength], endpoint
            elif endpoint== tail.Points[-1]:
                linept1, linept2 = tail.Points[-pointingLength], endpoint

            for tip, headStroke in self._arrowHeads:
                ep1, ep2 = headStroke.Points[0], headStroke.Points[-1]
                headBreadth = GeomUtils.pointDistance(ep1.X, ep1.Y, ep2.X, ep2.Y)
                if GeomUtils.strokeLength(headStroke) < GeomUtils.strokeLength(tail) \
                and _isPointWithHead(endpoint, headStroke, tip):
                    logger.debug("Tail stroke is close and within cone of an arrowhead")
                    pointsTo = GeomUtils.linePointsTowards(linept1, linept2, tip, headBreadth)
                    if pointsTo:
                        retlist.append( (tip, headStroke) )
        return retlist
开发者ID:loserpenguin15,项目名称:UCSBsketch,代码行数:48,代码来源:ArrowObserver.py

示例3: tipToNode

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import linePointsTowards [as 别名]
 def tipToNode( self, arrow_anno, circle_anno ):
     "return true if the tip of the arrow points to the circle"
     lineDist = min(10, max(len(arrow_anno.tailstroke.Points) / 10, 1)) #Check the last 10th of the stroke points the right way
     #lineseg: two points from arrow "neck" to arrowhead tip 
     #lineseg2: two points from arrow "neck" to last point in tail stroke
     if arrow_anno.direction == "tail2head":
         lineSeg = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tip )
         lineSeg2 = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tailstroke.Points[-1] )
     else: #direction == 'head2tail'
         lineSeg = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tip )
         lineSeg2 = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tailstroke.Points[0] )
         
     if GeomUtils.pointDist( arrow_anno.tip,  circle_anno.center ) < circle_anno.radius* DiGraphAnnotation.MATCHING_DISTANCE:
         if GeomUtils.linePointsTowards( lineSeg[0], lineSeg[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
         if GeomUtils.linePointsTowards( lineSeg2[0], lineSeg2[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
     return False
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:20,代码来源:DiGraphObserver.py

示例4: tailToNode

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import linePointsTowards [as 别名]
 def tailToNode( self, arrow_anno, circle_anno ):
     "return true if the tail of the arrow comes from the circle"
     lineDist = max(len(arrow_anno.tailstroke.Points) / 10, 1) #Check the last 10th of the stroke points the right way
     if arrow_anno.direction == "tail2head":
         lineSeg = ( arrow_anno.tailstroke.Points[lineDist], arrow_anno.tailstroke.Points[0] )
     else: #direction == 'head2tail'
         lineSeg = ( arrow_anno.tailstroke.Points[-lineDist], arrow_anno.tailstroke.Points[-1] )
         
     if GeomUtils.pointDist( arrow_anno.tail,  circle_anno.center ) < circle_anno.radius* DiGraphAnnotation.MATCHING_DISTANCE:
         if GeomUtils.linePointsTowards( lineSeg[0], lineSeg[1], circle_anno.center, circle_anno.radius * DiGraphAnnotation.POINTSTO_DISTANCE):
             return True
     return False
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:14,代码来源:DiGraphObserver.py

示例5: _matchHeadtoTail

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import linePointsTowards [as 别名]
    def _matchHeadtoTail(self, head = None, tail = None, point = None):
        """Input head stroke or tail stroke. If head is specified, match it to a tail. If tail is specified, match it to a head.
           Parameter 'point' should be the tip if head is specified, the end-point if tail is specified.
           Returns a list of tuples: (tip, head_stroke) if tail is specified, (endpoint, tail_stroke) if head is specified."""
        retlist = []
        if point is None:
            return retlist

            
        headStroke = head
        tailStroke = tail

        if headStroke is not None and tail is None: #Head is specified, find the tail
            tip = point
            ep1, ep2 = headStroke.Points[0], headStroke.Points[-1]
            headBreadth = GeomUtils.pointDistance(ep1.X, ep1.Y, ep2.X, ep2.Y)
            for endpoint, origStk, tailStroke in self._endpoints:
                pointingLength = len(tailStroke.Points) / 10
                if endpoint == tailStroke.Points[0]: #Treat as drawn head2tail
                    tailpoints = tailStroke.Points
                    linept1, linept2 = tailStroke.Points[pointingLength], endpoint
                elif endpoint== tailStroke.Points[-1]: #Treat as drawn tail2head
                    tailpoints = list(reversed(tailStroke.Points))
                    linept1, linept2 = tailStroke.Points[-(pointingLength+1)], endpoint

                headLen = GeomUtils.strokeLength(headStroke) 
                tailLen = GeomUtils.strokeLength(tailStroke)
                pointWithHead = _isPointWithHead(tailpoints, headStroke, tip)
                if headLen < tailLen * 2 \
                and pointWithHead:
                    logger.debug("Head stroke has a tail close and within cone")
                    #headToTail
                    pointsTo = GeomUtils.linePointsTowards(linept1, linept2, tip, headBreadth)
                    if pointsTo:
                        logger.debug("  Tail points to head")
                        retlist.append( (endpoint, origStk) )
                    else:
                        logger.debug("  Tail does NOT point to head")
                else:
                    if headLen < tailLen * 2:
                        logger.debug("  Head stroke scale is okay for this arrowhead")
                    else:
                        logger.debug("  Head stroke scale is BAD for this arrowhead")
                        logger.debug("  Head Len: %s, tail Len: %s" % (headLen, tailLen))
                    if not pointWithHead:
                        logger.debug("  Head stroke is NOT close or within cone of an arrowhead\n")
                    else:
                        logger.debug("  Head stroke is close and within cone of an arrowhead\n")

        elif tailStroke is not None and headStroke is None: #Find the head
            endpoint = point
            pointingLength = len(tailStroke.Points) / 10

            if endpoint == tailStroke.Points[0]: #Treat as drawn head2tail
                tailpoints = tailStroke.Points
                linept1, linept2 = tailStroke.Points[pointingLength], endpoint
            elif endpoint== tailStroke.Points[-1]: #Treat as drawn tail2head
                tailpoints = list(reversed(tailStroke.Points))
                linept1, linept2 = tailStroke.Points[-pointingLength], endpoint

            for tip, origStk, headStroke in self._arrowHeads:
                ep1, ep2 = headStroke.Points[0], headStroke.Points[-1]
                headBreadth = GeomUtils.pointDistance(ep1.X, ep1.Y, ep2.X, ep2.Y)
                headLen = GeomUtils.strokeLength(headStroke) 
                tailLen = GeomUtils.strokeLength(tailStroke)
                pointWithHead = _isPointWithHead(tailpoints, headStroke, tip)
                if headLen < tailLen * 2\
                and pointWithHead:
                    logger.debug("Tail stroke is close and within cone of an arrowhead")
                    pointsTo = GeomUtils.linePointsTowards(linept1, linept2, tip, headBreadth)
                    if pointsTo:
                        logger.debug("  Tail points to head")
                        retlist.append( (tip, origStk) )
                    else:
                        logger.debug("  Tail does NOT point to head")
                else:
                    if headLen < tailLen * 2:
                        logger.debug("  Tail stroke scale is okay for this arrowhead")
                    else:
                        logger.debug("  Tail stroke scale is BAD for this arrowhead")
                        logger.debug("  Head Len: %s, tail Len: %s" % (headLen, tailLen))

                    if not pointWithHead:
                        logger.debug("  Tail stroke is NOT close or within cone of an arrowhead\n")
                    else:
                        logger.debug("  Tail stroke is close and within cone of an arrowhead\n")
                        
        return retlist
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:90,代码来源:ArrowObserver.py


注:本文中的Utils.GeomUtils.linePointsTowards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。