Giter Site home page Giter Site logo

inhahe / 2dgrav Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 49 KB

Simulates gravity in space (2d, 3d, or higher). Versions included for C++, QB, and Python (the C++ and QB ones only do 2d.)

License: MIT License

C++ 29.34% Python 3.47% BASIC 67.19%

2dgrav's Introduction

Simulates gravitational interactions among circles in space. Includes versions written in C++, QuickBasic, and Python. Some of them have unique features that can create artistic-looking graphics, such as the ability to draw lines connecting every possible pair of objects, with or without erasing behind themselves as they change position. These things are controlled through hot-keys.

I think I never figured out how to get one of the features in the C++ version working or why it wouldn't work.

The QB and C++ versions are 2D. The Python version can handle any arbitrary number of dimensions (provided you code a way to display it, I've decoupled that from the gravitational calculations), but is currently set to calculate in 3 dimensions and display in 2.

There are multiple versions of the program included for the QB version, because I don't know which one is supposed to be the latest or best or which ones are experimental or what (I coded the QB versions probably back in the 90's..).

I did some really interesting graphical things using the Python version, such as separating the screen into tiles that could be either colored or not colored depending on whether an object is--or maybe how many are--within a tile's area at the time. I think I also did some 5D stuff and experimented with different ways of displaying the 5 different position variables. I lost that version. =/

I also wrote one in Python, or a version of the Python one included, that shades the objects as spheres, and can actually display objects' depths in 3D interactions with the use of red and green 3D glasses. I seem to have lost that one too. =/ I think there may be the code to display for 3D glasses, but not as spheres, commented out in 3dgrav.py.

In addition to the problems with the Python version mentioned in the source, a couple of other problems are: 1) you can't close the pygame window, and 2) for some reason it actually speeds up when you move the mouse around over the pygame window, so I guess something's not being done as efficiently as it could be done there.

Fixing the latter problem may involve allowing it to calculate position updates multiple times per screen update and maybe also modifying the gravitational constant and average initial inertias accordingly (this being how you do more or fewer position calculations per second while retaining visible simulation speed, or vice versa).

2dgrav's People

Contributors

inhahe avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.