# NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase Class Reference

Base class for a double pendulum simulation. More...

Inheritance diagram for NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase:

List of all members.

## Public Member Functions
abstract void | SetInitialConditionsAtRest ()
| Resets the initial conditions (angles and rotational speeds) for the pendulum simulation to a be at rest.
abstract Vector2[] | GetPosition ()
| Calculate pedulum positions.
abstract Vector2[] | GetPosition (Vector2 origin, double scale)
| Calculate scaled and positioned pedulum positions.
abstract double[] | GetSize ()
| Calculate the sizes of each component.
abstract double[] | GetSize (double scale)
| Calculate the sizes of each component with the scale applied.
abstract double | GetEnergy ()
| Calculates the current total energy of the system.
void | SetInitialConditions (double theta1, double omega1, double theta2, double omega2)
| Sets the initial conditions (angles and rotational speeds) for the pendulum simulation. Angles are measured relative to the direction of the gravitational acceleration in a counter-clockwise way.
double | Drive (DoublePendulumHinges which, double force)
| Drive the pendulum with a tangential rotational force applied to a hinge.
void | Animate ()
| Animates the pendulum through one time step.
double[] | GetAngle ()
| Get pedulum angles state (from last calculation).
double | GetAngle (DoublePendulumHinges which)
| Get pedulum angles state (from last calculation).
double[] | GetVelocity ()
| Get pedulum speeds from last calculation.
double | GetVelocity (DoublePendulumHinges which)
| Get A pedulum speed from last calculation.
double[] | GetAcceleration ()
| Get pedulum acceleration state (from last calculation).
double | GetAcceleration (DoublePendulumHinges which)
| Get pedulum acceleration state (from last calculation).
double[] | GetState ()
| Get complete pedulum state (from last calculation).
double | GetState (DoublePendulumStateValues which)
| Get complete pedulum state (from last calculation).
## Properties
double | H`[get, set]`
| Gets or sets the integrator stepsize (time step) in seconds.
double | T`[get, set]`
| Gets or sets the animation parameter (time) in seconds.

## Detailed Description

Base class for a double pendulum simulation.

Definition at line 74 of file DoublePendulumSimulationBase.cs.

## Member Function Documentation

void NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.Animate | ( |  | ) |

Animates the pendulum through one time step.

Apply friction to the hinges modifying speed

Definition at line 267 of file DoublePendulumSimulationBase.cs.

    00268         {
    00269             // Animate pendulum
    00270             // double t; VectorN theta, omega, acceleration;
    00271             this.pendulumIntegrator.Step(
    00272                 out this.t,
    00273                 out this.theta,
    00274                 out this.omega,
    00275                 out this.acceleration);
    00276
    00278             for (int i = 0; i < 2; i++)
    00279             {
    00280                 this.omega[i] = this.FrictionModel.ApplyFriction(this.omega[i]);
    00281             }
    00282         }

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.Drive | ( | DoublePendulumHinges | which,
|  | double | force |
| ) |  |  |

Drive the pendulum with a tangential rotational force applied to a hinge.

Parameters:

  | which | Which hinge to drive.
  | force | The tangential force to apply to the hinge.

Returns:
  The rotational speed change that was applied.

Definition at line 256 of file DoublePendulumSimulationBase.cs.

    00257         {
    00258             // Apply a force to the hinges modifying speed
    00259             double deltaOmega = force * this.H;
    00260             this.omega[(int)which] += deltaOmega;
    00261             return deltaOmega;
    00262         }

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAcceleration | ( | DoublePendulumHinges | which | ) |

Get pedulum acceleration state (from last calculation).

Parameters:

  | which | The hinge to return the value for.

Returns:
  A pendulum acceleration in radians/sec^2.

Definition at line 346 of file DoublePendulumSimulationBase.cs.

    00347         {
    00348             return this.acceleration[(int)which];
    00349         }

double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAcceleration | ( |  | ) |

Get pedulum acceleration state (from last calculation).

Returns:
  Two pendulum accelerations in radians/sec^2.

Definition at line 333 of file DoublePendulumSimulationBase.cs.

    00334         {
    00335             double[] omega = new double[2];
    00336             omega[0] = this.acceleration[0];
    00337             omega[1] = this.acceleration[1];
    00338             return omega;
    00339         }

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAngle | ( | DoublePendulumHinges | which | ) |

Get pedulum angles state (from last calculation).

Parameters:

  | which | The hinge to return the value for.

Returns:
  A pendulum angle in radians.

Definition at line 301 of file DoublePendulumSimulationBase.cs.

    00302         {
    00303             return this.theta[(int)which];
    00304         }

double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAngle | ( |  | ) |

Get pedulum angles state (from last calculation).

Returns:
  Two pendulum angles in radians.

Definition at line 288 of file DoublePendulumSimulationBase.cs.

    00289         {
    00290             double[] angles = new double[2];
    00291             angles[0] = this.theta[0];
    00292             angles[1] = this.theta[1];
    00293             return angles;
    00294         }

abstract double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetEnergy | ( |  | ) | `[pure virtual]`

Calculates the current total energy of the system.

Returns:
  The energy value.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

