Represents a moving circular object in 2D space under gravity influence. More...
Public Member Functions | |
| CircularObjectSimulation (double objectDiameter, double objectDensity, double gravity, double atmosphereDensity) | |
| Constructor for animated circular object. | |
| void | InitialConditionsAtRest () |
| Resets the initial conditions (position and velocity) for the object to be at rest. | |
| void | SetInitialConditions (double x, double y, double vx, double vy) |
| Sets the initial conditions (position and speed) for the the object simulation. | |
| void | Animate () |
| Animate the circular object. | |
| void | Drive (Vector2 force) |
| Drive ball by force transfer, changing its speed. | |
| void | SetPosition (Vector2 position) |
| Set the ball positions to a point. Resets speed to zero. | |
| void | SetPosition (Vector2 position, double scale) |
| Set the ball positions to a point which is at a particular scale. | |
| Vector2 | GetPosition () |
| Get object positions. | |
| Vector2 | GetPosition (double scale) |
| Get object positions relative to a particular scale. | |
Represents a moving circular object in 2D space under gravity influence.
Definition at line 20 of file CircularObjectSimulation.cs.
| NewGamePhysics.PhysicalElements.CircularObjectSimulation.CircularObjectSimulation | ( | double | objectDiameter, | |
| double | objectDensity, | |||
| double | gravity, | |||
| double | atmosphereDensity | |||
| ) |
Constructor for animated circular object.
| objectDiameter | Object (ball) diameter | |
| objectDensity | Object (ball) material density | |
| gravity | Acceleration due to gravity | |
| atmosphereDensity | The density of the atmosphere |
Definition at line 80 of file CircularObjectSimulation.cs.
00081 { 00082 // Time and stepsize 00083 t = 0; 00084 h = 0.01; 00085 00086 // Drag coefficient (cD) 00087 double dragSphere = DragCoefficient.Sphere; 00088 00089 // Ball mass = density * volume 00090 this.mass = objectDensity * Volume.Sphere(objectDiameter / 2.0); 00091 00092 // Ball acceleration 00093 this.circularObjectAcceleration = 00094 new CircularObjectAcceleration(objectDiameter, objectDensity, dragSphere, -gravity, atmosphereDensity); 00095 00096 // Reset state 00097 this.p = new VectorN(2); 00098 this.v = new VectorN(2); 00099 00100 // Create integrator 00101 this.circularObjectIntegrator = new NystromIntegrator( 00102 (ISecondDerivative)this.circularObjectAcceleration, 00103 this.h, 00104 this.p, 00105 this.v); 00106 this.integratorNeedsReset = false; 00107 00108 // Allocate physical state variables as cache 00109 circularObjectPosition = new Vector2(); 00110 }
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.Animate | ( | ) |
Animate the circular object.
Definition at line 144 of file CircularObjectSimulation.cs.
00145 { 00146 // Check if integrator needs to be reset 00147 if (this.integratorNeedsReset) 00148 { 00149 this.acceleration = circularObjectIntegrator.Reset(this.p, this.v); 00150 } 00151 00152 // Animate ball 00153 // double t; VectorN p, v, acceleration; 00154 circularObjectIntegrator.Step(out t, out p, out v, out acceleration); 00155 }
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.Drive | ( | Vector2 | force | ) |
Drive ball by force transfer, changing its speed.
| force | The force to apply to the object. |
Definition at line 161 of file CircularObjectSimulation.cs.
| Vector2 NewGamePhysics.PhysicalElements.CircularObjectSimulation.GetPosition | ( | double | scale | ) |
Get object positions relative to a particular scale.
| scale | The scale of the ball (pixels/meter). |
Definition at line 220 of file CircularObjectSimulation.cs.
| Vector2 NewGamePhysics.PhysicalElements.CircularObjectSimulation.GetPosition | ( | ) |
Get object positions.
Definition at line 206 of file CircularObjectSimulation.cs.
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.InitialConditionsAtRest | ( | ) |
Resets the initial conditions (position and velocity) for the object to be at rest.
Definition at line 116 of file CircularObjectSimulation.cs.
00117 { 00118 SetInitialConditions(0.0, 0.0, 0.0, 0.0); 00119 }
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.SetInitialConditions | ( | double | x, | |
| double | y, | |||
| double | vx, | |||
| double | vy | |||
| ) |
Sets the initial conditions (position and speed) for the the object simulation.
| x | The x coordinate of the object. | |
| y | The y coordinate of the object. | |
| vx | The x component of the objects speed. | |
| vy | The y component of hte objects speed. |
Definition at line 129 of file CircularObjectSimulation.cs.
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.SetPosition | ( | Vector2 | position, | |
| double | scale | |||
| ) |
Set the ball positions to a point which is at a particular scale.
| position | Scaled position where to place the ball. | |
| scale | The scale of the ball (pixels/meter). |
Definition at line 188 of file CircularObjectSimulation.cs.
| void NewGamePhysics.PhysicalElements.CircularObjectSimulation.SetPosition | ( | Vector2 | position | ) |
Set the ball positions to a point. Resets speed to zero.
| position | Position where to place the ball. |
Definition at line 172 of file CircularObjectSimulation.cs.
1.6.2