Base class for a double pendulum simulation. More...
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. | |
Base class for a double pendulum simulation.
Definition at line 74 of file DoublePendulumSimulationBase.cs.
| 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.
| which | Which hinge to drive. | |
| force | The tangential force to apply to the hinge. |
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).
| which | The hinge to return the value for. |
Definition at line 346 of file DoublePendulumSimulationBase.cs.
| double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAcceleration | ( | ) |
Get pedulum acceleration state (from last calculation).
Definition at line 333 of file DoublePendulumSimulationBase.cs.
| double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAngle | ( | DoublePendulumHinges | which | ) |
Get pedulum angles state (from last calculation).
| which | The hinge to return the value for. |
Definition at line 301 of file DoublePendulumSimulationBase.cs.
| double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetAngle | ( | ) |
Get pedulum angles state (from last calculation).
Definition at line 288 of file DoublePendulumSimulationBase.cs.
| abstract double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetEnergy | ( | ) | [pure virtual] |
Calculates the current total energy of the system.
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.
| 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.
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.
| scale | The scale factor for the size calculation. |
Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.
| abstract double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetSize | ( | ) | [pure virtual] |
Calculate the sizes of each component.
Implemented in NewGamePhysics.PhysicalElements.DoubleRegularPendulumSimulation, and NewGamePhysics.PhysicalElements.DoubleSquarePendulumSimulation.
| double NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetState | ( | DoublePendulumStateValues | which | ) |
Get complete pedulum state (from last calculation).
| which | The type of state value to return. |
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).
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.
| which | The hinge to return the value for. |
Definition at line 323 of file DoublePendulumSimulationBase.cs.
| double [] NewGamePhysics.PhysicalElements.DoublePendulumSimulationBase.GetVelocity | ( | ) |
Get pedulum speeds from last calculation.
Definition at line 310 of file DoublePendulumSimulationBase.cs.
| 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.
| 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.
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.
1.6.2