only white spaces
This commit is contained in:
parent
d4688d206a
commit
5f78545961
1 changed files with 91 additions and 91 deletions
|
@ -33,9 +33,9 @@ static const float KTS2MPS = 0.514444444444;
|
|||
|
||||
enum Config
|
||||
{
|
||||
CONFIG_NONE,
|
||||
CONFIG_APPROACH,
|
||||
CONFIG_CRUISE,
|
||||
CONFIG_NONE,
|
||||
CONFIG_APPROACH,
|
||||
CONFIG_CRUISE,
|
||||
};
|
||||
|
||||
// Generate a graph of lift, drag and L/D against AoA at the specified
|
||||
|
@ -50,70 +50,70 @@ enum Config
|
|||
*/
|
||||
void yasim_graph(Airplane* a, float alt, float kts, int cfg = CONFIG_NONE)
|
||||
{
|
||||
Model* m = a->getModel();
|
||||
State s;
|
||||
|
||||
m->setAir(Atmosphere::getStdPressure(alt),
|
||||
Atmosphere::getStdTemperature(alt),
|
||||
Atmosphere::getStdDensity(alt));
|
||||
Model* m = a->getModel();
|
||||
State s;
|
||||
|
||||
switch (cfg) {
|
||||
case CONFIG_APPROACH:
|
||||
a->loadApproachControls();
|
||||
break;
|
||||
case CONFIG_CRUISE:
|
||||
a->loadCruiseControls();
|
||||
break;
|
||||
case CONFIG_NONE:
|
||||
break;
|
||||
}
|
||||
//if we fake the properties we could also use FGFDM::getExternalInput()
|
||||
m->setAir(Atmosphere::getStdPressure(alt),
|
||||
Atmosphere::getStdTemperature(alt),
|
||||
Atmosphere::getStdDensity(alt));
|
||||
|
||||
switch (cfg) {
|
||||
case CONFIG_APPROACH:
|
||||
a->loadApproachControls();
|
||||
break;
|
||||
case CONFIG_CRUISE:
|
||||
a->loadCruiseControls();
|
||||
break;
|
||||
case CONFIG_NONE:
|
||||
break;
|
||||
}
|
||||
//if we fake the properties we could also use FGFDM::getExternalInput()
|
||||
|
||||
|
||||
m->getBody()->recalc();
|
||||
m->getBody()->recalc();
|
||||
|
||||
for(int deg=-179; deg<=179; deg++) {
|
||||
float aoa = deg * DEG2RAD;
|
||||
Airplane::setupState(aoa, kts * KTS2MPS, 0 ,&s);
|
||||
m->getBody()->reset();
|
||||
m->initIteration();
|
||||
m->calcForces(&s);
|
||||
for(int deg=-179; deg<=179; deg++) {
|
||||
float aoa = deg * DEG2RAD;
|
||||
Airplane::setupState(aoa, kts * KTS2MPS, 0 ,&s);
|
||||
m->getBody()->reset();
|
||||
m->initIteration();
|
||||
m->calcForces(&s);
|
||||
|
||||
float acc[3];
|
||||
m->getBody()->getAccel(acc);
|
||||
Math::tmul33(s.orient, acc, acc);
|
||||
float acc[3];
|
||||
m->getBody()->getAccel(acc);
|
||||
Math::tmul33(s.orient, acc, acc);
|
||||
|
||||
float drag = acc[0] * (-1/9.8);
|
||||
float lift = 1 + acc[2] * (1/9.8);
|
||||
float drag = acc[0] * (-1/9.8);
|
||||
float lift = 1 + acc[2] * (1/9.8);
|
||||
|
||||
printf("%d %g %g %g\n", deg, lift, drag, lift/drag);
|
||||
}
|
||||
printf("%d %g %g %g\n", deg, lift, drag, lift/drag);
|
||||
}
|
||||
}
|
||||
|
||||
void yasim_masses(Airplane* a)
|
||||
{
|
||||
RigidBody* body = a->getModel()->getBody();
|
||||
int i, N = body->numMasses();
|
||||
float pos[3];
|
||||
float m, mass = 0;
|
||||
printf("id posx posy posz mass\n");
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
body->getMassPosition(i, pos);
|
||||
m = body->getMass(i);
|
||||
printf("%d %.3f %.3f %.3f %.3f\n", i, pos[0], pos[1], pos[2], m);
|
||||
mass += m;
|
||||
}
|
||||
printf("Total mass: %g", mass);
|
||||
RigidBody* body = a->getModel()->getBody();
|
||||
int i, N = body->numMasses();
|
||||
float pos[3];
|
||||
float m, mass = 0;
|
||||
printf("id posx posy posz mass\n");
|
||||
for (i = 0; i < N; i++)
|
||||
{
|
||||
body->getMassPosition(i, pos);
|
||||
m = body->getMass(i);
|
||||
printf("%d %.3f %.3f %.3f %.3f\n", i, pos[0], pos[1], pos[2], m);
|
||||
mass += m;
|
||||
}
|
||||
printf("Total mass: %g", mass);
|
||||
}
|
||||
|
||||
int usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <ac.xml> [-m]\n");
|
||||
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
||||
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
||||
return 1;
|
||||
fprintf(stderr, "Usage: yasim <ac.xml> [-g [-a alt] [-s kts] [-approach | -cruise] ]\n");
|
||||
fprintf(stderr, " yasim <ac.xml> [-m]\n");
|
||||
fprintf(stderr, " -g print lift/drag table: aoa, lift, drag, lift/drag \n");
|
||||
fprintf(stderr, " -m print mass distribution table: id, x, y, z, mass \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,50 +137,50 @@ int main(int argc, char** argv)
|
|||
if(a->getFailureMsg())
|
||||
printf("SOLUTION FAILURE: %s\n", a->getFailureMsg());
|
||||
if(!a->getFailureMsg() && argc > 2 ) {
|
||||
if(strcmp(argv[2], "-g") == 0) {
|
||||
float alt = 5000, kts = 100;
|
||||
int cfg = CONFIG_NONE;
|
||||
for(int i=3; i<argc; i++) {
|
||||
if (std::strcmp(argv[i], "-a") == 0) {
|
||||
if(strcmp(argv[2], "-g") == 0) {
|
||||
float alt = 5000, kts = 100;
|
||||
int cfg = CONFIG_NONE;
|
||||
for(int i=3; i<argc; i++) {
|
||||
if (std::strcmp(argv[i], "-a") == 0) {
|
||||
if (i+1 < argc) alt = std::atof(argv[++i]);
|
||||
}
|
||||
else if(std::strcmp(argv[i], "-s") == 0) {
|
||||
else if(std::strcmp(argv[i], "-s") == 0) {
|
||||
if(i+1 < argc) kts = std::atof(argv[++i]);
|
||||
}
|
||||
else if(std::strcmp(argv[i], "-approach") == 0) cfg = CONFIG_APPROACH;
|
||||
else if(std::strcmp(argv[i], "-cruise") == 0) cfg = CONFIG_CRUISE;
|
||||
else return usage();
|
||||
}
|
||||
yasim_graph(a, alt, kts, cfg);
|
||||
}
|
||||
else if(strcmp(argv[2], "-m") == 0) {
|
||||
yasim_masses(a);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Solution results:");
|
||||
float aoa = a->getCruiseAoA() * RAD2DEG;
|
||||
float tail = -1 * a->getTailIncidence() * RAD2DEG;
|
||||
float drag = 1000 * a->getDragCoefficient();
|
||||
float cg[3];
|
||||
a->getModel()->getBody()->getCG(cg);
|
||||
a->getModel()->getBody()->recalc();
|
||||
else if(std::strcmp(argv[i], "-approach") == 0) cfg = CONFIG_APPROACH;
|
||||
else if(std::strcmp(argv[i], "-cruise") == 0) cfg = CONFIG_CRUISE;
|
||||
else return usage();
|
||||
}
|
||||
yasim_graph(a, alt, kts, cfg);
|
||||
}
|
||||
else if(strcmp(argv[2], "-m") == 0) {
|
||||
yasim_masses(a);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("Solution results:");
|
||||
float aoa = a->getCruiseAoA() * RAD2DEG;
|
||||
float tail = -1 * a->getTailIncidence() * RAD2DEG;
|
||||
float drag = 1000 * a->getDragCoefficient();
|
||||
float cg[3];
|
||||
a->getModel()->getBody()->getCG(cg);
|
||||
a->getModel()->getBody()->recalc();
|
||||
|
||||
float SI_inertia[9];
|
||||
a->getModel()->getBody()->getInertiaMatrix(SI_inertia);
|
||||
|
||||
printf(" Iterations: %d\n", a->getSolutionIterations());
|
||||
printf(" Drag Coefficient: %f\n", drag);
|
||||
printf(" Lift Ratio: %f\n", a->getLiftRatio());
|
||||
printf(" Cruise AoA: %f\n", aoa);
|
||||
printf(" Tail Incidence: %f\n", tail);
|
||||
printf("Approach Elevator: %f\n", a->getApproachElevator());
|
||||
printf(" CG: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], cg[2]);
|
||||
printf("Inertia tensor [kg*m^2], origo at CG:\n");
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]);
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]);
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]);
|
||||
}
|
||||
float SI_inertia[9];
|
||||
a->getModel()->getBody()->getInertiaMatrix(SI_inertia);
|
||||
|
||||
printf(" Iterations: %d\n", a->getSolutionIterations());
|
||||
printf(" Drag Coefficient: %f\n", drag);
|
||||
printf(" Lift Ratio: %f\n", a->getLiftRatio());
|
||||
printf(" Cruise AoA: %f\n", aoa);
|
||||
printf(" Tail Incidence: %f\n", tail);
|
||||
printf("Approach Elevator: %f\n", a->getApproachElevator());
|
||||
printf(" CG: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], cg[2]);
|
||||
printf("Inertia tensor [kg*m^2], origo at CG:\n");
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]);
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]);
|
||||
printf(" %7.3f, %7.3f, %7.3f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]);
|
||||
}
|
||||
delete fdm;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue