Game Development Reference
In-Depth Information
//--------------------------------------------------------------------------------//
int DoSimulation(void)
//--------------------------------------------------------------------------------//
{
.
.
.
// new local variables:
double sx1, vx1;
double sy1, vy1;
double sz1, vz1;
.
.
.
// Now we can calculate the position vector at this time
// Old position vector commented out:
//s.i = Vm * cosX * time + xe;
//s.j = (Yb + L * cos(Alpha*3.14/180)) + (Vm * cosY * time) −
(0.5 * g * time * time);
//s.k = Vm * cosZ * time + ze;
// New position vector calculations:
sx1 = xe;
vx1 = Vm * cosX;
sy1 = Yb + L * cos(Alpha * 3.14/180);
vy1 = Vm * cosY;
sz1 = ze;
vz1 = Vm * cosZ;
s.i =((m/Cd) * exp(-(Cd * time)/m) * ((-Cw * Vw * cos(GammaW * 3.14/180))/Cd −
vx1) - (Cw * Vw * cos(GammaW * 3.14/180) * time) / Cd ) -
( (m/Cd) * ((-Cw * Vw * cos(GammaW * 3.14/180))/Cd - vx1) ) + sx1;
s.j = sy1 + ( -(vy1 + (m * g)/Cd) * (m/Cd) * exp(-(Cd*time)/m) −
(m * g * time) / Cd ) + ( (m/Cd) * (vy1 + (m * g)/Cd) );
s.k =((m/Cd) * exp(-(Cd * time)/m) * ((-Cw * Vw * sin(GammaW * 3.14/180))/Cd −
vz1) - (Cw * Vw * sin(GammaW * 3.14/180) * time) / Cd ) -
( (m/Cd) * ((-Cw * Vw * sin(GammaW * 3.14/180))/Cd - vz1) ) + sz1;
.
.
.
}
To take into account the cross wind and drag, you'll need to add some new global
variables to store the wind speed and direction, the mass of the projectile, and the drag
Search Nedrilad ::




Custom Search