Easy to use environment allowing to place physic bodies in space and watch how they behave.
You can use our pre-defined objects like earth or sun.
Simulations become much more interesting after placing bigger number of objects. Our simulator provides you tools for placing many objects at the samte time.
This project requires Python 3
with Panda3d
, scipy
and numpy
.
Clone this repo on your local machine and go into project folder:
git clone https://github.com/FranciszekPin/gravity-field-simulator.git
cd gravity-field-simulator
To see default simulation run:
python3 GameManager.py
You should see few planets orbiting the sun:
In BallsManager.py
there is a function add_balls_to_render(self)
.
Inside this function you can define which planets will appear in simulation.
There are two functions that can be used:
First function adds one planet with given mass and velocity on given position:
add_ball(self, position, velocity, static, mass, planet_name)
where
position - starting position of planet in numpy.array([x, y, z])
velocity - starting velocity of planet in numpy.array([x, y, z])
static - if True, planet won't move, usually should be set to False
mass - single number standing for plaet mass
planet_name - sets planet texture with according name, the possible values are: "earth", "mercury", "mars", "moon"
For example:
self.add_ball(numpy.array([0., 0., 0.]), numpy.array([0, 0.0, 0.0]), False, 333000, "sun")
Adds physic body with sun texture on position with coordinates [0, 0, 0], velocity vector [0, 0, 0], not static, with mass 333000 Kg
It is possible to place multiple planets at the same time.
Function add_planet_square()
makes "square" of planets specified by position, border size and distance between neighboring planets
add_planet_square(self, position, size, distance_between_planets)
For example:
self.add_planet_square(numpy.array([0., 0., 100]), 40, 10)
Places square of planets with border 40, position [0, 0, 100] and distance between planets equal to 10