Current Project: Kepler
My latest project is a program that models gravitational attractions between any number of particles (ie, planets) in space. It uses a simple numerical (iterative) method to update the acceleration, velocity, and position of each object.
So far, I have the engine and the graphics down, and I've just added a whole coordinate system, with axes and grid lines, that allows you to scroll around the "universe" and zoom in and out. (And the scale of the grid lines changes as you zoom, just like in 3D modeling programs) More recently, I cleaned up the code a fair bit by putting this whole coordinate system in its own class. Right now, I'm just tinkering with the organization, and having fun experimenting with different systems.
Soon to come, hopefully, are:
- An interface for adding new planets whenever and wherever you want
- The ability to track individual particles
- Numbers on the grid lines to indicate whereabouts on the axes your field of view is.
- Mouse scrolling/zooming
I have just uploaded a sample program that will essentially generate what became Screenshot 7 below, (if you press PrntScrn at the right time), but this version has the precision turned down a little, so the planets' paths will look less like lines, and more like dots. There are no instructions in the program right now, so I'll just lay them out for you here:
P: pause/unpause simulation (simulation is initially paused)
I: iterate one step (only works when paused)
T: toggle planet trails
A: toggle axes
G: toggle grid lines
J: zoom in
K: zoom out
Arrow keys: scroll around the universe
And here's the program: Kepler Demo
In the demo program, if you want to see what's going on in any detail, you'll have to zoom in quite a bit, and maybe scroll around a little to get everything the way you want it. Then, press P and watch things fly! Exciting, eh? That's what I thought.
Or, if you just want to take a peek, here are some screenshots I've made:
Screenshot 7 NEW!
Screenshot 6 was actually a screenshot of a run where the attraction was not gravitational. The acceleration of the yellow particle was directly proportional to its distance from the fixed blue point, so the attraction was actually like that of a spring, instead of a gravitaional field. I thought this was interesting, and a potential spin-off of this project might be a similar, but separate program, that models spring dynamics, with any number of objects connected by springs of various strengths.
Screenshot 7 shows off some of the new features that have been added in the last week. See them in more action in the demo program above.
That's it for now, folks!
Last updated March 10, 2003