本文整理汇总了Python中Utils.GeomUtils.rotateStroke方法的典型用法代码示例。如果您正苦于以下问题:Python GeomUtils.rotateStroke方法的具体用法?Python GeomUtils.rotateStroke怎么用?Python GeomUtils.rotateStroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils.GeomUtils
的用法示例。
在下文中一共展示了GeomUtils.rotateStroke方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Score
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import rotateStroke [as 别名]
def Score( self, strokelist, max_return = 1, interest = 0.2):
"Compare these strokes to all templates, and return the best templates with their scores. "
ROTATIONS = 16
best_templ = None
for stroke_order in itertools.permutations(strokelist):
pointlist = []
for s in stroke_order:
pointlist.extend(s.Points)
new_stroke = Stroke.Stroke(points=pointlist)
for name, template_set in self._templates.items():
for template in template_set:
for angle in [2 * math.pi / ROTATIONS * i for i in range(ROTATIONS)]:
end_template = GeomUtils.rotateStroke(Stroke.Stroke(points=template), angle).Points
firstpass_score = _scoreStroke(new_stroke, end_template, 10)
if best_templ is not None and firstpass_score - 0.1 > best_templ['score']:
continue
score = _scoreStroke(new_stroke, end_template, len(end_template))
logger.debug(" '%s' ... %s" % (name, score))
if best_templ is None:
best_templ = {'score': score + 1}
if score < best_templ['score']:
best_templ['name'] = name
best_templ['score'] = score
best_templ['template'] = end_template
return best_templ