Nyström modification of fourth-order Runge-Kutta method of a solution of a set of ordinary second order differential equations for dynamics simulations. Works with the second derivative and must consider the first derivative as input. Based on code from Vit Buchta, June 2007. More...
Public Member Functions | |
| NystromIntegrator (ISecondDerivative secondDerivative, double timeStepsize, VectorN initialPosition, VectorN initialVelocity) | |
| A constructor for the Nystrom integrator object. | |
| VectorN | Reset (VectorN initialPosition, VectorN initialVelocity) |
| Resets the Nystrom integrator object. Sets the time to 0 and recalculates the current acceleration. | |
| void | Step (out double newTime, out VectorN newPosition, out VectorN newVelocity, out VectorN newAcceleration) |
| One step of the integration procedure. Recalculates all positions, velocities and current acceleration. Updates the time by a time step. | |
Nyström modification of fourth-order Runge-Kutta method of a solution of a set of ordinary second order differential equations for dynamics simulations. Works with the second derivative and must consider the first derivative as input. Based on code from Vit Buchta, June 2007.
Definition at line 20 of file NystromIntegrator.cs.
| NewGamePhysics.Mathematics.NystromIntegrator.NystromIntegrator | ( | ISecondDerivative | secondDerivative, | |
| double | timeStepsize, | |||
| VectorN | initialPosition, | |||
| VectorN | initialVelocity | |||
| ) |
A constructor for the Nystrom integrator object.
| secondDerivative | An object implementing the ISecondDerivative interface | |
| timeStepsize | The time step | |
| currentPosition | The vector of initial positions | |
| currentVelocity | The vector of initial velocities | |
| initialAcceleration | The vector of initial accelerations |
Definition at line 60 of file NystromIntegrator.cs.
00065 { 00066 this.secondDerivative = secondDerivative; 00067 this.timeStepsize = timeStepsize; 00068 this.Reset(initialPosition, initialVelocity); 00069 }
| VectorN NewGamePhysics.Mathematics.NystromIntegrator.Reset | ( | VectorN | initialPosition, | |
| VectorN | initialVelocity | |||
| ) |
Resets the Nystrom integrator object. Sets the time to 0 and recalculates the current acceleration.
| currentPosition | The vector of initial positions | |
| currentVelocity | The vector of initial velocities |
Definition at line 78 of file NystromIntegrator.cs.
00081 { 00082 // Set initial conditions 00083 this.currentTime = 0.0; 00084 this.currentPosition = initialPosition; 00085 this.currentVelocity = initialVelocity; 00086 00087 // Calculate current acceleration 00088 this.currentAcceleration = secondDerivative.GetValue( 00089 this.currentTime, 00090 this.currentPosition, 00091 this.currentVelocity); 00092 00093 return this.currentAcceleration; 00094 }
| void NewGamePhysics.Mathematics.NystromIntegrator.Step | ( | out double | newTime, | |
| out VectorN | newPosition, | |||
| out VectorN | newVelocity, | |||
| out VectorN | newAcceleration | |||
| ) |
One step of the integration procedure. Recalculates all positions, velocities and current acceleration. Updates the time by a time step.
| newTime | The time at the end of the time interval | |
| newPosition | The vector of next positions | |
| newVelocity | The vector of next velocities | |
| newAcceleration | The vector of next accelerations |
Definition at line 104 of file NystromIntegrator.cs.
00109 { 00110 double timeStepsizeSquared = timeStepsize * timeStepsize; 00111 double timeStepsizeHalf = timeStepsize / 2.0; 00112 VectorN k1 = currentAcceleration; 00113 VectorN k2 = secondDerivative.GetValue(currentTime + timeStepsizeHalf, currentPosition + timeStepsizeHalf * currentVelocity + timeStepsizeSquared / 8 * k1, currentVelocity + timeStepsizeHalf * k1); 00114 VectorN k3 = secondDerivative.GetValue(currentTime + timeStepsizeHalf, currentPosition + timeStepsizeHalf * currentVelocity + timeStepsizeSquared/8 * k2, currentVelocity + timeStepsizeHalf * k2); 00115 VectorN k4 = secondDerivative.GetValue(currentTime + timeStepsize, currentPosition + timeStepsize * currentVelocity + timeStepsizeSquared/2 * k3, currentVelocity + timeStepsize * k3); 00116 00117 newTime = currentTime + timeStepsize; 00118 newPosition = currentPosition + timeStepsize * currentVelocity + timeStepsizeSquared/6 * (k1 + k2 + k3); 00119 newVelocity = currentVelocity + timeStepsize/6 * (k1 + 2 * k2 + 2 * k3 + k4); 00120 newAcceleration = secondDerivative.GetValue(newTime, newPosition, newVelocity); 00121 00122 currentTime = newTime; 00123 currentPosition = newPosition; 00124 currentVelocity = newVelocity; 00125 currentAcceleration = newAcceleration; 00126 }
1.6.2