/* John Gardner, 2010 NBodySim is a 3d simulation of particles under the force gravity. Visit john-gardner.net/nbody for more information. =============== Controls ============== - Drag the mouse with the left mouse button to: - rotate the view around the selected particle if follow is checked - or move parallel to the view plane if follow is unchecked. The view plane is defined as the plane perpendicular to the view direction and containing the position of the last particle followed ((0, 0, 0) initially). - to zoom, drag the mouse up or down with the right mouse button - to rotate the view, drag the mouse left or right with the right mouse button - press to hide/restore the interface ============ The Interface ============ [Help / About] - toggle this text window [Statistics] - show extra information for the selected particle. First is a scaled history containing the step number, elapsed time, position and also the distance result if testing for step method accuracy. Next is current step number, elapsed time, mass, position, velocity, and acceleration. Finally, the calculation time of the selected step method is averaged every second. [New Window] - opens the app in a new window. This is convenient for resizing to fullscreen when running in a browser. [Reset Time] - reset elapsed time for the system [Reset All] - reset the system and restore initial settings [Run / Pause] - toggle continuous running of the simulation [Single Step] - execute the simulation one step at a time [Step Size] - set the size of the time step (in seconds) [Steps/Frame] - set number of steps to do before updating the screen [Frames/Sec] - set the maximum number of frames per second [Step Method] - select the method used to evolve the system [Test Method Accuracy Using Half Step Size] - Checking this creates a copy of the system and evolves it using the same step method but at half step size. This result, which should be much more accurate than the original, is drawn as an "x" on the display. Comparing the distance between the original and half step size results provides a good estimation of accuracy. If "show names" is checked, this distance is shown after the name. [Load Systems] - loads a new set of systems from a text file. (See below for instructions on how to create a systems file). There may be a file load error due to access restrictions in the applet version. If so try downloading the desktop version. [Particle System] - select which system to display [Particle List] - selects a particle (left clicking on a particle will also select it). Information about the selected particle is shown in the statistics window and it is followed if [follow] is checked. [show names] - check to display names next to each particle [show history] - draws the positions for all the particles of all the [show velocity] - show velocity as a green line [show accel.] - show acceleration as a red line [follow] - check to keep the view centered on the selected particle Settings - At the bottom right are displayed the current system and particle, steps/frame, frames/sec, step method and elapsed time. The total steps per second calculated equals steps/frame times frames/sec. If its too demanding on the cpu, these numbers may be lower than the set values. Also frames/sec is the rate of frame draw requests to the operating system but the actual frames/sec drawn may be lower. */ ////////////////////////////////////////////////////////////////////////////// // systems file syntax // use // and /* */ for comments /* - values are separated by spaces - use double quotes ("") for a blank name or name with spaces - lengths are in meters, velocity in meters/second and masses in kilograms - vectors can be defined using the following coordinate systems: 2d cartesian coordinates (z = 0): xy "x" "y" 3d cartesian coordinates: xyz "x" "y" "z" polar coordinates (z = 0): rt "r" "theta" spherical coordinates: rtp "r" "theta" "phi" - angles are in degrees theta(azimuth): in xy plane, angle from x-axis in direction of y-axis phi(elevation): angle from xy plane in +z direction - camera view definitions: 2d view: 2d "x center" "y center" "view height" - example for a camera centered at (0,0) with view height 1 2d 0 0 1 3d view: 3d "camera position" "position to look at" "camera tilt angle" - example for a camera at (0,0,0) looking at (10,0,0) and tilted 10 degrees clockwise: 3d xyz 0 0 0 xyz 10 0 0 10 commands: /nextsystem - use to start a new system /addprev and /stopadd - add the r and v coordinates of the particle before /addprev to all particles between /addprev and /stopadd */ ////////////////////////////////////////////////////////////////////////////// // a two system example // 2d system start info // system view center view step steps/ show // name x y height size frame fps names? "Star, Planet and Moon" 2d 0.0 0.0 4.0 0.01 1 30 true // particle info // position velocity color // name coordinates coordinates mass radius r g b Star xy 0 0 xy 0 0.14 1.0e11 0.15 255 155 0 Planet xy 1.0 0 xy 0 -2.8 5.0e09 0.04 80 80 255 /addprev // use moon coordinates relative to planet Moon xy 0 0.1 xy 1.8 0 0 0.02 120 120 120 /stopadd /nextsystem // 3d system start info // name camera look at tilt size frame fps names? Pulsating 3d xyz 5 5 5 xyz 0 0 0 15 0.01 1 30 false Star xy 0.0 0.0 xy 0.0 0.0 1.0e11 0.1 255 255 255 "" rtp 1.0 0 15 rtp 1.5 15 90 0 0.02 150 150 150 "" rtp 1.0 30 15 rtp 1.5 15 120 0 0.02 150 150 150 "" rtp 1.0 60 15 rtp 1.5 15 150 0 0.02 150 150 150 "" rtp 1.0 90 15 rtp 1.5 15 180 0 0.02 150 150 150 "" rtp 1.0 120 15 rtp 1.5 15 210 0 0.02 150 150 150 "" rtp 1.0 150 15 rtp 1.5 15 240 0 0.02 150 150 150 "" rtp 1.0 180 15 rtp 1.5 15 270 0 0.02 150 150 150 "" rtp 1.0 210 15 rtp 1.5 15 300 0 0.02 150 150 150 "" rtp 1.0 240 15 rtp 1.5 15 330 0 0.02 150 150 150 "" rtp 1.0 270 15 rtp 1.5 15 0 0 0.02 150 150 150 "" rtp 1.0 300 15 rtp 1.5 15 30 0 0.02 150 150 150 "" rtp 1.0 330 15 rtp 1.5 15 60 0 0.02 150 150 150