def rotate(self): v = (self.start[0]-self.end[0],self.start[1]-self.end[1]) angle = get_angle(v) + self.rad center = ((self.start[0] + self.end[0])/2.0, (self.start[1] + self.end[1])/2.0) temp = hanshu.vector_length(v)/2.0 self.start = (center[0]+temp*math.cos(angle),center[1] - temp * math.sin(angle)) self.end = (center[0]-temp*math.cos(angle),center[1] + temp * math.sin(angle))
def get_angle(x): a = hanshu.vector_length(x) return -1*math.acos(math.fabs(x[0])/a) if x[1]*x[0]>=0 else math.acos(math.fabs(x[0])/a)