Skip to main content

A python module for simulating planets trajectories in 2D.

Project description

#gravipython

README.md

This python module is a basic module that can be used for small simulations.

v 0.0.5


class SolarSystem(width, height, **kwargs):

**kwargs

  • collisions=True (Set this to False if you want to deactivate collisions)

Used to create a solar system to add stars in your simulation.

SolarSystem.main(): Method that does all the work, don't forget otherwise nothing is going to appear.

  • Click on A to spawn an asteroid of 0.000001 solar masses.
  • Click on D to spawn a red dwarf of 0.35 solar masses.
  • Click on B to spawn a brown dwarf of 0.07 solar masses.
  • Click on S to spawn a star of 1 solar mass.
  • Click on P to spawn a planet of 0.0001 solar masses.
  • Click on M to spawn a moon of 0.00001 solar masses.
  • Click on C to spawn a comet of 0.000001 solar masses.
  • Click on W to spawn a white dwarf of 0.9 solar masses.
  • Click on R to reset and remove all stars from the screen.

class SolarSystemBody(solar_system, mass, position=(0, 0), velocity=(0, 0), color=(255, 255, 255)) This class allows you to create your own stars. From this class are created the classes :

  • Sun
  • RedDwarf
  • BrownDwarf
  • Asteroid
  • Planet
  • Moon
  • Comet
  • WhiteDwarf
    Each of these classes can be instantiated with the same parameters as SolarSystemBody, except that they have a default value for the mass and a
    different one for the color.


###Official examples :

#####Simple system :

import gravipython as gp   
# v 0.0.3 and before, use 'import gravitypython as gp'


ss = gp.SolarSystem(width=500, height=500, collisions=True)
# collisions is set by default to True

planet1 = gp.Planet(ss, mass=1, position=(0, 70), velocity=(5, 0), color=(0, 0, 255))
# color for planets is by default set to (0, 0, 255)
sun = gp.Sun(ss, mass=10000, position=(0, 0))
# you could use just sun = gp.Sun() because every arguments are set by default

ss.main() # runs the simulation

#####Binary system :

import gravipython as gp  

ss = gp.SolarSystem(500, 500)

sun1 = gp.Sun(ss, mass=10000, position=(-20, 0), velocity=(0, 5))
sun2 = gp.Sun(ss, mass=10000, position=(20, 0), velocity=(0, -5))

ss.main()


###Credits A part of this code has been made thanks to Stephen Gruppetta on ThePythonCodingBook



If you found any error, bug, or idea, you can send it by mail at latomateultime@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gravipython-0.0.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gravipython-0.0.5-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file gravipython-0.0.5.tar.gz.

File metadata

  • Download URL: gravipython-0.0.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for gravipython-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8b8abecbb1c44de87eff6d13185be613ded6472c671d815cc7d814ec203be8f0
MD5 16425a7fb76784bfe0d064c8aeb3b4c3
BLAKE2b-256 da0d4306264e5b0e7fe70b954050b46b0a1eaa831a0f14d71bad28af213e45ec

See more details on using hashes here.

File details

Details for the file gravipython-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: gravipython-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for gravipython-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e8ec2668a4c150f6362cbaeee3946e7026f7a6e22803feeaf0523e69e2eaf63d
MD5 da03d64e395c98fc1a9cbf4201a01fd9
BLAKE2b-256 c5a2b60e86cd9afd42a605d89b4c1a4929ce9fb69cad567b04af5a68a508c046

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page