Planetorium

Community Forums/Showcase/Planetorium

Lukasha(Posted 2006) [#1]
Hi,

here is a small new BlitzMax-program.
It simulates gravity between many "planets"!
Because the code is very messy, I don't explain the details in this text, but if you have questions I'd like to answer them.

Now information you gonna need.At the top of the code are a few variables which you can change in the code:

- anzahl = change "anzahl" to set the number of planets

- ausgleich = "ausgleich" is a factor which influences the speed of the planets

-weite = "weite" sets how big the area is in which the planets can move

-zufweite = sets how big the area is in which the planets are created

-gu = sets how big the planets can be when they are created

These factors are in the program code as it is now very high. You can chose them however you like. Please try out!

The control also is quite easy:

- SPACE: Shows the direction of every planet
- "g": Shows the biggest gravity-connections
- "a": Zoom out
- "s": Zoom in
- "Cursor-Keys: Move camera"

I hope you'll enjoy the program:



PS: With this setting you have to zoom in a lot at the beginning!!

Feedback is welcome,
Lukas


Amon(Posted 2006) [#2]
I liked it. :)


Booticus(Posted 2007) [#3]
Hey Lukas that's pretty great! I've always liked gravity simulation planet stuff!!


Lukasha(Posted 2007) [#4]
Thank you guys,

if you have ideas how to improve it and it is not too difficult ;-), tell it to me!

Lukas


Lukasha(Posted 2007) [#5]
Here is another version with the controls at the top of the screen. It think this will be easier to control!



Have fun with it!

Lukas


Steffenk(Posted 2007) [#6]
Interesting indeed. The physics are quite bad, though. The speed of a sphere after a collision should be rather the mass-weighted speed of the two spheres which fusioned and not whatever it's now.

Maybe like this:
planetxs[xx3] = (planetxs[xx3] * planetg[xx3] + planetxs[yy3] * planetg[yy3]) / ( planetg[xx3] + planetg[yy3])
planetys[xx3] = (planetys[xx3] * planetg[xx3] + planetys[yy3] * planetg[yy3]) / ( planetg[xx3] + planetg[yy3])

Of course this would have to be done after calculating the new mass.
I've done something similar before and the real challenge turned out to be creating a scenario with complex systems. Even for 3 bodies (sun-earth-moon for example) this is quite difficult and it's even more with several planets and moons at once.

With your current code 3-4 somewhat larger bodies emerge but everything dissolves after a (long) while but satellites form only very rarely. With my correction there happens what would be expected: Every piece of mass accumulates in one huge sphere, which would be the star of a planetary system. An interesting idea would be to give the bodies some kind of starting impulse, maybe orthogonal to a common central point. That would be at least a little more realistic.


Lukasha(Posted 2007) [#7]
Hi Steffenk,

thank you for your very useful tips!
Did you change anything else but the speed after a collision?
I know that the physics are very bad, but I don't have the knowledge about that.
Perhaps you could take a look 165-183, where the change in speed is calculated --> It's definitely wrong!
It's also not correct because my program only looks on which side the other planet is and moves there ( not with Sin,Cos)--> This also makes it unexact.

It would be very kind if you could look again over the program and perhaps post the code here.

Thank you very much,
Lukasha.


Steffenk(Posted 2007) [#8]
Hi!
Unluckily your program is quite confusing. I used types (and functions/methods!) when I did this and you haven't indented anything! Maybe you should try the Community Edition IDE, btw.
My first attempt maybe a year ago wasn't quite good either and also not very fast, so i'll try a new one now.

uhm.. how do i post code like you did in the first post?


Lukasha(Posted 2007) [#9]
You have to use:

[codebox]

...

[//codebox]

in front of the second codebox you have to use only one "/".
If I wrote it here down correct, there would be a codebox!!
;-)

Lukas