From bb94a6ef5c31a8726f88a9577b743be7952a56e4 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 28 Jun 1999 17:39:20 +0000 Subject: [PATCH] Updates contributed by Jon Berndt. --- src/FDM/JSBSim/FGAircraft.cpp | 11 ++++-- src/FDM/JSBSim/FGCoefficient.cpp | 21 +++++++---- src/FDM/JSBSim/FGCoefficient.h | 6 ++-- src/FDM/JSBSim/FGControls.cpp | 4 +-- src/FDM/JSBSim/FGControls.h | 4 +-- src/FDM/JSBSim/FGMain.cpp | 4 +-- src/FDM/JSBSim/FGMatrix.cpp | 60 ++++++++++++++++---------------- src/FDM/JSBSim/FGOutput.cpp | 6 ++-- 8 files changed, 65 insertions(+), 51 deletions(-) diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index aa5bef805..82d9e4599 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -385,9 +385,14 @@ void FGAircraft::FAero(void) for (int ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++) F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue(); - Forces[0] += F[DragCoeff]*cos(alpha)*cos(beta) - F[SideCoeff]*cos(alpha)*sin(beta) - F[LiftCoeff]*sin(alpha); - Forces[1] += F[DragCoeff]*sin(beta) + F[SideCoeff]*cos(beta); - Forces[2] += F[DragCoeff]*sin(alpha)*cos(beta) - F[SideCoeff]*sin(alpha)*sin(beta) + F[LiftCoeff]*cos(alpha); + Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta) + - F[SideCoeff]*cos(alpha)*sin(beta) + + F[LiftCoeff]*sin(alpha); + Forces[1] += F[DragCoeff]*sin(beta) + + F[SideCoeff]*cos(beta); + Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta) + - F[SideCoeff]*sin(alpha)*sin(beta) + - F[LiftCoeff]*cos(alpha); } diff --git a/src/FDM/JSBSim/FGCoefficient.cpp b/src/FDM/JSBSim/FGCoefficient.cpp index 65d61edaa..0e69bcb75 100644 --- a/src/FDM/JSBSim/FGCoefficient.cpp +++ b/src/FDM/JSBSim/FGCoefficient.cpp @@ -82,8 +82,8 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile) coeffdef["FG_RUDDER"] = 8192; coeffdef["FG_MACH"] = 16384; coeffdef["FG_ALTITUDE"] = 32768L; - coeffdef["FG_I2VEL"] = 65536L; - coeffdef["FG_HALF"] = 131072L; + coeffdef["FG_BI2VEL"] = 65536L; + coeffdef["FG_CI2VEL"] = 131072L; FDMExec = fdex; State = FDMExec->GetState(); @@ -245,10 +245,15 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, ifstream& coeffDefFile) mult_count++; cout << "h "; } - if (multipliers & FG_I2VEL) { - mult_idx[mult_count] = FG_I2VEL; + if (multipliers & FG_BI2VEL) { + mult_idx[mult_count] = FG_BI2VEL; mult_count++; - cout << "1 /(2*Vt) "; + cout << "b /(2*Vt) "; + } + if (multipliers & FG_CI2VEL) { + mult_idx[mult_count] = FG_CI2VEL; + mult_count++; + cout << "c /(2*Vt) "; } cout << endl; @@ -450,8 +455,10 @@ float FGCoefficient::GetCoeffVal(int val_idx) return State->GetMach(); case FG_ALTITUDE: return State->Geth(); - case FG_I2VEL: - return 1.0/(0.5 * State->GetVt()); + case FG_BI2VEL: + return Aircraft->GetWingSpan()/(2.0 * State->GetVt()); + case FG_CI2VEL: + return Aircraft->Getcbar()/(2.0 * State->GetVt()); } return 0; } diff --git a/src/FDM/JSBSim/FGCoefficient.h b/src/FDM/JSBSim/FGCoefficient.h index c28af0dfe..c937c54a6 100644 --- a/src/FDM/JSBSim/FGCoefficient.h +++ b/src/FDM/JSBSim/FGCoefficient.h @@ -75,7 +75,8 @@ using namespace std; #define FG_RUDDER 8192 #define FG_MACH 16384 #define FG_ALTITUDE 32768L -#define FG_I2VEL 65536L +#define FG_BI2VEL 65536L +#define FG_CI2VEL 131072L /******************************************************************************* FORWARD DECLARATIONS @@ -114,7 +115,8 @@ FG_AILERON 4096 FG_RUDDER 8192 FG_MACH 16384 FG_ALTITUDE 32768L -FG_I2VEL 65536L +FG_BI2VEL 65536L +FG_CI2VEL 131072L ******************************************************************************** CLASS DECLARATION diff --git a/src/FDM/JSBSim/FGControls.cpp b/src/FDM/JSBSim/FGControls.cpp index ab2c13c77..c4de8a2ef 100644 --- a/src/FDM/JSBSim/FGControls.cpp +++ b/src/FDM/JSBSim/FGControls.cpp @@ -51,8 +51,8 @@ FGControls::~FGControls() { // $Log$ -// Revision 1.2 1999/06/21 03:01:38 curt -// Updated for both JSBsim and Tony Peden's c172 flight model. +// Revision 1.3 1999/06/28 15:39:23 curt +// Updates contributed by Jon Berndt. // // Revision 1.1 1999/02/13 01:12:03 curt // Initial Revision. diff --git a/src/FDM/JSBSim/FGControls.h b/src/FDM/JSBSim/FGControls.h index 36cfb3300..6ed9c16bd 100644 --- a/src/FDM/JSBSim/FGControls.h +++ b/src/FDM/JSBSim/FGControls.h @@ -177,8 +177,8 @@ extern FGControls controls; // $Log$ -// Revision 1.2 1999/06/21 03:01:39 curt -// Updated for both JSBsim and Tony Peden's c172 flight model. +// Revision 1.3 1999/06/28 15:39:24 curt +// Updates contributed by Jon Berndt. // // Revision 1.1 1999/02/13 01:12:03 curt // Initial Revision. diff --git a/src/FDM/JSBSim/FGMain.cpp b/src/FDM/JSBSim/FGMain.cpp index 93843bdce..08413befd 100644 --- a/src/FDM/JSBSim/FGMain.cpp +++ b/src/FDM/JSBSim/FGMain.cpp @@ -38,9 +38,9 @@ void main(int argc, char** argv) // if (FDMExec->GetState()->Getsim_time() > 5.0) { - FDMExec->GetFCS()->SetDa(0.05); + FDMExec->GetFCS()->SetDe(0.05); // FDMExec->GetFCS()->SetDr(0.05); -// FDMExec->GetFCS()->SetDe(0.05); +// FDMExec->GetFCS()->SetDa(0.05); } FDMExec->Run(); diff --git a/src/FDM/JSBSim/FGMatrix.cpp b/src/FDM/JSBSim/FGMatrix.cpp index 680ca1a20..1c1fcf937 100644 --- a/src/FDM/JSBSim/FGMatrix.cpp +++ b/src/FDM/JSBSim/FGMatrix.cpp @@ -120,8 +120,8 @@ FGMatrix& FGMatrix::operator=(const FGMatrix& A) data = A.data; } else { data = alloc(rows,cols); - for (int i=0; i<=rows; i++) { - for (int j=0; j<=cols; j++) { + for (unsigned int i=0; i<=rows; i++) { + for (unsigned int j=0; j<=cols; j++) { data[i][j] = A.data[i][j]; } } @@ -161,8 +161,8 @@ void FGMatrix::SetOParams(char delim,int width,int prec,int origin) void FGMatrix::InitMatrix(double value) { if (data) { - for (int i=0;i<=rows;i++) { - for (int j=0;j<=cols;j++) { + for (unsigned int i=0;i<=rows;i++) { + for (unsigned int j=0;j<=cols;j++) { operator()(i,j) = value; } } @@ -187,8 +187,8 @@ FGMatrix operator-(FGMatrix& A, FGMatrix& B) FGMatrix Diff(A.Rows(),A.Cols()); Diff.keep=true; - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { Diff(i,j)=A(i,j)-B(i,j); } } @@ -205,8 +205,8 @@ void operator-=(FGMatrix &A,FGMatrix &B) exit(1); } - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { A(i,j)-=B(i,j); } } @@ -224,8 +224,8 @@ FGMatrix operator+(FGMatrix& A, FGMatrix& B) FGMatrix Sum(A.Rows(),A.Cols()); Sum.keep = true; - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { Sum(i,j)=A(i,j)+B(i,j); } } @@ -241,8 +241,8 @@ void operator+=(FGMatrix &A,FGMatrix &B) cout << endl; exit(1); } - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { A(i,j)+=B(i,j); } } @@ -253,8 +253,8 @@ FGMatrix operator*(double scalar,FGMatrix &A) { FGMatrix Product(A.Rows(),A.Cols()); Product.keep = true; - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { Product(i,j) = scalar*A(i,j); } } @@ -264,8 +264,8 @@ FGMatrix operator*(double scalar,FGMatrix &A) void operator*=(FGMatrix &A,double scalar) { - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { A(i,j)*=scalar; } } @@ -284,10 +284,10 @@ FGMatrix operator*(FGMatrix &Left, FGMatrix &Right) FGMatrix Product(Left.Rows(),Right.Cols()); Product.keep = true; - for (int i=1;i<=Left.Rows();i++) { - for (int j=1;j<=Right.Cols();j++) { + for (unsigned int i=1;i<=Left.Rows();i++) { + for (unsigned int j=1;j<=Right.Cols();j++) { Product(i,j) = 0; - for (int k=1;k<=Left.Cols();k++) { + for (unsigned int k=1;k<=Left.Cols();k++) { Product(i,j)+=Left(i,k)*Right(k,j); } } @@ -309,10 +309,10 @@ void operator*=(FGMatrix &Left,FGMatrix &Right) double **prod; prod=alloc(Left.Rows(),Right.Cols()); - for (int i=1;i<=Left.Rows();i++) { - for (int j=1;j<=Right.Cols();j++) { + for (unsigned int i=1;i<=Left.Rows();i++) { + for (unsigned int j=1;j<=Right.Cols();j++) { prod[i][j] = 0; - for (int k=1;k<=Left.Cols();k++) { + for (unsigned int k=1;k<=Left.Cols();k++) { prod[i][j]+=Left(i,k)*Right(k,j); } } @@ -327,8 +327,8 @@ FGMatrix operator/(FGMatrix& A, double scalar) { FGMatrix Quot(A.Rows(),A.Cols()); A.keep = true; - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { Quot(i,j)=A(i,j)/scalar; } } @@ -338,8 +338,8 @@ FGMatrix operator/(FGMatrix& A, double scalar) void operator/=(FGMatrix &A,double scalar) { - for (int i=1;i<=A.Rows();i++) { - for (int j=1;j<=A.Cols();j++) { + for (unsigned int i=1;i<=A.Rows();i++) { + for (unsigned int j=1;j<=A.Cols();j++) { A(i,j)/=scalar; } } @@ -357,8 +357,8 @@ void FGMatrix::T(void) void FGMatrix::TransposeSquare(void) { - for (int i=1;i<=rows;i++) { - for (int j=i+1;j<=cols;j++) { + for (unsigned int i=1;i<=rows;i++) { + for (unsigned int j=i+1;j<=cols;j++) { double tmp=data[i][j]; data[i][j]=data[j][i]; data[j][i]=tmp; @@ -372,8 +372,8 @@ void FGMatrix::TransposeNonSquare(void) double **tran; tran=alloc(rows,cols); - for (int i=1;i<=rows;i++) { - for (int j=1;j<=cols;j++) { + for (unsigned int i=1;i<=rows;i++) { + for (unsigned int j=1;j<=cols;j++) { tran[j][i]=data[i][j]; } } diff --git a/src/FDM/JSBSim/FGOutput.cpp b/src/FDM/JSBSim/FGOutput.cpp index e7aa254c6..abf5bdcac 100644 --- a/src/FDM/JSBSim/FGOutput.cpp +++ b/src/FDM/JSBSim/FGOutput.cpp @@ -190,9 +190,9 @@ void FGOutput::DelimitedOutput(void) cout << "Latitude,"; cout << "Longitude,"; cout << "QBar,"; - cout << "Alpha"; - cout << "L"; - cout << "M"; + cout << "Alpha,"; + cout << "L,"; + cout << "M,"; cout << "N"; cout << endl; FirstPass = false;