Home : Map : Chapter 8 : Java : Tech : Physics :
Discretization
JavaTech
Course Map
Chapter 8

Introduction
Threads Overview
  Demo 1   Demo 2
Stopping Threads
Multi-Processing
Thread Tasks
Animations
 
 Demo 3   Demo 4  
  Demo 5

Non-interacting
  Demo 6

Task Splitting
  Demo 7

Exclusivity
  Demo 8

Communicating
  Demo 9

Priority/Scheduling
More Thread

Exercises

    Supplements
Java2D Animation
  Demo 1 
Processor View
More Concurrency
Cloning
  Demo 2  Demo 3 

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

In a computer simulation you must break both time and space into finite, discrete pieces. This typically results in tension between precision and performance.

Ideally, you would make the time and space units extremely small so as to best represent the continuity of the physical world and to reduce the build up of mathematical errors. On the other hand, the fewer the number of units to deal with, the less memory the program requires and the faster the program will run.

The optimum size for the time and space units will clearly depend on the particular simulation and the equations involved. In fact, as we will see in a later discussion dealing with time in a simulation, different parts of the simulation might use different scaling.

For example, the frame rate of an animation would typically involve a considerably longer time period than those of the time increments in an integration of a differential equation that calculates the motion of an object over the time period of that frame. Otherwise, a coarse increment could result in a highly inaccurate integration in the case where the function varies significantly at the scale of the increment.

Obviously, the platform(s) on which you plan to run the program also can affect what scale of units to use. This is especially significant for animations. One powerful machine might easily complete the calculations required before it displays a new frame, while a less powerful machine might occasionally fail to complete the calculations on time and cause flickering in the animation. (Animation frames could be saved for later playback as in a video but here we are discussing real-time interactive animations.)

Below we show a simple animation of a projectile. For the given initial location, velocity, and angle, it should hit at the spot indicated. The slider allows the user to vary the dtcalc value used in the numerical integration of the equation of motion for each frame.

 
DiscreteTest_JApplet11.java
+
Histogram.java
+
Updateable.java, MakeData.java,
+

HistPanel.java, PlotPanel.java, PlotFormat.java

 

PlotPanel.java, PlotFormat.java are unchanged from Chapter 6: Tech : Plotting.

HistPanel.java, Histogram.java are unchanged from Chapter 6: Tech : Histogram Plot

 

 

              Tech
Timers
  Demo 1
Hist. Adapt Range
  Demo 2
Sorting in Java
  Demo 3
Histogram Median
  Demo 4
Refactoring
  Demo 5
Error Bars
  Demo 6
Exercises

           Physics
Least Squares Fit
  Demo 1
Fit to Polynomial
  Demo 2
Fit Hist Errors
  Demo 3
Discretization
  Demo 4
Timing
  Demo 5
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.