예제 #1
0
 def rotate(self,angle=pi,point=[0,0]):
     """Rotate the point using the angle and the center of rotation.
     Uses the origin for the center of rotation by default."""
     v=Vector(self.x-point[0],self.y-point[1])
     v.rotate(angle)
     new_point=v(point)
     self.x,self.y=new_point
예제 #2
0
 def rotate(self,angle,C=None):
     """Rotate the form by rotating its points from the center of rotation.
     Use center of the shape as default center of rotation.""" #Actually not working
     if not C:
         C=self.center()
     for i in range(len(self.points)):
         P=self.points[i]
         v=Vector(P.x-C.x,P.y-C.y)
         v.rotate(angle)
         self.points[i]=v(C)
예제 #3
0
    points = [p1, p3, p2, p4]
    f = Form([
        Point(random.randint(-10, 10), random.randint(-10, 10))
        for i in range(10)
    ])
    #f.show(window)
    f2 = f.getSparse()
    p1.show(window)
    p2.show(window)
    v1 = Vector(p2[0] - p1[0], p2[1] - p1[1], color=(255, 0, 0))

    while window.open:
        window.check()
        window.clear()
        window.draw.control()
        v1.rotate(0.1)
        v2 = v1 % (pi / 2)
        v2.color = GREEN
        v2.rotate(0.1)
        f2.rotate(0.1)
        center = f2.center()
        center.color = BLUE
        #center.radius=0.1
        A = v1(center)
        window.draw.show()
        center.show(window)
        v1.show(center, window)
        v2.show(A, window)
        f2.show(window)
        window.flip()
    #Segment(f[0],f[1],color=(255,0,0)).center().show(window)