Class TPhysCalcs

java.lang.Object
  |
  +--TPhysCalcs

class TPhysCalcs
extends java.lang.Object
implements java.lang.Runnable

Class that does all the physical simulations and caries all the physical objects.


Field Summary
 boolean Active
          Activity flag
 double ALPHA0
          Initial angle of the first pendulum in radians
 TArc3D Arc3D1
          Arc between LinePendul1 and the first pendulum
 TArc3D Arc3D2
          Arc between LinePendul2 and the second pendulum
 double BETA0
          Initial angle of the second pendulum in radians
 double C
          Distance between suspension point of the pendulum and suspension point of the spring ON the pendulum
 double CM2AXIS
          Distance between center of mass and suspension point of the pendula
 double DEPTHPENDUL
          Depth of the pendula
 double e_max
          Maximum error in the simulation
 double G
          Gravitational constant
 double h_maxinit
          Initial maximum stepsize (for use in adaptive stepsize)
 double HEIGHTPENDUL
          Initial Height of the pendula
 double K
          Initial spring constant K
 TLine3D LinePendul1
          Line going through the first pendulum when it is at rest.
 TLine3D LinePendul2
          Line going through the second pendulum when it is at rest.
 double MASS
          Initial mass of the pendula
 int NOTIMES
          Initial number of steps the simulation does between two frames
(package private)  TOscilloscope Oscilloscope
          Oscilloscope canvas.
 TPendulum Pendul1
          First pendulum
 int Pendul1DataStream
          Datastream index of the first pendulum, used to identify the data for the first pendulum in the oscilloscope
 TPendulum Pendul2
          Second pendulum
 int Pendul2DataStream
          Datastream index of the second pendulum, used to identify the data for the second pendulum in the oscilloscope
 double perframe
          Number of seconds per frame
