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


Python GeomUtils.centroid方法代码示例

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


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

示例1: _scoreStroke

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def _scoreStroke(stroke, template, sample_size = None):
    
    if sample_size is None:
        sample_size = len(template)
        
    sNorm = GeomUtils.strokeNormalizeSpacing(stroke, len(template))
    centr = GeomUtils.centroid(sNorm.Points)
    numPoints = len(sNorm.Points)
    
    point_vect = []
    templ_vect = []

    numPoints = len(template)
    if len(template) == len(sNorm.Points):
        for idx in range(0, numPoints, numPoints/sample_size ):
            templ_vect.append(template[idx].X)
            templ_vect.append(template[idx].Y)
            
            p = sNorm.Points[idx]
            point_vect.append(p.X - centr.X)
            point_vect.append(p.Y - centr.Y)
       
        angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
    else:
        angularDist = math.pi
    return angularDist
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:28,代码来源:Template.py

示例2: SaveTemplate

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
 def SaveTemplate(self, numSamples = TEMPLATE_SAMPLE):
     if len(self.StrokeList) > 0:
         last_stroke = self.StrokeList[-1]
         template_name = str(len(self.StrokeList))
         sNorm = GeomUtils.strokeNormalizeSpacing(last_stroke, numSamples)
         centroid = GeomUtils.centroid(sNorm.Points)
         sNorm = sNorm.translate(-1*centroid.X, -1 * centroid.Y)
         storeTemplate(sNorm, tag=template_name)
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:10,代码来源:TkTemplateInput.py

示例3: drawMyself

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
    def drawMyself( self ):
        for a in self.annotation_list:
            center = GeomUtils.centroid(a.Strokes[0].Points) #Ugly hack to get the center of the annotation!
            templ_stroke = Stroke.Stroke(a.template)
            templ_stroke = templ_stroke.translate(center.X, center.Y)

            SketchGUI.drawText(center.X, center.Y, InText=a.name)
            SketchGUI.drawStroke(templ_stroke, color="#F050F0")
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:10,代码来源:TemplateObserver.py

示例4: scoreStroke

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def scoreStroke(stroke, template):
    sNorm = GeomUtils.strokeNormalizeSpacing(stroke, TEMPLATE_SAMPLE)
    centr = GeomUtils.centroid(sNorm.Points)
    point_vect = []
    templ_vect = []
    for q in template:
       templ_vect.append(q.X)
       templ_vect.append(q.Y)
    for p in sNorm.Points:
       point_vect.append(p.X - centr.X)
       point_vect.append(p.Y - centr.Y)
    angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
    return angularDist
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:15,代码来源:TkTemplateInput.py

示例5: SaveTemplate

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
 def SaveTemplate(self, sender, e, numSamples = TEMPLATE_SAMPLE):
     if len(self.StrokeList) > 0:
         #last_stroke = self.StrokeList[-1]
         pts = []
         for stk in self.StrokeList:
             pts.extend(stk.Points)
         templ_stroke = Stroke.Stroke(points= pts)
         template_name = TEMPLATE_TEXT.Text 
         if template_name.strip() == '':
             template_name = 'Blob'
         sNorm = GeomUtils.strokeNormalizeSpacing(templ_stroke, numSamples * len(self.StrokeList))
         centroid = GeomUtils.centroid(sNorm.Points)
         sNorm = sNorm.translate(-1*centroid.X, -1 * centroid.Y)
         storeTemplate(sNorm, len(self.StrokeList), tag=template_name)
     self.Clear()
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:17,代码来源:WpfTemplateInput.py


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