Live data from Hacker News

Gravity Simulator

nowykurier.com

91–100 of 135 posts

Re: Gravity Simulator

#92
I, like many others on this thread, have dabbled in the Gravity Simulation game. I've done two of them.

The first one was back in 1999, I wrote one with 13h[1] graphics for DOS (Borland Turbo C++), and to make it more fun, I used flat sprites to represent the objects (so the objects progressed from being rocks to asteroids to planets - with the largest sprite I used being an image of Jupiter).

A few years later, I rewrote it in OpenGL (using the GLUT library) for a class. It worked much better (and of course the hardware was much faster too).

I had always planned rewriting the physics engine to use Barnes-Hut, but never got around to it, so it always ran at N^2.

Anyway, for the curious, the code is up on Github amongst my collection of other old garbage stuff from back in the day: https://github.com/choptastic/OldCode-Public/tree/master/Gra...

[1] http://en.wikipedia.org/wiki/Mode_13h

Re: Gravity Simulator

#93
post #86
post #81

Earlier quoted context omitted.

Can someone explain the math behind this? Which methods were used? I wasn't aware it was possible to run such a simulation on flash because each body results in 6x more calculation. Is this like plugging in the masses into a single equation? I want to learn more about how this is done .

> Can someone explain the math behind this? Which methods were used? I can't speak to the linked simulator, but gravitational calculations are relatively simple -- they represent the solution to a numerical differential equation that, in small slices of time, solves: f = G m1 m2 / r^2 Where: f = force, Newtons G = Universal gravitational constant: http://en.wikipedia.org/wiki/Gravitational_constant m1 = mass of body…

Here are the people who do this for NASA planetary missions:

http://ssd.jpl.nasa.gov

Here's a snapshot of object locations in the inner solar system:

http://ssd.jpl.nasa.gov/?ss_inner

There are a lot of challenging problem areas: rendezvous with small bodies (very irregular gravity fields), mission trajectory design, operations planning for flybys in the presence of, say, camera pointing constraints.

(@lutusp knows this already -- I'm putting it here just for interest.)

Re: Gravity Simulator

#94
post #7

It's really nice. Be sure to activate paths, I'm having a lot of fun using that to draw cool stuff :). https://i.imgur.com/j3YwI5y.png That was me trying to have a small particle making an 8-shaped path around two bigger ones that would be sufficiently far apart to not interact too strongly with each other. Of course, when the small particle went between the two bigger ones, it shifted their position a tiny bit, but…

> That was me trying to have a small particle making an 8-shaped path around two bigger ones that would be sufficiently far apart to not interact too strongly with each other.

This kind of path is called a free return trajectory and was used in the Apollo program lunar missions. The trajectory is not periodic, ie. it doesn't repeat more than once. The trajectory around the earth takes less time than lunar period ("month") so when the craft goes back up, the moon has moved on. You might be able to construct a planet-moon system with an m:n resonance in the orbital periods of the moon and the craft so that the tracjetory is periodic.

Free return trajectories are used in manned space flight to guarantee that the craft and crew return to earth if a failure prevents from entering lunar orbit.

Re: Gravity Simulator

#95
post #87

Love this. I managed to get a pretty stable orbit by using the right angle and velocity (by chance). Highlighted in yellow: http://i.imgur.com/OOaTLMP.png

This is the coolest trajectory found on this thread for now!!!!

Re: Gravity Simulator

#96

I did something similar, but with combat - ships, lasers and missiles. There are a couple of variations, and some tweaks like the ships accelerating perpendicular to the planets so they don't crash land. http://codepen.io/simonswain/full/ftEjD/ http://codepen.io/simonswain/full/CeHmh/

Very cool. I notice that many ships tend to get stuck on the edge of the map though. Maybe make it so they loop back around to the other side of the map?

Re: Gravity Simulator

#97

I think I just learnt something about gravity and oscillations: http://i.imgur.com/OrUUFj7.png Using the rapid-click feature on my mouse to place a dense circle outline: http://i.imgur.com/14IN5pi.png

And I think I just learned something about all of your open tabs and bookmarks

Re: Gravity Simulator

#99

This is nice, but please rename the OMFG button. As someone who works in K-12, it would be a shame if a program like this is rejected because of a button.

Its a shame that a simple button label would be the cause of an education tool to be rejected... sissy-state for the win!

OMFG is not a standard abbreviation. If you are making a tool that can be used worldwide, best to stick with words and slangs that are universally known.

Moreso, best to stick with terms that are acceptable to people of all cultures and backgrounds. The word 'fucking' may be a light-hearted slang to a 20 year old american, but it may just be offensive to someone older living in the UAE.

Professionalism, though not perfect, does in fact help in making people from various background agree and understand good ideas by being austere, simple and well-defined.

Re: Gravity Simulator

#100
post #97

I think I just learnt something about gravity and oscillations: http://i.imgur.com/OrUUFj7.png Using the rapid-click feature on my mouse to place a dense circle outline: http://i.imgur.com/14IN5pi.png

And I think I just learned something about all of your open tabs and bookmarks

Hope it's useful :)
Post reply on HN