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


Python Math.sin方法代码示例

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


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

示例1: bug_vector_y

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

示例2: move

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
	def move(this):
		if not this._first_time and this._explore_ttl:
			this._explore_ttl -=1
			if not this._explore_ttl % 50:
				d('explore: '+str(this._explore_ttl))
			if not this._explore_ttl:
				this.me.setBehavior(exploring)
				return
		if this._join_ttl:
			this._join_ttl -= 1
			if this._join_ttl:
				return
			else:
				sumx = sumy = 0
				for p in this._join_points:
					sumx += p[0]
					sumy += p[1]
				this._join_direction = self.towards(sumx/len(this._join_points), sumy/len(this._join_points))
				this._first_time = 0
		if not this._cached and len(this.me._killers) > 0:
			if this._first_time:
				for pos in this.resolve(this.me._killers, this.getCircle(len(this.me._killers), security_radius)):
					k = this.me.getKillerByName(pos[0].getName())
					k.setPosition(pos[1][0], pos[1][1])
				this._cached = 1
			else:
				x = Math.cos(this._join_direction*Math.PI/180) * security_radius
				y = Math.sin(this._join_direction*Math.PI/180) * security_radius
				for pos in this.resolve(this.me._killers, this.getHalfCircle(len(this.me._killers), security_radius, x, y)):
					k = this.me.getKillerByName(pos[0].getName())
					k.setPosition(pos[1][0], pos[1][1])
				this._cached = 1
		this.sendCache()
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:35,代码来源:TheBigOne.py

示例3: update_distances

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def update_distances():
    covered=self.getCoveredDistance()
    last_angle=mvt_mem.last_heading - deg_val(mvt_mem.direction)
    toterm("la"+str(last_angle)+"lh"+str(mvt_mem.last_heading)+"di"+str(deg_val(mvt_mem.direction)))
    ortho_increment=covered*Math.sin(last_angle)
    dist_increment=covered*Math.cos(last_angle)
    mvt_mem.valuable_distance += dist_increment
    mvt_mem.orthogonal_error += ortho_increment
开发者ID:peyotll,项目名称:warbot,代码行数:10,代码来源:SamMaxExplore.py

示例4: miseAJourMouvement

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def miseAJourMouvement():
	# Mouvement normal et mise a jour des coordonnees
	alpha = self.getHeading() * Math.PI / 180
	depl_x = 2*Math.cos(alpha)
	depl_y = 2*Math.sin(alpha)
	if not self.isMoving():
		self.randomHeading()
	else:
		coordonnees.setCoord(coordonnees.getX() + depl_x, coordonnees.getY() + depl_y)
开发者ID:peyotll,项目名称:warbot,代码行数:11,代码来源:BPVExplore.py

示例5: compute_heading

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [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))     
开发者ID:peyotll,项目名称:warbot,代码行数:44,代码来源:SamMaxExplore.py

示例6: getHalfCircle

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
	def getHalfCircle(this, num, radius, x, y):
		if num == 1:
			return [[x,y]]
		axe = self.towards(x, y)
		rayon = radius * (1 - Math.exp(-num/3))
		offset = Math.PI / (num-1)
		points = []
		for i in range(num):
			X = rayon*Math.cos(i*offset+Math.PI/2+axe*Math.PI/180)+x
			Y = rayon*Math.sin(i*offset+Math.PI/2+axe*Math.PI/180)+y
			points.append([X,Y])
		return points
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:14,代码来源:TheBigOne.py

示例7: getCircle

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
	def getCircle(this, num, radius):
		if num == 0: 
			return None
		if num == 1:
			return [[50,50]]
		rayon = radius * (1 - Math.exp(-num/3))
		offset = 2*Math.PI / num
		points = []
		for i in range(num):
			X = rayon*Math.cos(i*offset)
			Y = rayon*Math.sin(i*offset)
			points.append([X,Y])
		return points
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:15,代码来源:TheBigOne.py

示例8: skitter

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def skitter(_field):
	_maxangle = 2 * Math.PI
	_ordering = sortBy(_field)
	_increment = _maxangle / len(_ordering)
	_curangle = 0
	g.nodes[0].outdegree
	_maxdeg = outdegree.max + 1.0
	for _n in _ordering:
		_radius = 1 - Math.log((_n.outdegree + 1.0) / _maxdeg)
		_radius = _radius * 500.0
		_x = 500.0 + _radius * Math.cos(_curangle)
		_y = 500.0 + _radius * Math.sin(_curangle)
		_n.setX(_x)
		_n.setY(_y) 
		_curangle += _increment
开发者ID:cns-iu,项目名称:nwb,代码行数:17,代码来源:Main-applet.py

