Simple 2D black hole simulator

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
I made a simple 2-dimensional simulator of a spaceship flying near a black hole and I thought I'd share it :)

EDIT: I made a new version, more detailed description can be found on page 2 of this thread.
black_hole.png


You can see the [ame="http://en.wikipedia.org/wiki/Apsidal_precession"]apsidal precession[/ame] in the picture ;)

Forgive the poor graphics (if we can even call it graphics :D), but it was just an attempt to simulate black hole physics. I'm going to improve it a bit in the near future.

You can download it here: http://dl.dropbox.com/u/7065759/Black Hole/Black_hole_old.exe

You have a spaceship orbiting a black hole at about 5 Schwarzschild radii from the center. Controls:

W/S/A/D - single press increases forward/backward/left/right thrust.
Q - thrust cutoff.

There are a few fun things to try:

1. Dropping into the black hole. You can see how the board time slows down. Also, there is one quite surprising effect, see if you can spot it and explain it ;)
2. Lowering the orbit. This is damn hard, I still can't succeed - mostly it's poor controls, but this is the only way I could get it to work; I'll need to modify the program to make it better.
3. "Slingshot" around the black hole - now this is funny, because if you aim right, you can make a full circle and get launched again in the same direction (actual circle is very hard, I had managed to get a trajectory that intersected itself though). This is quite different to Newtonian mechanics, where you always get a hyperbola.

Hope you like it :)
 
Last edited:

Wishbone

Clueless developer
Addon Developer
Joined
Sep 12, 2010
Messages
2,421
Reaction score
1
Points
0
Location
Moscow
My antivirus says that a Keylogger has been detected.
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
What.

That's strange, I assure you I have put no keylogger in there. Maybe that's because I use the GetAsyncKeyState functions for the controls.

In case you want proof (I know I'm not a recognized member and I guess you may not want to just take my word), I can post whole source of this program.
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,617
Reaction score
2,337
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
My antivirus says that a Keylogger has been detected.

Can't confirm it here, my A/V doesn't detect anything and manually checking the file imports verifies that it does not import any windows function, that it does not need.
 

Wishbone

Clueless developer
Addon Developer
Joined
Sep 12, 2010
Messages
2,421
Reaction score
1
Points
0
Location
Moscow
hehe, you're recognized, and most likely related to Kandinsky...

Now back to the functions: I did have a look at the file (see, your name is in there :)), encountered no suspicious kernel-level calls, and noticed that the "keylogger" alarm goes on if the window loses focus. Suggest you should compile with Release setting and post the exe for us to verify that the alert was debug-related.
 

Keatah

Active member
Joined
Apr 14, 2008
Messages
2,218
Reaction score
2
Points
38
I ran it by VirusTotal (www.virustotal.com) and they couldn't find anything. 43 scanners said ok, and that's good enough for me.
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Wishbone said:
Now back to the functions: I did have a look at the file (see, your name is in there :))
Haha, indeed, I wasn't aware things like that remain in the exe files :D

Wishbone said:
Suggest you should compile with Release setting and post the exe for us to verify that the alert was debug-related.
Umm, this is the release version - actually, in the same place where my name is you can see that the directory was ".../Release/..." ;).
 

Wishbone

Clueless developer
Addon Developer
Joined
Sep 12, 2010
Messages
2,421
Reaction score
1
Points
0
Location
Moscow
slight paranoia... quite possible that it is the result of an earlier exam re-sit today, which the student failed :(

Back to relativity: is there any way to show thrust graphically in the right panel (e.g., with an arrow)? I've managed to get nice spirals around the hole so far.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
Haha, indeed, I wasn't aware things like that remain in the exe files :D


Umm, this is the release version - actually, in the same place where my name is you can see that the directory was ".../Release/..." ;).
For the Release configuration, in the "Project Properties -> Configuration Properties", for "C/C++ -> General -> Debug Information Format" select "Disabled", and for "Linker -> Debugging -> Generate Debug Info" select "No". This will disable generation and exclude the PDB file referencing from the EXE file.
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
orb said:
For the Release configuration, in the "Project Properties -> Configuration Properties", for "C/C++ -> General -> Debug Information Format" select "Disabled", and for "Linker -> Debugging -> Generate Debug Info" select "No". This will disable generation and exclude the PDB file referencing from the EXE file.
I tried it, but for some reason the compiler still generates debug database and adds the reference to the .exe file. That doesn't bother me much, though ;)

