Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Gravitational force between multiple bodies with linear momentum conservation

Author
Message
Proteus
22
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 22nd Aug 2004 07:39
There's goes something I enjoyed coding:

+Simulates Gravitational or Eletromagnetic forcefields


Reference:
It's just
http://scienceworld.wolfram.com/physics/Gravity.html
or
http://scienceworld.wolfram.com/physics/CoulombsLaw.html

The linear momentum conservation is kind of crappy cause the "bodies" perform perfectlly inelastic collision (they merge with each other uppon crashing)




As you've probably seen the comments are in portuguese, if you feel like you need them to understand the code just ask me and i'll find some time to translate'em...

DarkSin
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: Under your bed
Posted: 22nd Aug 2004 10:23
Sent yea an email. Very awsome!


Proteus
22
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 23rd Aug 2004 00:59
Thanks for the feedback
Just downloaded the code into my pda, I'm going to translate it "on the go" might as well add a few more info about the physics of it

Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 23rd Aug 2004 05:37
Very nice bit of physics modelling, Proteus. One thing I can't figure out though, is how to set up the program to make an indefinite number of moons. I noticed that you've already put the code there, but 'remmed out' - so I unremmed it, and although it creates lots of moons, there doesn't seem to be any gravity anymore - they all just move in straight lines! What am I doing wrong?
Proteus
22
Years of Service
User Offline
Joined: 4th Oct 2002
Location: The Future
Posted: 23rd Aug 2004 06:56 Edited at: 23rd Aug 2004 08:19
This should make things better...
+I've Translated the comments to english
+There are still some problems with the random generator, but it's working much better now





EDITED: fixed a few things

EDITED: As you might have noticed mass does attract mass and this has some interesting effects depending on the initial state of the system

Generator 1


Solar System Example:
A much more familiar picture of gravitation you can see by adding a small number(only one here) of HEAVY bodies



Now it's your turn, post your cool system configuration

Login to post a reply

Server time is: 2024-11-23 19:57:49
Your offset time is: 2024-11-23 19:57:49