Esempio n. 1
0
    def add_satellite(self, body_name, vi, s_name, r, m, target, d=0):
        """
        Adds a satellite to the system a distance from the surface of a specific body

        body_name: name of body the satellite starts at
        vi: velocity of satellite
        s_name: name of satellite
        r: radius of satellite
        m: mass of satellite
        target: name of body satellite is aiming for
        d: extra added distance from body, use when adding more than one satellite to body
        """

        #Loops over bodies selecting the specified starting body
        for body in self.bodies:
            if body.name == body_name:
                #Creates a new satellite with the given parameters
                s = Satellite(s_name, 'green', m, r,
                              body.d - 2 * body.radius - d, vi, target)

                #Calculates initial acceleration of satellite
                s.get_init_accn(self.bodies)

                #Adds satellite to system bodies and a circle to the patches for animation
                self.bodies.append(s)
                self.patches.append(
                    plt.Circle(s.r / const.PixelToKM / const.DistScaleFactor,
                               radius=s.radius / const.PixelToKM *
                               const.SatelliteScaleFactor,
                               color=s.c,
                               animated=True))

                #Increment satellite couint and then break
                self.satellite_count += 1
                break