本文整理汇总了Python中Point.Point.x方法的典型用法代码示例。如果您正苦于以下问题:Python Point.x方法的具体用法?Python Point.x怎么用?Python Point.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point.Point
的用法示例。
在下文中一共展示了Point.x方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calcMotionEnergy
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import x [as 别名]
def calcMotionEnergy(self):
n = len(self.points)
l = 3
speed = []
for i in range(0,n-l-1):
a,b = self.points[i].getCoords()
dx = dy = 0
for j in range(l):
index = i+j+1
c,d = self.points[i+l+1].getCoords()
dx = dx + c - a
dy = dy + d - b
dx = dx/l
dy = dy/l
d = Point(dx, dy)
speed.append(d)
n = len(speed)
if n == 0:
return 0
e = Point(0, 0)
mx = my = 0
for i in range(0,n):
a,b = speed[i].getCoords()
mx = mx + a
my = my + b
mx = mx/n
my = my/n
for i in range(0,n):
a,b = speed[i].getCoords()
dx = mx - a
dy = my - b
dx2 = dx*dx
dy2 = dy*dy
e.x = e.x + dx2
e.y = e.y + dy2
print(str(n-1))
e.x = e.x/(n-1)
e.y = e.y/(n-1)
return e.length()
示例2: isBallInFrontOfRobot
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import x [as 别名]
def isBallInFrontOfRobot(robotState,ball,param_x = .5, param_y = .04, behind_x = 0):
refPoint = Point(ball.x-robotState.x,ball.y - robotState.y)
if refPoint.x < 0:
if abs(refPoint.x) < behind_x:
print "behind ball %.2f m but still rushing" %(abs(refPoint.x))
refPoint.x = -refPoint.x
else:
print "ball is too far behind, stopping rush"
return False
#print "refence from robot: %f, %f" % (refPoint.x,refPoint.y)
#print "angle: %f" % robotState.theta
rotatedPoint = MotionSkills.rotatePointByAngle(refPoint, robotState.theta)
#print "rotatedPoint to robot frame: %f, %f" % (rotatedPoint.x,rotatedPoint.y)
angleToGoal = MotionSkills.angleBetweenPoints(robotState, HOME_GOAL)
angleDiff = abs(angleToGoal-robotState.theta)
if angleDiff > math.pi:
angleDiff = (2*math.pi - angleDiff)
#print 'angle difference: %d' %((angleDiff/math.pi)*180)
if rotatedPoint.x > 0 and rotatedPoint.x < param_x and rotatedPoint.y < param_y and rotatedPoint.y > -param_y:
#print "Behind Ball!"
if angleDiff < 0.15:
#print "Angled toward Goal"
return True
print "Not angled to goal!"
return False
print "Not Behind Ball!"
return False
示例3: center
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import x [as 别名]
def center(points):
center_point = Point(0,0,0)
for point in points:
center_point.x += point.x
center_point.y += point.y
center_point.x = center_point.x/float(len(points))
center_point.y = center_point.y/float(len(points))
return center_point
示例4: position_at
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import x [as 别名]
def position_at(self, time):
dt = time - self.src_time
if dt > 0.0 and self.total_time > 0.0:
ratio = dt / self.total_time
p = Point()
p.x = self.src.x + self.dx * ratio
p.y = self.src.y + self.dy * ratio
return p
else:
return self.src
示例5: Point
# 需要导入模块: from Point import Point [as 别名]
# 或者: from Point.Point import x [as 别名]
from subscriber.msg import FieldPositions
from subscriber.srv import *
from Point import Point
from velchange import *
import math
from numpy import matrix
import signal
import sys
# from roboclaw import *
start_time = 1
centerField = Point()
goal = Point()
#hardcoded if vision is untrustworthy
centerField.x = 423
centerField.y = 234
goal.x = 0
goal.y = 234
defensex = 50
globalCounter = 0
dbehind = 20
yNorthThreshold = -30
ySouthThreshold = 15
yNorthOffset = -16
ySouthOffset = 18
goalYOffset = -12
fastMaxSpeed = .9
slowMaxSpeed = .3
maxSpeed = fastMaxSpeed