Exemple #1
0
    def __init__(self, semi_major_axis, ecc, radius, period, t_0, name,
                 tilt_angle, node_angle, ecc_angle):
        """Constructor

        The constructor receives the planet attributes and sets its position
        at the perihelium (whose date is given by t_0 and should be the first
        perihelium after 31st December, 1899).

        Args:
            semi_major_axis: Longitude of the semi-major axis of the planet
                orbit.
            ecc: Eccentricity of the elliptical planet orbit; a float in ]0,1[
            radius: Radius of the planet, for visual purposes only.
            period: Period of the planet, measured in days.
            t_0: Date in which the first perihelium after 31st December, 1899
                was reached.
            name: Name of the planet, for visual purposes only.
        """
        self.semi_major_axis = semi_major_axis
        self.eccentricity = ecc
        self.radius = radius
        self.period = period
        self.t0 = t_0
        self.name = name

        self.tilt_angle = math.pi*tilt_angle/180
        self.node_angle = math.pi*node_angle/180
        self.ecc_angle = math.pi*(ecc_angle-node_angle)/180

        self.setPos(self.t0)

        # Ball constructor, for visual purposes only
        Ball.__init__(self, steel_red, self.radius, self.GUIcoord)
    def __init__(self, coord=[0.0,0.0], vel=[0.0,0.0], b_type=BBallType.whitey, color=steel_red):
        self.vel = [vel[0], 0.0, vel[1]]
        self.type = b_type

        self.frame_tick = 0
        self.highlighted = False

        self.first_radius = self.radius = BALL_RADIUS

        if self.type == BBallType.whitey:
            self.first_radius = self.radius = BALL_RADIUS*0.9
            color = steel_white
        elif self.type == BBallType.black:
            color = black

        self.coord = [coord[0], BALL_RADIUS, coord[1]]

        Ball.__init__(self, color, self.radius, self.coord)
Exemple #3
0
    def draw(self):
        """Draws the planet and its orbit

        OpenGL-only function. Override the Ball draw function, as the orbit
        also has to be drawn.
        """
        # Draws orbit
        glColor3f(*steel_blue)
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
        glBegin(GL_POLYGON)

        time = 0
        while time <= self.period:
            pos, _ = self.getPos(time)
            coords = self.getGUICoords(pos)
            glVertex3f(*coords)
            time += self.period / 50

        glEnd()

        # Draws the planet
        Ball.draw(self)