Also, I uploaded a new version of the program, which displays one more information, namely what I called "total proper velocity". Total velocity, displayed before, is total velocity as seen by the observer at infinity and doesn't take different time flow where the ship is into account. Total proper velocity takes that into account, so its value can be quite different from the non-proper total velocity.

Wishbone said:
Back to relativity: is there any way to show thrust graphically in the right panel (e.g., with an arrow)? I've managed to get nice spirals around the hole so far.
Yeah, that's possible, I'll add it in the version with new interface (which, unfortunately, might not be soon, because I have some work to do, but I'll get to it ;) ).
 
Last edited:

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
I tried it, but for some reason the compiler still generates debug database and adds the reference to the .exe file. That doesn't bother me much, though ;)
This is strange, because I just tested this setting in a simple EXE file that does nothing, and the PDB wasn't referenced any longer in Release with those options. Maybe try rebuilding the whole project instead of simply building only changed files (?).
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
I realized I missed the point about turning off debugging in the linker options too - my bad. It's ok now. Thanks! :)
I uploaded this new version, it's available under the same address.
 

Wishbone

Clueless developer
Addon Developer
Joined
Sep 12, 2010
Messages
2,421
Reaction score
1
Points
0
Location
Moscow
Thanks, looks fine. Yet after time (inertial) crosses 150, the black hole is no longer black but white with a thin black rim :p And a serious question: does the black hole rotate?
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Wishbone said:
Yet after time (inertial) crosses 150, the black hole is no longer black but white with a thin black rim
I knew there were issues with graphics after when the window was hidden behind another window, but I never noticed it was tied to time in any way. Well, I'll rewrite the whole visual side using Qt anyway ;)

EDIT: Indeed, it went white after about 157 seconds for me. Strange.

Wishbone said:
And a serious question: does the black hole rotate?
Nope, it's the Schwarzschild black hole, but I was trying to write the code in a way that will allow relatively easy switch to Kerr if I ever feel like it :p
 
Last edited:

Linguofreak

Well-known member
Joined
May 10, 2008
Messages
5,034
Reaction score
1,273
Points
188
Location
Dallas, TX
By "board time" I take it you mean "on-board time"?

Would it make the math (or the programming) too much hairier to give an option to propagate the trajectory by on-board time rather than time-at-infinity?
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Linguofreak said:
By "board time" I take it you mean "on-board time"?

Would it make the math (or the programming) too much hairier to give an option to propagate the trajectory by on-board time rather than time-at-infinity?
Yeah, that's what I meant.

The math would only differ by one division :p I just chose the time at infinity due to a bit external look of this simulator. If I ever take it into 3D (which I'm planning to do, but it may be too much for me) and first-person-perspective, the on-board time will be the obvious choice as the main time.

I'll make the version using on-board time in a moment.

EDIT: Here you are:
http://dl.dropbox.com/u/7065759/Black_hole_onboard.exe

It goes a bit crazy when you fall on the horizon, because from the on-board perspective you should pass it and fall to the singularity, but I don't simulate the inside of the black hole. Also it's quite easy to see how interstellar travel can be possible even without FTL ;)
 
Last edited:

Stevodoran

Donator
Donator
Joined
May 19, 2010
Messages
867
Reaction score
0
Points
0
Location
loughcrew
A little problem. After an extensive period of time the ship dissapears and their are two black holes both white:

picture.php


Notice it tipped off my antivirus but its clean.

Other than that its great fun and you can make cool orbits :D

picture.php


Just one request's: Can you make the controls a little less responsive?
 

Fizyk

Member
Joined
Jun 20, 2008
Messages
285
Reaction score
1
Points
18
Location
Warsaw
Website
ebvalaim.net
Stevodoran said:
A little problem. After an extensive period of time the ship dissapears and their are two black holes both white:
Yeah, I don't know why that happens, but I'm currently rewriting this using Qt, so it should work better when I finish.

Stevodoran said:
Other than that its great fun and you can make cool orbits :D
Glad to hear that :)

Stevodoran said:
Just one request's: Can you make the controls a little less responsive?
I'll make them more convenient in the Qt version :)
 

Stevodoran

Donator
Donator
Joined
May 19, 2010
Messages
867
Reaction score
0
Points
0
Location
loughcrew
Yeah, I don't know why that happens, but I'm currently rewriting this using Qt, so it should work better when I finish.


Glad to hear that :)


I'll make them more convenient in the Qt version :)

Whats Qt?
 
Top