(package private)  TPhysCanvas PhysCanvas
          Canvas onto which all the physical objects are drawn.
 TSphere3D Sphere1
          Sphere at the top of the first pendulum (suspension point)
 TSphere3D Sphere2
          Sphere at the top of the second pendulum (suspension point)
 TSpiral3D Spiral
          Spring between the two pendula
 double t
          Time of the simulation (in milliseconds
protected  java.lang.Thread timerThread
          Thread used for calculating and predrawing the physics of the simulation.
 double VPendul1
          Angular velocity of the first pendulum
 double VPendul2
          Angular velocity of the second pendulum
 double WIDTHPENDUL
          Width of the pendula
 
Constructor Summary
(package private) TPhysCalcs()
          The constructor of the class.
 
Method Summary
 double Accel(double _a)
          Angular acceleration of a single pendulum
 double Accel(double _a, double _b)
          Angular acceleration off the pendula.
 void activateChanges()
          After a parameter is changed this routine is called.
 double atan(double _alpha)
          Java's arctangens is only defined in a certain range of points, this is a work around for angles > 0.5 PI
 void estimateStepsize()
          Use adaptive stepsize velocity verlet on 1 period of simulation of a single pendulum.
 double Inertia()
          The Inertia of the pendula
 void initGraphics()
          Call the initGraphics of both canvases.
 void run()
          This routine is called when a thread is started for this class.
 void setActive()
          Set Active true
 void setInactive()
          Set Active false
 void start()
          start the simulation by setting both canvases to active, and opening a new thread that calls the run method.
 void stop()
          stop the simulation by setting both canvases to inactive, and shutting down the thread.
 void switchActive()
          When called this routine switches the state of the simulation.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Pendul1

public TPendulum Pendul1
First pendulum

Pendul2

public TPendulum Pendul2
Second pendulum

Spiral

public TSpiral3D Spiral
Spring between the two pendula

Arc3D1

public TArc3D Arc3D1
Arc between LinePendul1 and the first pendulum

Arc3D2

public TArc3D Arc3D2
Arc between LinePendul2 and the second pendulum

Sphere1

public TSphere3D Sphere1
Sphere at the top of the first pendulum (suspension point)

Sphere2

public TSphere3D Sphere2
Sphere at the top of the second pendulum (suspension point)

LinePendul1

public TLine3D LinePendul1
Line going through the first pendulum when it is at rest.

LinePendul2

public TLine3D LinePendul2
Line going through the second pendulum when it is at rest.

PhysCanvas

TPhysCanvas PhysCanvas
Canvas onto which all the physical objects are drawn.

Oscilloscope

TOscilloscope Oscilloscope
Oscilloscope canvas.

timerThread

protected java.lang.Thread timerThread
Thread used for calculating and predrawing the physics of the simulation.

Pendul1DataStream

public int Pendul1DataStream
Datastream index of the first pendulum, used to identify the data for the first pendulum in the oscilloscope

Pendul2DataStream

public int Pendul2DataStream
Datastream index of the second pendulum, used to identify the data for the second pendulum in the oscilloscope

t

public double t
Time of the simulation (in milliseconds

VPendul1

public double VPendul1
Angular velocity of the first pendulum

VPendul2

public double VPendul2
Angular velocity of the second pendulum

e_max

public double e_max
Maximum error in the simulation

h_maxinit

public double h_maxinit
Initial maximum stepsize (for use in adaptive stepsize)

perframe

public double perframe
Number of seconds per frame

NOTIMES

public int NOTIMES
Initial number of steps the simulation does between two frames

MASS

public double MASS
Initial mass of the pendula

ALPHA0

public double ALPHA0
Initial angle of the first pendulum in radians

BETA0

public double BETA0
Initial angle of the second pendulum in radians

K

public double K
Initial spring constant K

HEIGHTPENDUL

public double HEIGHTPENDUL
Initial Height of the pendula

WIDTHPENDUL

public double WIDTHPENDUL
Width of the pendula

DEPTHPENDUL

public double DEPTHPENDUL
Depth of the pendula

CM2AXIS

public double CM2AXIS
Distance between center of mass and suspension point of the pendula

G

public double G
Gravitational constant

C

public double C
Distance between suspension point of the pendulum and suspension point of the spring ON the pendulum

Active

public boolean Active
Activity flag
Constructor Detail

TPhysCalcs

TPhysCalcs()
The constructor of the class. It initializes all the physical components
Method Detail

atan

public double atan(double _alpha)
Java's arctangens is only defined in a certain range of points, this is a work around for angles > 0.5 PI
Parameters:
_alpha - The angle in radians for which the arctangens should be calculated

activateChanges

public void activateChanges()
After a parameter is changed this routine is called. It resets all physical elements.

switchActive

public void switchActive()
When called this routine switches the state of the simulation. If it runs, it gets paused, if it is paused it will start runnign again.

initGraphics

public void initGraphics()
Call the initGraphics of both canvases. These initialize the canvas. Initialize the double buffering, a standard technique used in computer animations to get a flicker free image.

start

public void start()
start the simulation by setting both canvases to active, and opening a new thread that calls the run method.

stop

public void stop()
stop the simulation by setting both canvases to inactive, and shutting down the thread.

run

public void run()
This routine is called when a thread is started for this class. It runs until the thread is killed
Specified by:
run in interface java.lang.Runnable

Accel

public double Accel(double _a,
                    double _b)
Angular acceleration off the pendula.
Parameters:
_a - the deviation from the equilibrium position of the pendulum for which the acceleration should be calculated
_b - the deviation from the equilibrium position of the other pendulum

Accel

public double Accel(double _a)
Angular acceleration of a single pendulum
Parameters:
_a - the deviation from the equilibrium position of the pendulum

setActive

public void setActive()
Set Active true

setInactive

public void setInactive()
Set Active false

Inertia

public double Inertia()
The Inertia of the pendula

estimateStepsize

public void estimateStepsize()
Use adaptive stepsize velocity verlet on 1 period of simulation of a single pendulum. The smallest stepsize used is the stepsize that is going to be used by the rest of the simulation.