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


Python Math.sqrt方法代码示例

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


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

示例1: toBut

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [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
开发者ID:hasanzorlu,项目名称:kalle-martin-group,代码行数:13,代码来源:PrivatHomekiller.py

示例2: process

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [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]
开发者ID:evaimg,项目名称:Icy-App,代码行数:10,代码来源:Jython_FFT_half.py

示例3: eviteAmis

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
def eviteAmis(percepts):

	dist1 = dist2 = 500
	taille_robot = 20
	liste_obstacles = []
	for p in percepts:
		centre = Point()
		centre.setCoord(p.getX(), p.getY())
		liste_obstacles.append(centre)
		
		        			
	# on dessine 2 droite paralleles a la direction
	# qui partent des bords du robot -> d1 : y = 12 et d2 : y = -12
	# Dans nouveau repere : origine = self
	#                       rotation du repere de l"angle de direction courant
	direction = self.getHeading()
	angle = Math.PI * direction / 180
	t = Math.tan(angle)
	s = Math.sin(angle)
	c = Math.cos(angle)
		
	for p in liste_obstacles:
	
		# centre_x, centre_y : centre de l"obstacle dans le repere
		centre_x = (  p.getX() + t* p.getY()) / (c + s * t)
		centre_y = -p.getY()/c + t * centre_x

		# savoir quelle droite prendre
		if centre_x > 0:
			if centre_y >= 0 and centre_y <= 2*taille_robot:
				y = centre_y - taille_robot
				dist1 = min(dist1,-Math.sqrt(taille_robot*taille_robot - y*y) + centre_x)
			elif centre_y < 0 and centre_y >= -(2*taille_robot):
				y = centre_y + taille_robot
				dist2 = min(dist2,-Math.sqrt(taille_robot*taille_robot - y*y) + centre_x)

	if min(dist1, dist2) <= 100 and abs(dist1 - dist2) > 2:
		if dist1 < dist2:
			direction += 100/dist1
		else:
			direction -= 100/dist2
	
		self.setHeading(direction)	
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:45,代码来源:BPVHomeKiller.py

示例4: message

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
  def message(self, m):
    x = float(m.getArg1()) + m.getFromX()
    y = float(m.getArg2()) + m.getFromY()
    d = Math.sqrt(x*x+y*y)
    a = m.getAct()
    if a=='Me':
      return 1/(d + 1)
    elif a=='RocketLauncher':
      if d>200 and d<400 and mem.trouille < mem.t:
	mem.trouille = mem.t
开发者ID:hasanzorlu,项目名称:kalle-martin-group,代码行数:12,代码来源:PrivatBase.py

示例5: arcTo

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
def arcTo(self, cx, cy, p2x, p2y):
	"""Adds a segment from the current position to p2x, p2y by drawing part of a circle centered on 'cx,cy'"""
	p1x, p1y = self.nodes[-1].position2()
	angle1 = Math.atan2(-(p1y-cy), p1x-cx)
	angle2 = Math.atan2(-(p2y-cy), p2x-cx)
	if (angle2-angle1>Math.PI):
		angle2-=Math.PI*2
	if (angle2-angle1<-Math.PI):
		angle2+=Math.PI*2
	self.arc(Math.sqrt( (p1x-cx)*(p1x-cx)+(p1y-cy)*(p1y-cy)), cx,cy, angle1, angle2, join=1)
	return self
开发者ID:EQ4,项目名称:Field,代码行数:13,代码来源:NewCachedLines.py

示例6: longJumps

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [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)
开发者ID:acardona,项目名称:Fiji-TrakEM2-scripts,代码行数:14,代码来源:long_jumps.py

示例7: NeighborChecker

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [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
开发者ID:cmci,项目名称:3D-DotDetection,代码行数:24,代码来源:Dot3Danalysis_2_MI.py

示例8: edges

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
parser.add_option("--no-preserveGroups", default=True, action="store_false",
                  dest="preserveGroups",
                  help="do not preserve groups: edges adjacent to two "
                  "different groups are handled like normal edges (default: "
                  "preserve groups)")
parser.add_option("-k", "--skeleton",
                  default=False, action="store_true", dest="skeleton",
                  help="remesh skeleton beforehand")
parser.add_option("-n", "--allowNearNodes",
                  action="store_true", dest="allowNearNodes",
                  help="insert vertices even if this creates a small edge")
parser.add_option("-r", "--rho", metavar="FLOAT", default=2.0,
                  action="store", type="float", dest="rho",
                  help="numerical metric ratio (required: rho > 1, default: 2)")
parser.add_option("-T", "--nearLengthRatio", metavar="FLOAT",
                  default=1.0/Math.sqrt(2.0), action="store", type="float",
                  dest="nearLengthRatio",
                  help="ratio to size target to determine if a vertex is near "
                  "an existing point (default: 1/sqrt(2))")
parser.add_option("-w", "--wire", metavar="FLOAT", default=-1.0,
                  action="store", type="float", dest="wire",
                  help="remesh beams (default: -1.0: do not remesh)")
parser.add_option("-e", "--eratio", metavar="FLOAT", default=10.0,
                  action="store", type="float", dest="eratio",
                  help="remove triangles whose edge ratio is greater than "
                  "tolerance (default: 10.0)")
parser.add_option("-I", "--immutable-border",
                  action="store_true", dest="immutable_border",
                  help="Tag free edges as immutable")
parser.add_option("-M", "--immutable-groups", metavar="STRING",
                  action="store", type="string", dest="immutable_groups_file",
开发者ID:alclp,项目名称:jCAE,代码行数:33,代码来源:remeshSingularity.py

示例9: distance

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
def distance(x, y):
    try:
        return Math.sqrt(x * x + y * y)
    except:
        return -1
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:7,代码来源:Tourneur.py

示例10: distance

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
def distance(_node1,_node2):
	return Math.sqrt(((_node1.x - _node2.x) * (_node1.x - _node2.x)) + ((_node1.y - _node2.y) * (_node1.y - _node2.y)))
开发者ID:cns-iu,项目名称:nwb,代码行数:4,代码来源:Main-applet.py

示例11: distance

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
def distance (x, y):
    return Math.sqrt (x*x + y*y)
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:4,代码来源:SamMaxHomekiller.py

示例12: dist

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
 def dist(self, p):
     return Math.sqrt(((self.y-p.y)*(self.y-p.y))+((self.x-p.x)*(self.x-p.x)))
开发者ID:ThisNameNotUsed,项目名称:code-samples,代码行数:4,代码来源:BoilerPlateClasses.py

示例13: __abs__

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
 def __abs__(self):
     return Math.sqrt(self.x*self.x+self.y*self.y)
开发者ID:ThisNameNotUsed,项目名称:code-samples,代码行数:4,代码来源:BoilerPlateClasses.py

示例14: metric

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
 def metric(self, l):
     # Use Java API directly
     import java.lang.Math as math
     return math.sqrt(l[0] / l[1])
开发者ID:StevenLOL,项目名称:h2o-3,代码行数:6,代码来源:utils_model_metrics.py

示例15: distxy

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sqrt [as 别名]
 def distxy(self, ox, oy):
   return Math.sqrt(Math.pow(self.x-ox,2)+Math.pow(self.y-oy,2))
开发者ID:hasanzorlu,项目名称:kalle-martin-group,代码行数:4,代码来源:PrivatHomekiller.py


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