Esempio n. 1
0
File: shape.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)

		#半径
		self.radius = kwargs['radius']

		#角度
		self.angle = kwargs.get('angle', 90.0)

		#圆心
		self.center = (0, 0)

		x = Geometry.sin(self.angle / 2) * self.radius
		y = Geometry.cos(self.angle / 2) * self.radius

		self.source = x, y
		self.target = -x, y

		#外切圆心,外切半径
		if self.angle < 90: #三点求圆
			self.wrap_center = Geometry.circle_center(self.source, self.target, self.center)
			self.wrap_radius = Geometry.distance(self.wrap_center, self.center)
		elif self.angle < 180: #两侧点中点
			self.wrap_center = (0, y)
			self.wrap_radius = x
		else: #所在的圆
			self.wrap_center = self.center
			self.wrap_radius = self.radius
Esempio n. 2
0
File: route.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)

		#起始朝向
		self.toward = kwargs.get('toward', self.rotate)

		#轨迹包含的线段
		self.compose = kwargs['compose']

		#角速度,每个时间片旋转的角度
		self.velocity = kwargs.get('velocity', 20.0)

		#剩余角度
		self.residual = 0.0
Esempio n. 3
0
File: shape.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)

		#宽度
		self.width = kwargs['width']

		#高度
		self.height = kwargs['height']

		#包络圆心
		self.wrap_center = (0, self.height / 2)

		#包络半径
		self.wrap_radius = Geometry.distance(self.wrap_center, (self.width / 2, 0))
Esempio n. 4
0
File: route.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)
		Motion.__init__(self, **kwargs)

		#长度
		self.length = kwargs['length']

		#源点
		self.source = (0, 0)

		#目标点
		self.target = (0, self.length)

		#距离
		self.distance = self.length
Esempio n. 5
0
File: shape.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)

		#形状组成,由扇形和矩形组成
		self.compose = kwargs.get('compose', [])
		
		#快速计算范围,不精确
		sx = sy = 0.0
		for shape in self.compose:
			x, y = shape.wrap_center
			sx += x
			sy += y
		sx /= len(self.compose)
		sy /= len(self.compose)
			
		self.wrap_center = (sx, sy)
		self.wrap_radius = sum(map(lambda x: x.wrap_radius, self.compose))
Esempio n. 6
0
File: route.py Progetto: zx013/other
	def __init__(self, **kwargs):
		Coordinate.__init__(self, **kwargs)
		Motion.__init__(self, **kwargs)

		#长度
		self.length = kwargs['length']

		middle = kwargs['middle']
		#中间点,middle=0为圆
		self.middle = (middle, self.length / 2)

		#源点
		self.source = (0, 0)

		#目标点
		if middle:
			self.target = (0, self.length)
		else:
			self.target = self.source

		#圆弧的圆心
		if middle:
			self.center = Geometry.circle_center(self.source, self.target, self.middle)
		else:
			self.center = self.middle

		#半径
		self.radius = Geometry.distance(self.source, self.center)

		#角度
		center_x, center_y = self.center

		if middle > 0:
			self.angle = 360 - 2 * Geometry.acos(center_x / self.radius)
		elif middle < 0:
			self.angle = 2 * Geometry.acos(center_x / self.radius)
		else:
			self.angle = 360

		#距离
		self.distance = Geometry.radian(self.angle) * self.radius

		#上一个点
		self.last_step = self.source