abstract Vector2 [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetPosition | ( | Vector2 | origin,
|  | double | scale |
| ) |  |  | `[pure virtual]`

Calculate scaled and positioned pedulum positions.

Returns:
  The pendulum positions.

Parameters:

  | origin | Anchor position of double square pendulum.
  | scale | Scaling factor for pendulum in pixels/m.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

abstract Vector2 [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetPosition | ( |  | ) | `[pure virtual]`

Calculate pedulum positions.

Returns:
  The pendulum positions.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

abstract double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetSize | ( | double | scale | ) | `[pure virtual]`

Calculate the sizes of each component with the scale applied.

Parameters:

  | scale | The scale factor for the size calculation.

Returns:
  Array containing size values.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

abstract double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetSize | ( |  | ) | `[pure virtual]`

Calculate the sizes of each component.

Returns:
  Array containing size values.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetState | ( | DoublePendulumStateValues | which | ) |

Get complete pedulum state (from last calculation).

Parameters:

  | which | The type of state value to return.

Returns:
  A pendulum angle, speed or acceleration value in its respective unit.

Definition at line 380 of file DoublePendulumSimulationBase.cs.

    00381         {
    00382             return this.GetState()[(int)which];
    00383         }

double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetState | ( |  | ) |

Get complete pedulum state (from last calculation).

Returns:
  Two pendulum angle, speed and accelerations values each in their respective units.

Definition at line 356 of file DoublePendulumSimulationBase.cs.

    00357         {
    00358             double[] values = new double[6];
    00359             values[(int)DoublePendulumStateValues.Angle1] =
    00360                 this.theta[(int)DoublePendulumHinges.Hinge1];
    00361             values[(int)DoublePendulumStateValues.Angle2] =
    00362                 this.theta[(int)DoublePendulumHinges.Hinge2];
    00363             values[(int)DoublePendulumStateValues.Velocity1]
    00364                 = this.omega[(int)DoublePendulumHinges.Hinge1];
    00365             values[(int)DoublePendulumStateValues.Velocity2]
    00366                 = this.omega[(int)DoublePendulumHinges.Hinge2];
    00367             values[(int)DoublePendulumStateValues.Acceleration1]
    00368                 = this.theta[(int)DoublePendulumHinges.Hinge1];
    00369             values[(int)DoublePendulumStateValues.Acceleration2]
    00370                 = this.theta[(int)DoublePendulumHinges.Hinge2];
    00371             return values;
    00372         }

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetVelocity | ( | DoublePendulumHinges | which | ) |

Get A pedulum speed from last calculation.

Parameters:

  | which | The hinge to return the value for.

Returns:
  A pendulum speed in radians/sec.

Definition at line 323 of file DoublePendulumSimulationBase.cs.

    00324         {
    00325             return this.omega[(int)which];
    00326
    00327         }

double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetVelocity | ( |  | ) |

Get pedulum speeds from last calculation.

Returns:
  Two pendulum speeds in radians/sec.

Definition at line 310 of file DoublePendulumSimulationBase.cs.

    00311         {
    00312             double[] omega = new double[2];
    00313             omega[0] = this.omega[0];
    00314             omega[1] = this.omega[1];
    00315             return omega;
    00316         }

void NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.SetInitialConditions | ( | double | theta1,
|  | double | omega1,
|  | double | theta2,
|  | double | omega2 |
| ) |  |  |

Sets the initial conditions (angles and rotational speeds) for the pendulum simulation. Angles are measured relative to the direction of the gravitational acceleration in a counter-clockwise way.

Parameters:

  | theta1 | Angle of the top square measures along the line from the hinge to the corner across the hinge, in radians. 0.0 is vertically downwards, counter-clockwise is positive.
  | omega1 | Rotational speed of the top pendulum square. In radians per second, counter-clockwise is positive.
  | theta2 | Angle of the bottom square measures along the line from the hinge to the corner across the hinge, in radians. 0.0 is vertically downwards, counter-clockwise is positive.
  | omega2 | Rotational speed of the bottom pendulum square. In radians per second, counter-clockwise is positive.

Definition at line 234 of file DoublePendulumSimulationBase.cs.

    00235         {
    00236             // Store values
    00237             this.theta[0] = theta1;
    00238             this.theta[1] = theta2;
    00239             this.omega[0] = omega1;
    00240             this.omega[1] = omega2;
    00241
    00242             // (Re)create integrator
    00243             this.pendulumIntegrator = new NystromIntegrator(
    00244                 (ISecondDerivative)this.pendulumAcceleration,
    00245                 this.H,
    00246                 this.theta,
    00247                 this.omega);
    00248         }

abstract void NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.SetInitialConditionsAtRest | ( |  | ) | `[pure virtual]`

Resets the initial conditions (angles and rotational speeds) for the pendulum simulation to a be at rest.

Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.

## Property Documentation

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.H`[get, set]`

Gets or sets the integrator stepsize (time step) in seconds.

Definition at line 132 of file DoublePendulumSimulationBase.cs.

double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.T`[get, set]`

Gets or sets the animation parameter (time) in seconds.

Definition at line 141 of file DoublePendulumSimulationBase.cs.

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/PhysicalElements/DoublePendulumSimulationBase.cs