16 lines
622 B
Python
16 lines
622 B
Python
# A simulation of a solar system, with a sun and three planets.
|
|
# Gravity is the only force acting on the system.
|
|
|
|
from simulation import Simulation
|
|
from simulation.ball import Ball
|
|
from geometry.point import Point
|
|
from geometry.vector import Vector
|
|
|
|
sun = Ball(Point(), mass=100000, radius=20, color="yellow")
|
|
a = Ball(Point((100, 0)), velocity=Vector((0, 14)), mass=1, radius=10, color="blue")
|
|
b = Ball(Point((-80, 0)), velocity=Vector((0, -14)), mass=1, radius=10, color="red")
|
|
c = Ball(Point((0, 200)), velocity=Vector((-5, 0)), mass=2, radius=10, color="green")
|
|
|
|
sim = Simulation([sun, a, b, c], g=0.2)
|
|
sim.run(1000)
|