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
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