Example #1
0
 def random(corners=[-1, -1, 1, 1], n=5):
     """Create a random body."""
     form = Form.random(corners, n)
     motion = Motion.random(n=2, d=3)
     moment = Motion.random(n=2, d=3)
     print(motion.acceleration)
     return Body(form, motion, moment)
 def random(cls, n=5, size=5, life_factor=1 / 10, **kwargs):
     """Create a random asteroid."""
     a = FormAnatomy.random(n)
     mt = Motion.random(n=2, d=2)
     mm = Moment.random(n=2, d=1)
     a.enlarge(size)
     return cls(a, [mt, mm],
                alive=True,
                max_life=a.area * life_factor,
                **kwargs)
Example #3
0
 def random(min=-1,max=1):
     """Create a random material point using optional minimum and maximum."""
     motion=Motion.random()
     return MaterialPoint(motion)
Example #4
0
            if self.iterator==0: value=self.motion.getPosition()[0]
            if self.iterator==1: value=self.motion.getPosition()[1]
            self.iterator+=1
            return value
        else:
            raise StopIteration

    def __str__(self):
        """Return the string representation of a point."""
        return "Point:"+str(self.__dict__)

    __repr__=__str__



FallingPoint=lambda :MaterialPoint(Motion.random(),[myforce.gravity])

if __name__=="__main__":
    #Only used for testing
    from mysurface import Surface
    surface=Surface()
    points=[MaterialPoint.random() for i in range(5)]
    while surface.open:
        surface.check()
        surface.clear()
        surface.control()
        surface.show()
        for point in points:
            surface.print(str(point),tuple(point))
            point.show(surface)
            point.showMotion(surface)
Example #5
0
 def random(cls, **kwargs):
     """Return a random perlin asteroid entity."""
     p = PerlinAsteroidAnatomy.random()
     m1 = Motion.random(n=2)
     m2 = Moment.random(d=1, n=2)
     return cls(p, m1, m2, **kwargs)
Example #6
0
 def random(cls, n=50, **kwargs):
     """Create a quadtree of 'n' points."""
     motions = [Motion.random(n=2) for i in range(n)]
     return cls(motions, **kwargs)
 def spread(self, n=10):
     """Spread randomly the entities."""
     for entity in self.entities.values():
         entity.motion = n * Motion.random()
Example #8
0
 def random(cls, **kwargs):
     """Create a random bezier asteroid."""
     a = BezierForm.random(**kwargs)
     mt = Motion.random(n=2, d=2)
     mm = Moment.random(n=2, d=1)
     return cls(a, mt, mm)
 def random(cls, **kwargs):
     """Create a shooter with a Shoot, TriangleAnatomy, and motion"""
     shoot = Shoot(SegmentMissile)
     anatomy = TriangleAnatomy()
     motion = Motion.random(n=3, d=2)
     return cls(anatomy, [motion], shoot)
Example #10
0
 def random(cls, n=2, nm=2, d=2):
     """Create n random physical objects."""
     return cls([Motion.random(n=nm, d=d) for i in range(n)])
Example #11
0
 def random(cls, **kwargs):
     """Create random motions for the spider base."""
     motion = Motion.random(n=2, d=2)
     moment = Moment.random(n=2, d=1)
     return cls(motion, moment, **kwargs)
Example #12
0
 def random(cls, **kwargs):
     anatomy = TriangleAnatomy()
     motion = Motion.random(n=3, d=2)
     shoot = Shoot(SegmentMissile)
     return cls(anatomy, motion, shoot, **kwargs)
Example #13
0
 def random(cls, **kwargs):
     """Create a random spaceship."""
     motion = Motion.random(n=3, d=2)
     anatomy = FormAnatomy.random()
     return cls(anatomy, [motion], **kwargs)
Example #14
0
 def random(corners=[-1, -1, 1, 1], **kwargs):
     """Create a random material point using optional minimum and maximum."""
     motion = Motion.random(corners)
     return MaterialPoint(motion, **kwargs)
Example #15
0
 def random(cls, nm=1, nv=2, d=2):
     """Create a random asteroid."""
     anatomy = Asteroid(color=mycolors.random(), conversion=False, radius=5)
     motions = [Motion.random(n=nv, d=d) for im in range(nm)]
     return cls(anatomy, motions)
Example #16
0
 def random(cls, **kwargs):
     """Create a random particle using its motions' dimensions."""
     return cls([Motion.random(n=3, d=2), Motion.random(n=2, d=1)], **kwargs)
Example #17
0
 def random(cls):
     """Create a segment missile with a random motion."""
     motion = Motion.random()
     segment = SegmentAnatomy.createFromTuples((-0.5, 0), (0.5, 0))
     return cls(segment, [motion])