Пример #1
0
 def rotate(self, angle=math.pi, center=Point.origin()):
     """Rotate the point using an angle and the point of rotation."""
     self.abstract.rotate(angle, center)
     point = self.abstract
     point.rotate(angle, center)
     vector = Vector.createFromPoint(point)
     self.motion.setPosition(vector)
Пример #2
0
 def shoot(self,context):
     """Return a missile."""
     #logging.warning("This function is only a test and should not be included in the body class but in a child class instead.""")
     keys=context.press()
     point=Point(*context.point())
     if keys[K_SPACE]:
         center=Point(*self.position)
         direction=Vector.createFromTwoPoints(center,point)
         direction.norm=2
         origin=Point.origin()
         form=Segment(origin,direction(origin))
         position=copy.deepcopy(self.position+direction(origin))
         velocity=direction+copy.deepcopy(self.velocity)
         return Missile(form,position,velocity)
Пример #3
0
        # This function should be able to determine which proportion of the object is contained in the force
        # field in order to apply some of the force
        pass

    def exert(self, body):
        """Exert the force of the force field to the object."""
        pass


down = Vector([0, -1])
gravity = Force(0, -9.81, color=mycolors.RED)

if __name__ == "__main__":
    zero = Vector([0, 0])
    propulsion = Force(0, 0)
    o = Point.origin()

    random_force = Force.random()
    # print(random_force)
    random_force += gravity
    # print(random_force)

    result = Force.sum([gravity, propulsion, random_force])
    # print("Force.sum:",result)

    x, y = result
    # print(x,y) #Unpacking is compatible for vectors

    f = gravity
    print(result)
Пример #4
0
 def delPosition(self):
     """Set the position of the material form to the origin."""
     self.setCenter(Point.origin())
Пример #5
0
 def delCenter(self):
     """Set the center to the origin."""
     self.setCenter(Point.origin())
Пример #6
0
 def rotate(self, angle=math.pi, center=Point.origin()):
     """Rotate the form by rotating its points."""
     for point in self.points:
         point.rotate(angle, center)