Class NormalModes
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.awt.Applet
|
+----Edu.calpoly.math.gepstein.NormalModes
- public class NormalModes
- extends Applet
- implements Runnable
This applet shows the first eight contributing normal modes of string with
fixed ends. This is equivalent to two identical traveling waves moving
in opposite directions.
The wave equation:

Boundary Conditions:


Initial Condition:

Initial Condition:

Originally Written in TRUE Basic for Macintosh by Dr. G.M. Epstein
Copyright © 1997, 1998 by Dr. G.M. Epstein
gepstein@calpoly.edu
- Author:
- Gary M. Epstein
-
NormalModes()
-
-
aTerms(int)
- Calculates the coefficients for the Fourier series.
-
fourier(int, double, double)
- Calculates the value of a harmonic in the equation:
for different times t and different locations x.
-
init()
- This method sets the frame refresh rate for the animation, the
background color, the amount of space the animation occupies in the
the WWW browser and how much space each individual contributing
wave will occupy in the total area.
-
linearTransform(double, int)
- Takes a value from the conventional cartesian coordinate system and
translates it to the coordinate system in a single panel on our
display
-
paint(Graphics)
- This method simply passes the current graphics context to the
update() method.
-
run()
- The Java Virtual Machine calls this method just after completing the
start() method.
-
start()
- If the user has not requested that we stop the animation with a mouse
click, this method begins animation following initial program loading,
the user revisting the WWW page or de-iconifying the browser.
-
stop()
- Stops the animation.
-
update(Graphics)
- This method does the computation and displays the graphical results
on the screen.
NormalModes
public NormalModes()
init
public void init()
- This method sets the frame refresh rate for the animation, the
background color, the amount of space the animation occupies in the
the WWW browser and how much space each individual contributing
wave will occupy in the total area.
- Overrides:
- init in class Applet
start
public void start()
- If the user has not requested that we stop the animation with a mouse
click, this method begins animation following initial program loading,
the user revisting the WWW page or de-iconifying the browser. If the
user did request that we stop the motion, this method does
nothing.
- Overrides:
- start in class Applet
- See Also:
- stop
run
public void run()
- The Java Virtual Machine calls this method just after completing the
start() method. This method begins another thread running
concurrently, the thread handling the animation. Calls the
paint() method on regular intervals in order to continue
the animation.
- See Also:
- run in class Thread
paint
public void paint(Graphics g)
- This method simply passes the current graphics context to the
update() method.
- Overrides:
- paint in class Container
- See Also:
- update
update
public void update(Graphics g)
- This method does the computation and displays the graphical results
on the screen.
- Overrides:
- update in class Container
- See Also:
- paint
stop
public void stop()
- Stops the animation. In the case of the user leaving the web page or
minimizing the browser, the JVM calls this method so that the animation
won't continue running and taking CPU time without anyone to see it.
- Overrides:
- stop in class Applet
- See Also:
- start
aTerms
public float aTerms(int n)
- Calculates the coefficients for the Fourier series:

where:
- Parameters:
- n - the number of the harmonic.
- Returns:
- the value of the n-th coefficient.
fourier
public double fourier(int n,
double x,
double t)
- Calculates the value of a harmonic in the equation:

for different times t and different locations x.
- Parameters:
- n - the number of the harmonic
- x - the current location on the x-axis
- t - the elapsed time since the start of the animation
- Returns:
- the value of the n-th harmonic.
linearTransform
public int linearTransform(double yValue,
int mid)
- Takes a value from the conventional cartesian coordinate system and
translates it to the coordinate system in a single panel on our
display
- Parameters:
- yValue - vertical value in the canonical cartesian coordinate system
- mid - value halfway between 0 and the maximum vertical coordinate
- Returns:
- the value of
yValue in the AWT coordinate system