本文整理汇总了Python中java.lang.Math.abs方法的典型用法代码示例。如果您正苦于以下问题:Python Math.abs方法的具体用法?Python Math.abs怎么用?Python Math.abs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Math
的用法示例。
在下文中一共展示了Math.abs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NeighborChecker
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import abs [as 别名]
def NeighborChecker(xar, yar, zar, switch):
""" Check the distance to neighbors, and count the number of neighbors below thdist. """
global thdist
neighborA = zeros('d', len(xar))
if switch:
for i in range(len(xar)):
cx = xar[i]
cy = yar[i]
cz = zar[i]
for j in range(len(xar)):
if j != i :
dist = Math.sqrt( Math.pow((cx - xar[j]), 2) + Math.pow((cy - yar[j]), 2))
if dist < thdist:
if Math.abs(cz - zar[j]) < 2:
logstr = ".... Dot%d - Dot%d too close: dist = %d" % (i, j, dist)
IJ.log(logstr)
print logstr
neighborA[i] += 1
if neighborA[i] > 0:
IJ.log("---> Dot%d rejected" % (i))
print "---> Dot", i, " rejected"
return neighborA
示例2: processEnv
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import abs [as 别名]
def processEnv():
if my._direction_ttl:
my._direction_ttl -= 1
percepts = self.getPercepts()
best = None
rocket = None
for p in percepts:
if p.getTeam() != my.getTeam():
if p.getPerceptType() == 'RocketLauncher': # or i.getPerceptType() == 'Explorer':
if not best or distance(p.getX(), p.getY()) < distance(best.getX(), best.getY()):
best = p
elif p.getPerceptType() == 'Home':
my.setHome(p.getX(), p.getY())
if p.getPerceptType() == 'Rocket' or p.getTeam() != my.getTeam():
if not rocket or distance(p.getX(), p.getY()) < distance(rocket.getX(), rocket.getY()) and Math.abs(self.towards(p.getX(), p.getY()))-Math.abs(self.getHeading()) < 20:
rocket = p
if not best:
return
my.setTarget(p.getX(), p.getY())
# évitement des rockets et des mechants !
if rocket and not my._direction_ttl:
self.setHeading(self.towards(rocket.getX(), rocket.getY())+120)
my._direction_ttl = 30