Welcome, Guest

Author Topic: 2D 3-body Gravitational Simulator  (Read 5762 times)

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
2D 3-body Gravitational Simulator
« on: April 10, 2011, 12:55:08 PM »
Right now, I'm working on a Perl gravitational simulator. It takes 3 bodies characteristics and creates an output file. The visual output is your favorite graphing program! Excel, Google Docs, or whatever. The output file just outputs the locations. I'll probably change it to include acceleration or other data. Collisions aren't in the program yet. It should be easy by simply adding radii to the objects. It's conventionally a Star-Planet-Moon simulator, but with a little calculation you can make a 2 planet system. :P

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: 2D 3-body Gravitational Simulator
« Reply #1 on: April 10, 2011, 06:37:30 PM »
I finished it... and tested it... It wrote the file... but it only said:

Code: [Select]
StarX StarY PlanetX PlanetY MoonX MoonY
when it should have had that AND a bunch of data

It said "Illegal division by zero at line 164"
« Last Edit: April 10, 2011, 06:47:29 PM by NeutronStar »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: 2D 3-body Gravitational Simulator
« Reply #2 on: April 10, 2011, 06:53:45 PM »
I think I fixed it but then all I got was:

Code: [Select]
2.45230724281467e+024 1.63605369640936e+024 2.39322572687155e+026 -1.6524812430857e+027 -4.25878464967556e+030 -7.94160599526426e+031

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: 2D 3-body Gravitational Simulator
« Reply #3 on: April 10, 2011, 07:28:40 PM »
Fixed it, but now it just gives the same number repetitively, for each one.

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: 2D 3-body Gravitational Simulator
« Reply #4 on: April 12, 2011, 09:59:35 PM »
I got it to work! I can't tell if the sun is working... it's the only one giving the same numbers. Anyhow... Here's a chart. 48 iterations 6 hours each. Due to the way the numbers output and google reads it... You should view it upside down. :P

The star is located... not at 0 for whatever reason. I have no clue. I tell it that it is located there, but it doesn't seem to care.
« Last Edit: April 12, 2011, 10:04:02 PM by NeutronStar »

Dan Dixon

  • Creator of Universe Sandbox
  • Developer
  • *****
  • Posts: 3244
    • Personal Site
Re: 2D 3-body Gravitational Simulator
« Reply #5 on: April 14, 2011, 12:43:12 PM »
Very cool.

You've seen my early gravity simulation work, right?
http://dandixon.us/programming/planets.htm

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: 2D 3-body Gravitational Simulator
« Reply #6 on: April 14, 2011, 07:54:01 PM »
Yeah, I have.  :)