home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / SPRING.ZIP / SPRING2.DOC next >
Text File  |  1992-04-30  |  4KB  |  133 lines

  1. SPRING2.DOC
  2. ===========
  3.  
  4. This little program started as an investigation into 'damped oscillations'
  5. such as those created by a pendulum moving through air, or a weight
  6. attached to a spring.  It soon became an exercise in modeless dialog boxes,
  7. user painted controls and PM animation.
  8.  
  9. There are three basic components to the program:
  10.  
  11. Main Window:
  12. ------------
  13. After starting the program, you will see the main window.  I usually resize
  14. this window so it's fairly small.  What you see is a pale gray grid and
  15. a two function plots, one in dark red and one in dark blue.  The dark red
  16. line plots the oscillatory motion along the X axis and the dark blue plots 
  17. the motion along the Y axis.
  18.  
  19. At first, both axes have identical parameters, so it just appears as one
  20. blue line.  The X axis of the grid is time in seconds, and the Y axis
  21. is magnitude of oscillation.  Each pale gray division shows one second.
  22.  
  23. Parms Window:
  24. -------------
  25. Pressing F6 (or clicking on the menu) brings up the Parameters dialog.
  26. You use this dialog to control the variables in the oscillation function
  27. for both the X and Y axes.
  28.  
  29. The 'Period' of oscillation controls the length of the oscillation period
  30. in seconds.
  31.  
  32. 'Mass' controls the mass of the object being oscillated.
  33.  
  34. 'Damping' controls the effectiveness of the dampener.  For instance, a body
  35. oscillating in air has a lower damping factor than one oscillating in water.
  36.  
  37. 'Phase' controls the beginning phase angle (in radians) for the oscillation.
  38.  
  39. The 'Copy' buttons simply duplicate the parameters up to X or down to Y.
  40.  
  41. The 'OK' button makes the changes permanent and closes the dialog.
  42.  
  43. The 'Cancel' button abandons all change and closes the dialog.
  44.  
  45. Animate Window:
  46. ---------------
  47. Press F5 (or clicking on the menu) brings up the Animation dialog.
  48. This dialog graphically animates the motion of the object in the X and Y
  49. axes in real-time.  The 'Weight' window contains a red box that represents
  50. the object being oscillated.
  51.  
  52. The button controls in this window are similar to VCR-like controls.  From
  53. left to right they are defined as follows:
  54.  
  55. REWIND:
  56. Resets the time counter to zero and stops the replay.
  57.  
  58. STOP:
  59. Pauses the replay.
  60.  
  61. PLAY:
  62. Starts (or unpauses) the animation at the current time.
  63.  
  64. FRAME:
  65. Moves the animation forward one frame, to the next time increment.
  66.  
  67. CANCEL:
  68. Closes the dialog.
  69.  
  70.  
  71. EXAMPLE:
  72. Start the program and press F6 for the Parms window.  Modify the controls
  73. so they are like this:
  74.  
  75. X Axis:
  76.    Period:  0.8000
  77.    Mass:    0.9600
  78.    Damping: 2.0000
  79.    Phase:   0.0000
  80. Y Axis:
  81.    Period:  0.5000
  82.    Mass:    0.9600
  83.    Damping: 1.1200
  84.    Phase:   1.4451
  85.  
  86. Now press F5 and click on the PLAY button.  This demonstrates the actual
  87. motion of the object oscillating along the two axes.
  88.  
  89. CAVEATS:
  90. --------
  91. This program wasn't written for you, it was written for a friend studying
  92. physics.  However, you are welcome to use as you see fit.
  93.  
  94. Since I wrote the program in about a day and a half, there are a few bugs:
  95. sometimes the animation dialog shows strange behavior.  If it does, simply
  96. cancel the dialog and bring it back up again.
  97.  
  98. Display update may vary.  It works great on my 486-50, and it works OK on
  99. my 386SX-16.  Also, because the animation is based on snapshots of the
  100. object position at a point in time, setting the 'period' to a very small
  101. value will cause the animation to be confusing.
  102.  
  103. Resize the main window so it's fairly small.  Parameter changes are
  104. immediately reflected in the main window, so the smaller it is, the faster
  105. it will update.
  106.  
  107. It's possible to click bring up more than one copy of each dialog box.
  108. I just didn't put the code in to disable the menu options...  If you do
  109. this, unexpected results may occur!
  110.  
  111. This program was written in Zortech C++ and the OS/2 V1.2 toolkit, developed
  112. on OS/2 1.3EE on a Gateway 486-50.
  113.  
  114. The formula for damped oscillations is:
  115.  
  116.        -(b/2m)t
  117. x = A e          cos(wt + d)
  118.  
  119. Where:
  120.     A is the amplitude
  121.     b is the damping constant
  122.     m is the mass of the object
  123.     t is the time
  124.     w is the angular frequency (2pi / T)
  125.     d is the phase constant
  126. -------------------------------------------------------------------------
  127. That's all! Play with it if you like.  Talk to me on CIS:71316,1603 or on
  128. Pete Norloff's OS/2 Shareware BBS.
  129.  
  130. Steve Horne
  131. CoralSoft, Inc.
  132.  
  133.