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


Python GeomUtils.pointInAngleCone方法代码示例

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


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

示例1: onAnnotationSuggested

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import pointInAngleCone [as 别名]
    def onAnnotationSuggested(self, anno_type, strokelist):
        """Called when the a list of strokes are suggested to yield an annotation of type anno_type."""

        #First pass, assume we were just too strict with the distance/size thresholds
        knownHeads = []
        knownTails = []
        for tip, stk in self._arrowHeads:
            if stk in strokelist:
                knownHeads.append( (tip, stk) )
        for ep, tail_stk in self._endpoints:
            if tail_stk in strokelist:
                for tip, head_stk in knownHeads:
                    if head_stk == tail_stk:
                        continue
                    headEnds = ( head_stk.Points[0], head_stk.Points[-1] )
                    if GeomUtils.pointInAngleCone(ep, headEnds[0], tip, headEnds[1]):
                        anno = ArrowAnnotation( tip, ep, headstroke= head_stk, tailstroke = tail_stk )
                        self.getBoard().AnnotateStrokes([head_stk, tail_stk],anno)
                        logger.debug("Suggestion Response: Matched arrow with looser constraints")
                        return

        #Second pass, we missed the arrowhead to begin with

        logger.warn("Not able to generate Arrow!")
        return
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:27,代码来源:ArrowObserver.py

示例2: _isPointWithHead

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import pointInAngleCone [as 别名]
def _isPointWithHead(point, head, tip):
    "Returns true if point is close enough and within the cone of the head stroke"
    distanceThresh = 1 
    distanceThresh *= distanceThresh #Keep up with squared distances

    ep1 = head.Points[0]
    ep2 = head.Points[-1]
    #              *  tip
    #           o     o
    #          o        o
    #        o            o
    #      o      (x)      o
    #          midpoint
    #
    #             * endpoint
    #            o
    #            o
    #           o
    #         (etc)
    midpoint = Point((ep1.X + ep2.X)/2, (ep1.Y + ep2.Y)/2) #Mid-way between the two endpoints of the arrowhead
    tip_to_endpoint = GeomUtils.pointDistanceSquared(point.X, point.Y, tip.X, tip.Y)
    tip_to_backofarrowhead =  GeomUtils.pointDistanceSquared(tip.X, tip.Y, midpoint.X, midpoint.Y)
    endpoint_to_backofarrowhead = GeomUtils.pointDistanceSquared(point.X, point.Y, midpoint.X, midpoint.Y)
    
    #logger.debug("tip_to_endpoint: %s\n, tip_to_backofarrowhead: %s,\n endpoint_to_backofarrowhead: %s" % (tip_to_endpoint, tip_to_backofarrowhead, endpoint_to_backofarrowhead))
    #Tail's endpoint is close to the end of the arrowhead, or even closer to the tip of the arrowhead
    if tip_to_backofarrowhead >= endpoint_to_backofarrowhead or tip_to_backofarrowhead >= tip_to_endpoint:
        if GeomUtils.pointInAngleCone(point, ep1, tip, ep2):
            return True
    return False
开发者ID:loserpenguin15,项目名称:UCSBsketch,代码行数:32,代码来源:ArrowObserver.py

示例3: _isPointWithHead

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import pointInAngleCone [as 别名]
def _isPointWithHead(point, head, tip):
    "Returns true if point is close enough and within the cone of the head stroke"
    ep1 = head.Points[0]
    ep2 = head.Points[-1]
    midpoint = Point((ep1.X + ep2.X)/2, (ep1.Y + ep2.Y)/2)
    tip_to_endpoint = GeomUtils.pointDistanceSquared(point.X, point.Y, tip.X, tip.Y)
    tip_to_backofarrowhead =  GeomUtils.pointDistanceSquared(tip.X, tip.Y, midpoint.X, midpoint.Y)
    
    if tip_to_endpoint < tip_to_backofarrowhead:
        if GeomUtils.pointInAngleCone(point, ep1, tip, ep2):
            return True
    return False
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:14,代码来源:ArrowObserver.py

示例4: _isPointWithHead

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import pointInAngleCone [as 别名]
def _isPointWithHead(tailpoints, head, tip):
    "Returns true if point is close enough and within the cone of the head stroke"

    distanceThresh = 1 
    distanceThresh *= distanceThresh #Keep up with squared distances

    point = tailpoints[0]
    ep1 = head.Points[0]
    ep2 = head.Points[-1]
    #              *  tip
    #           o     o
    #          o        o
    #        o            o
    #      o      (x)      o
    #          midpoint
    #
    #             * endpoint
    #            o
    #            o
    #           o
    #         (etc)
    midpoint = Point((ep1.X + ep2.X)/2, (ep1.Y + ep2.Y)/2) #Mid-way between the two endpoints of the arrowhead
    tip_to_endpoint = GeomUtils.pointDistanceSquared(point.X, point.Y, tip.X, tip.Y)
    tip_to_backofarrowhead =  GeomUtils.pointDistanceSquared(tip.X, tip.Y, midpoint.X, midpoint.Y)
    endpoint_to_backofarrowhead = GeomUtils.pointDistanceSquared(point.X, point.Y, midpoint.X, midpoint.Y)

    #fuzz = math.sqrt(tip_to_backofarrowhead) #Number of pixels to fuzz the "in-angle-cone" test
    
    #logger.debug("tip_to_endpoint: %s\n, tip_to_backofarrowhead: %s,\n endpoint_to_backofarrowhead: %s" % (tip_to_endpoint, tip_to_backofarrowhead, endpoint_to_backofarrowhead))
    #Tail's endpoint is close to the end of the arrowhead, or even closer to the tip of the arrowhead
    if tip_to_backofarrowhead >= endpoint_to_backofarrowhead or tip_to_backofarrowhead >= tip_to_endpoint:
        logger.debug("Distance from head-tip to tail-endpoint is good!")
        #Check the in-angle cone progressively down the tail
        epList = tailpoints[: len(tailpoints) / 3]

        for pt in epList:
            if GeomUtils.pointInAngleCone(pt, ep1, tip, ep2):
                logger.debug("Endpoint inside angle cone")
                return True
    return False
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:42,代码来源:ArrowObserver.py


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