本文整理汇总了Python中java.lang.Math.pow方法的典型用法代码示例。如果您正苦于以下问题:Python Math.pow方法的具体用法?Python Math.pow怎么用?Python Math.pow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Math
的用法示例。
在下文中一共展示了Math.pow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def process(input, position):
size = len(input)
output = copy.deepcopy(input)
fft = DoubleFFT_1D(size)
fft.realForward(output)
for j in range(size/2):
output[j]= Math.sqrt(Math.pow(output[2*j],2)+Math.pow(output[2*j+1],2));
return output[:len(input)/2]
示例2: toBut
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def toBut(self, but):
if but.x == 'abs':
return but.y
a = but.x - self.origin.x
b = but.y - self.origin.y
if a == 0 and b == 0:
return rnd.nextDouble() * 360;
if b < 0:
return 180*Math.asin(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI+270
else:
return 180*Math.acos(a / Math.sqrt(Math.pow(a,2)+Math.pow(b,2)))/Math.PI
示例3: longJumps
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def longJumps(t, mindist):
for nd in t.getRoot().getSubtreeNodes():
if nd.parent is None:
continue
d = Math.sqrt(Math.pow(nd.x - nd.parent.x, 2) + Math.pow(nd.y - nd.parent.y, 2))
if d > mindist:
print nd.x, nd.y
p = array([nd.x, nd.y], 'f')
aff = t.affineTransform
aff.transform(p, 0, p, 0, 1)
cal = t.layerSet.getCalibration()
print "Off:", p[0] * cal.pixelWidth, p[1] * cal.pixelHeight, (nd.layer.getParent().indexOf(nd.layer) + 1)
示例4: bug_vector_y
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def bug_vector_y(percept, dist, scale, theta, p):
r = percept.getRadius() / 2
return (
Math.sin(deg2pi(180 + self.towards(percept.getX() + r, percept.getY() + r)))
* theta
/ Math.pow((dist / scale), p)
)
示例5: NeighborChecker
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [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
示例6: compute_heading
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def compute_heading ():
if (mvt_mem.direction=="EAST"):
x_modifier=2000
y_modifier=0
elif (mvt_mem.direction=="WEST"):
x_modifier=-2000
y_modifier=0
elif (mvt_mem.direction=="SOUTH"):
x_modifier=0
y_modifier=+2000
elif (mvt_mem.direction=="NORTH"):
x_modifier=0
y_modifier=-1000
# on construit une liste de TOUS les objets répulsifs
repulsives = percepts.attackers.items () + \
percepts.explorers.items () + \
percepts.homes.items () + \
percepts.friends.items () + \
percepts.obstacles.items ()
# valeurs magiques
theta = 140
scale = 25
p = 2
u = 30
# composantes X et Y du vecteur direction final
X = 0
Y = 0
if repulsives:
for it, dist in repulsives:
X = X + Math.cos (deg2pi (180 + self.towards (it.getX(), it.getY()))) * theta / Math.pow (dist/scale, p)
Y = Y + Math.sin (deg2pi (180 + self.towards (it.getX(), it.getY()))) * theta / Math.pow (dist/scale, p)
toterm ("AFTER REPULSION:"+str(X) +" "+ str(Y))
X = X + Math.cos (deg2pi ( self.getHeading() ))*u
Y = Y + Math.sin (deg2pi ( self.getHeading() ))*u
toterm ("AFTER ATTRACTION:"+str(X) +" "+ str(Y))
X+=x_modifier
Y+=y_modifier
toterm ("NEW HEADING : "+str(self.towards (X, Y)))
self.setHeading (self.towards (X, Y))
示例7: vector_y
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def vector_y (percept, dist, scale, theta, p):
return Math.sin (deg2pi (180 + self.towards (percept.getX(), percept.getY()))) * theta / Math.pow ((dist / scale), p)
示例8: _distance
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def _distance(o1, o2):
return Math.sqrt(Math.pow(o2.x - o1.x,2) + Math.pow(o2.y - o1.y, 2))
示例9: distxy
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def distxy(self, ox, oy):
return Math.sqrt(Math.pow(self.x-ox,2)+Math.pow(self.y-oy,2))
示例10: computeWorldCorrection
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def computeWorldCorrection():
x0, y0, z0 = 43324.0, 41836.0, 0.0
x1, y1, z1 = 46780.0, 45532.0, 22950.0
x2, y2, z2 = x0, y0, z1
# A point in the first section that should be directly on top of the x0,y0,z0
x3, y3, z3 = 48164, 23372, 0
trans = Transform3D()
trans.setTranslation(Vector3d(-x0, -y0, 0))
rot = Transform3D()
p0 = Vector3d(0, 0, z1)
p1 = Vector3d(x1 - x0, y1 - y0, z1 - z0)
pc = Vector3d()
pc.cross(p1, p0)
angle = Math.atan(Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)) / (z1 - z0))
print angle * 180 / Math.PI
rot.setRotation(AxisAngle4d(pc, angle))
t = Transform3D()
t.mul(rot)
t.mul(trans)
# Transform the third point
p3 = Point3d(x3, y3, z3)
t.transform(p3)
print "A p3:", p3
# test
p0 = Point3d(x0, y0, z0)
t.transform(p0)
print "A: p0", p0
p1 = Point3d(x1, y1, z1)
t.transform(p1)
print "A: p1", p1
# Compute rotation of third point around Z axis
rotZ = Transform3D()
angleZ = Math.atan((p3.x - 0) / (p3.y - 0))
print "angleZ", angleZ
rotZ.setRotation(AxisAngle4d(Vector3d(0,0,1), angleZ))
t.mul(rotZ, t)
# test
p0 = Point3d(x0, y0, z0)
t.transform(p0)
print p0
p1 = Point3d(x1, y1, z1)
t.transform(p1)
print p1
p3 = Point3d(x3, y3, z3)
t.transform(p3)
print p3
return t
示例11: test_pow
# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import pow [as 别名]
def test_pow(self):
self.assertEqual(Math.pow(5, 3), 125)