- }
-
-
- return false;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGAircraft::MassChange() {
- static FGColumnVector vXYZtank(3);
- float Tw;
- float IXXt, IYYt, IZZt, IXZt;
- unsigned int t;
- unsigned int axis_ctr;
-
- for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
-
- // UPDATE TANK CONTENTS
- //
- // For each engine, cycle through the tanks and draw an equal amount of
- // fuel (or oxidizer) from each active tank. The needed amount of fuel is
- // determined by the engine in the FGEngine class. If more fuel is needed
- // than is available in the tank, then that amount is considered a shortage,
- // and will be drawn from the next tank. If the engine cannot be fed what it
- // needs, it will be considered to be starved, and will shut down.
-
- float Oshortage, Fshortage;
-
- for (unsigned int e=0; e<numEngines; e++) {
- Fshortage = Oshortage = 0.0;
- for (t=0; t<numTanks; t++) {
- switch(Engine[e]->GetType()) {
- case FGEngine::etRocket:
-
- switch(Tank[t]->GetType()) {
- case FGTank::ttFUEL:
- if (Tank[t]->GetSelected()) {
- Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
- numSelectedFuelTanks)*(dt*rate) + Fshortage);
- }
- break;
- case FGTank::ttOXIDIZER:
- if (Tank[t]->GetSelected()) {
- Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
- numSelectedOxiTanks)*(dt*rate) + Oshortage);
- }
- break;
- }
- break;
-
- case FGEngine::etPiston:
- case FGEngine::etTurboJet:
- case FGEngine::etTurboProp:
-
- if (Tank[t]->GetSelected()) {
- Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
- numSelectedFuelTanks)*(dt*rate) + Fshortage);
- }
- break;
- }
- }
- if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
- else Engine[e]->SetStarved(false);
- }
-
- Weight = EmptyWeight;
- for (t=0; t<numTanks; t++)
- Weight += Tank[t]->GetContents();
-
- Mass = Weight / GRAVITY;
- // Calculate new CG here.
-
- Tw = 0;
- for (t=0; t<numTanks; t++) {
- vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
- vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
- vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
-
- Tw += Tank[t]->GetContents();
- }
-
- vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
-
- // Calculate new moments of inertia here
-
- IXXt = IYYt = IZZt = IXZt = 0.0;
- for (t=0; t<numTanks; t++) {
- IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
- IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
- IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
- IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
- }
-
- Ixx = baseIxx + IXXt;
- Iyy = baseIyy + IYYt;
- Izz = baseIzz + IZZt;
- Ixz = baseIxz + IXZt;
-
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGAircraft::FMAero(void) {
- static FGColumnVector vDXYZcg(3);
- static FGColumnVector vAeroBodyForces(3);
- unsigned int axis_ctr,ctr;
-
- for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
-
- for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
- for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
- vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
- }
- }
-
- vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
- vForces += vAeroBodyForces;
-
- // The d*cg distances below, given in inches, are the distances FROM the c.g.
- // TO the reference point. Since the c.g. and ref point are given in inches in
- // the structural system (X positive rearwards) and the body coordinate system
- // is given with X positive out the nose, the dxcg and dzcg values are
- // *rotated* 180 degrees about the Y axis.
-
- vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0; //cg and rp values are in inches
- vDXYZcg(eY) = (vXYZrp(eY) - vXYZcg(eY))/12.0;
- vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
-
- vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
- vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
- vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
-
- for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
- for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
- vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
- }