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


Python Point.distanceTo方法代码示例

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


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

示例1: testDistanceTo

# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distanceTo [as 别名]
 def testDistanceTo(self):
     p = Point(3,4)
     q = Point(4,5)
     
     self.assertEquals(p.distanceTo(q), q.distanceTo(p))
     self.assertEquals(p.distanceTo(q), math.sqrt(2))
     self.assertEquals(p.distanceTo(self.p0), 5.0)
开发者ID:thomaschrstnsn,项目名称:fortifiedforest,代码行数:9,代码来源:test_Point.py

示例2: getVelocity

# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import distanceTo [as 别名]
    def getVelocity(self, at):
        #Get the location of the sphero
        spheroPoint = Point(at.x, at.y)
        #Get the vector towards the goal.
        
        #path should be set by set by the pathfinder?
        if spheroPoint.distanceTo(self.path[self.current]) < SIZE_OF_GRID:
            if self.current >= len(self.path) - 1:
                self.current = 0
            else:
                self.current += 1
        dest = self.path[self.current]

        x = y = 0
        up = Point(dest.x, dest.y - 1)
        left = Point(dest.x - 1, dest.y)
        down = Point(dest.x, dest.y + 1)
        right = Point(dest.x + 1, dest.y)
        poly = [up, left, down, right]
        wayPoint = AttractiveField(-1, 80, 1, poly)
        tmpPoint = wayPoint.getVect(spheroPoint).getPoint()
        x += tmpPoint.x
        y += tmpPoint.y

        #print "fields: " + str(self.fields)
        for field in self.fields:
            if type(field) is AttractiveField and field.inCircle(spheroPoint):
                return Point(0, 0)
            tmpPoint = field.getVect(spheroPoint).getPoint()
            print "vector" + str(field.id) + "=" + str(tmpPoint)
            x += tmpPoint.x
            y += tmpPoint.y
        point = Point(x, y)
        #print "velocity= " + str(point)
        return point
开发者ID:romrell4,项目名称:470-AI,代码行数:37,代码来源:World.py


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