Below is a Java applet I am developing that simulates a gravitational system
in real time, and allows the user to interact with it. The article that
accompanies it can be found in the
Queens College Nucleus, a
science student science journal with an eclectic array of research related
articles by the Students of Queens College CUNY.
Source Files:
CelestialBody - Stores information on the
position, velocity, mass, size, and color of a planet/star.
SolarSystem - Stores a set of CelestialBody
objects in a doubly linked list structure, and manages most events.
Grabity - The Applet that serves as the drawing
board for the solar system. This will also be the place where all of our
controls are handled.
GRABITY
Pressing '1' on the keyboard sets - CelestialBody Creation Mode:
Find the spot where you want to create a celestial body, then click and hold down the (left)mouse button. Pull back in the direction opposite to the way you want your celestial body to travel. A yellow line will appear indicating the magnitude of the velocity that will be imparted upon the body once it is created as you release the button. The further you pull back, the faster your new body will go. You can think of this as a slingshot,
or starting up a pinball game. (At this point the mass and size of the new body can not be specified)
Pressing '2' on the keyboard sets - Zoom In/Out Mode:
Zooming in and out can be accomplished by clicking and holding down the mouse
button, then moving the mouse left and right. Release the mouse button to continue.
Pressing '3' on the keyboard sets - View Moving Mode:
Click and hold the mouse button, dragging the mouse will move the 'camera'
around, so that you can see objects that are off the screen.
Pressing '4' on the keyboard sets - Set Focus Point Mode:
Click, hold down, and drag to form a rectangle. The first celestial body
in the list that is found to be contained within that rectangle will be set
as the center point of the rendering portion of the simulation. (NOTE:
This is still a bit buggy.)
S - Set Focus Point to the Sun...
F - Free Focus Point... (NOTE: Activing View Move Mode also frees the focus)