示例9: gene

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def gene(cible, p):
	taille = 12
	if p.getPerceptType() == "Home":
		taille = 20
	# Distance par rapport au tir
	angle = self.towards(cible.getX(), cible.getY())
	angle = Math.PI * angle / 180
	t = Math.tan(angle)
	s = Math.sin(angle)
	c = Math.cos(angle)
	
	dist_x = (  p.getX() + t* p.getY()) / (c + s * t)
	dist_y = -p.getY()/c + t * dist_x
	#print self.getAddress().getName() + " --> " + str(dist_x) + " --- " + str(dist_y)
	return abs(dist_y) < taille and dist_x > 0 and dist_x< cible.distanceTo(Point())
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:17,代码来源:BPVHomeKiller.py

示例10: eviteAmis

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [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

示例11: compute_heading

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def compute_heading (target, mode):
    # composantes X et Y du vecteur direction final
    X = Y = 0
    for it, dist in percepts.friends.items ():
        #               percept, dist, scale, theta, p
        X = X + vector_x (it, dist, 50, 60, 2)
        Y = Y + vector_y (it, dist, 50, 60, 2)
    for it, dist in percepts.bases.items ():
        # Les bases sont boguées : repère sur le coin
        # supérieur gauche
        X = X + bug_vector_x (it, dist, 60, 70, 2)
        Y = Y + bug_vector_y (it, dist, 60, 70, 2)
    for it, dist in percepts.attackers.items ():
        # devrait être négligeable...
        X = X + vector_x (it, dist, 30, 70, 2)
        Y = Y + vector_y (it, dist, 30, 70, 2)
    for it, dist in percepts.explorers.items ():
        X = X + vector_x (it, dist, 20, 60, 1)
        Y = Y + vector_y (it, dist, 20, 60, 1)
    for it, dist in percepts.homes.items ():
        X = X + bug_vector_x (it, dist, 60, 70, 2)
        Y = Y + bug_vector_y (it, dist, 60, 70, 2)
    for it, dist in percepts.obstacles.items ():
        radius = it.getRadius ()
        X = X + vector_x (it, dist, 50+radius, 60, 2)
        Y = Y + vector_y (it, dist, 50+radius, 60, 2)
        
    # pour la cible
    if mode == 'flee':
        offset = 180
        u = 12 # on s'arrache viiiiite !!
    else:
        offset = 0
        u = 8
    X = X + Math.cos (deg2pi (offset + self.towards (target.getX(), target.getY()))) * u * target.getDistance ()
    Y = Y + Math.sin (deg2pi (offset + self.towards (target.getX(), target.getY()))) * u * target.getDistance ()
    if immobile ():
        toterm ("immobile")
    self.setHeading (self.towards (X, Y))
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:41,代码来源:SamMaxHomekiller.py

示例12: isMasqued

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def isMasqued(x, y):
	# on ne tire pas si un #@! de copain se trouve devant (verification des percepts seulement ?)
	for p in self.getPercepts():
		if p.getTeam() == self.getTeam() and p.getPerceptType() != 'Rocket':
			if distance(p.getX(), p.getY()) > distance(x, y):
				continue
			a = self.towards(p.getX(), p.getY())*Math.PI/180
			b = self.towards(x, y)
			r = p.getRadius() + security_distance
			cos = Math.cos(a - Math.PI/2)
			sin = Math.sin(a - Math.PI/2)
			inf = self.towards(p.getX() + r*cos, p.getY() + r*sin)
			sup = self.towards(p.getX() - r*cos, p.getY() - r*sin)
			#~ d('ene: x: '+str(x)+' y: '+str(y)+' A: '+str(b)+' a: '+str(b*Math.PI/180))
			#~ d('     s: '+str(p.getX() + r*cos)+':'+str(p.getY() + r*sin)+' t: '+str(p.getX() - r*cos)+':'+str(p.getY() - r*sin))
			#~ d('ami: x: '+str(p.getX())+' y: '+str(p.getY())+' A: '+str(a*180/Math.PI)+' a: '+str(a)+' r: '+str(r))
			#~ d('ne pas tirer ene(A) entre '+str(inf)+' et '+str(sup))
			#~ d('angles relatifs: ami: '+str((sup - inf) % 360)+' enemy: '+str((b - inf) % 360 ))
			if ((b - inf) % 360 ) > ((sup - inf) % 360):
				#~ d('boom!')
				continue
			#~ d('un ami me cache la cible!')
			return 1
	return 0
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:26,代码来源:SmartKiller.py

示例13: doIt

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
def doIt():
	mem.t += 1
	if mem.iMove:
	  if not self.isMoving():
	    self.setHeading(mem.go())
	  else:
	    # Calcul de la nouvelle position
	    mem.origin.x += Math.cos(self.getHeading()*Math.PI/180)*2
	    mem.origin.y += Math.sin(self.getHeading()*Math.PI/180)*2
	    #if mem.t % 15 == 0:
	      #print len(mem.buts),mem.origin.str(),'->',mem.current.str()
	mem.iMove = 0

	# Latence de tir
	if mem.wait>=0:
	  mem.wait = mem.wait - 1

	# Lecture des messages
	if not self.isMessageBoxEmpty():
	  while not self.isMessageBoxEmpty():
	    mem.message(self.readMessage())
	  if mem.fuite == 0:
	    mem.newBut()

	percepts = self.getPercepts()
	c = 1 # Coequipiers - Ennemis (rockerLauncher)
	pmin = primin = 0 # Objectif et sa valeur
	aurax = auray = 0 # Vecteurs d'evitement des mechants
	auraxt = aurayt = 0 # Vecteurs d'evitement des gentils (team)
	for p in percepts:
	  pri = 0 # Interet du percept courant
	  d = self.distanceTo(p)+0.0001
	  t = p.getPerceptType()
	  if p.getTeam()!=self.getTeam():
	    if t=='Home':
	      mem.send(p)
	      pri=1
	      if d < 80:
		aurax += p.getX()/d
		auray += p.getY()/d
	    elif t=='RocketLauncher':
	      mem.send(p)
	      pri=4
	      c -= 1
	      if d < 70 or mem.fuite > 0:
		aurax += p.getX()/d
		auray += p.getY()/d
	    elif t=='Explorer':
	      mem.send(p)
	      pri=3
	      if d < 70:
		aurax += p.getX()/d
		auray += p.getY()/d
	    elif t=='Food':
	      pri=2
	    # Mise a jour de l'objectif en fonction de la priorite et de son energie
	    if pri>0 and (pri>primin or (pri==primin and p.getEnergy() < pmin.getEnergy())):
	      pmin=p
	      primin=pri
	  else:
	    if d < 70:
	      auraxt += p.getX()/d *(70-d)/120
	      aurayt += p.getY()/d *(70-d)/120
	    if t=='RocketLauncher':
	      c += 1

	# Si pas d'objectif
	if pmin == 0:
	  mem.pbak = mem.priminbak = 0
	  # Si but atteind
	  if mem.current.x != 'abs' and mem.current.dist(mem.origin) < 70:
	    self.broadcast(groupName,"launcher","Next",str(mem.current.x-mem.origin.x),str(mem.current.y-mem.origin.y))
	    print "but ok ", mem.current.str()
	elif primin==2: #food (non teste)
	  mem.priminbak = primin
	  d = self.distanceTo(pmin)+0.0001
	  if d<2:     #if close enough
	    self.eat(pmin)			    #eat it
	    return
	  else: 						  #else go towards it
	    self.setHeading(self.towards(pmin.getX(),pmin.getY()))
	    self.move()
	    return
	else: # Tir sur auelaue chose
	  x = pmin.getX()
	  y = pmin.getY()
	  # Inference de tir (ou prediction a la louche)
	  if primin == mem.priminbak:
	    xx = x - mem.pbak.getX()
	    yy = y - mem.pbak.getY()
	    if xx*xx+yy*yy <= 50:
	      d = self.distanceTo(pmin)/25+0.0001
	      if primin == 4:
		d /= 4
	      x += xx*d*d
	      y += yy*d*d
	  mem.pbak = pmin
	  mem.priminbak = primin
	  if mem.wait<=0 and mem.fuite==0:
#	     self.broadcast(groupName,"launcher","Help",str(x),str(y))
#.........这里部分代码省略.........
开发者ID:hasanzorlu,项目名称:kalle-martin-group,代码行数:103,代码来源:PrivatHomekiller.py

示例14: setTrajectoire

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [as 别名]
	def setTrajectoire(this):
		if this._explore:
			if not self.isMoving() or self.getHeading() == 0:
				self.randomHeading()
			return
		decalx = decaly = 0
		for p in self.getPercepts():
			type = p.getPerceptType()
			dist = p.getDistance()
			if dist < redirect_distance and p.getTeam() == self.getTeam() and (type == 'Home' or type == 'RocketLauncher' or type == 'Explorer'):
				decalx += p.getX() / dist * (70-dist) / 120
				decaly += p.getY() / dist * (70-dist) / 120
				#~ d('distance: '+str(dist))
		#~ d('direction originelle: '+str(self.towards(this._destX, this._destY)))
		#~ d('direction modifiee: '+str(self.towards(Math.cos(self.towards(this._destX, this._destY))-decalx, Math.sin(self.towards(this._destX, this._destY))-decaly)))
		self.setHeading(self.towards(Math.cos(self.towards(this._destX, this._destY)*Math.PI/180)-decalx, Math.sin(self.towards(this._destX, this._destY)*Math.PI/180)-decaly))
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:18,代码来源:SmartKiller.py

示例15: vector_y

# 需要导入模块: from java.lang import Math [as 别名]
# 或者: from java.lang.Math import sin [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)
开发者ID:Ooya,项目名称:Robot-Sapiens,代码行数:4,代码来源:SamMaxHomekiller.py


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