/
wmigor
/
z-plane
Обзор
Документация
Войти
/
wmigor
/
z-plane
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/src/aircrafts.cpp
308 строк
8 KB
wmigor
сохранение/загрузка
8 часов назад
8 часов назад
81be381
Код
Авторство
О чём код?
#include "aircrafts.h" #include "Wheel.h" #include <asim/Constants.h> #include <asim/Propeller.h> #include <asim/PistonEngine.h> using namespace asim; std::vector<Propeller::Element> buildPropellerElementsC172() { std::vector<Propeller::Element> elements; elements.resize(10); elements[0].radius = 0.1426; elements[0].chord = 0.0845; elements[0].pitch = glm::radians(56.35); elements[0].length = 0.0853; elements[1].radius = 0.2279; elements[1].chord = 0.1132; elements[1].pitch = glm::radians(45.81); elements[1].length = 0.0853; elements[2].radius = 0.3131; elements[2].chord = 0.1419; elements[2].pitch = glm::radians(36.83); elements[2].length = 0.0853; elements[3].radius = 0.3984; elements[3].chord = 0.1392; elements[3].pitch = glm::radians(30.48); elements[3].length = 0.0853; elements[4].radius = 0.4836; elements[4].chord = 0.1268; elements[4].pitch = glm::radians(25.87); elements[4].length = 0.0853; elements[5].radius = 0.5689; elements[5].chord = 0.1144; elements[5].pitch = glm::radians(22.40); elements[5].length = 0.0853; elements[6].radius = 0.6541; elements[6].chord = 0.1021; elements[6].pitch = glm::radians(19.72); elements[6].length = 0.0853; elements[7].radius = 0.7394; elements[7].chord = 0.0897; elements[7].pitch = glm::radians(17.59); elements[7].length = 0.0853; elements[8].radius = 0.8246; elements[8].chord = 0.0774; elements[8].pitch = glm::radians(15.87); elements[8].length = 0.0853; elements[9].radius = 0.9099; elements[9].chord = 0.0651; elements[9].pitch = glm::radians(14.45); elements[9].length = 0.0853; return elements; } std::shared_ptr<Airfoil> createNaca2412Airfoil(double zeroLiftAngle, const std::string &name) { auto airfoil = std::make_shared<Airfoil>(); airfoil->name = name; airfoil->baseSettings.zeroLiftAngle = zeroLiftAngle; return airfoil; } std::shared_ptr<Airfoil> createClarkAirfoil() { auto airfoil = std::make_shared<Airfoil>(); airfoil->name = "Clark"; airfoil->baseSettings.zeroLiftAngle = glm::radians(-5.25); airfoil->baseSettings.dragMin = 0.01; airfoil->baseSettings.liftSlope = 5.1; return airfoil; } void addContactPoints(const AircraftPhysics *physics, RigidBody *body) { for (auto wing : physics->getWings()) { const auto §ions = wing->getSections(); if (sections.empty()) continue; const auto §ion = sections[sections.size() - 1]; auto point = section.getPosition(1.0); body->addContactPoint(point, 0.1); if (section.mirror) body->addContactPoint(glm::reflect(point, asim::Constants::Right), 0.1); } for (auto thruster : physics->getThrusters()) body->addContactPoint(thruster->position, 0.1); } Aircraft *createC172() { auto physics = new AircraftPhysics(); physics->mass = 930.0; physics->inertia = glm::dvec3(2644.0, 4372.0, 1285.0); physics->massCenter = glm::dvec3(0.0, 1.0, 0.0); physics->addWheel(asim::Wheel {glm::dvec3(0.0, -0.1, -0.7), 0.2, glm::radians(30.0)}); physics->addWheel(asim::Wheel {glm::dvec3(-1.0, 0.0, 0.7), 0.2, 0.0}); physics->addWheel(asim::Wheel {glm::dvec3(1.0, 0.0, 0.7), 0.2, 0.0}); auto aircraft = new Aircraft(physics); auto body = aircraft->getBody(); body->position.y = 2.0; auto engine = new PistonEngine(160.0 * Constants::HP_TO_W, 2700.0 / Constants::TO_RPM); Propeller::Config propellerConfig(createClarkAirfoil()); auto elements = buildPropellerElementsC172(); auto propeller = new Propeller(propellerConfig, elements, engine); propeller->position = glm::dvec3(0.0, 1.0, -2.2); physics->addThruster(propeller); Fuselage::Config fuselageConfig; fuselageConfig.position = glm::dvec3(0.0, 1.0, 2.0); auto naca2412zero = createNaca2412Airfoil(0.0, "NACA2412_zero"); auto naca2412 = createNaca2412Airfoil(glm::radians(-2.5), "NACA2412"); physics->addFuselage(new Fuselage(fuselageConfig)); { WingSection wing(naca2412); wing.span = 2.6215; wing.chord = 1.585; wing.dihedral = glm::radians(1.0); wing.incidence = glm::radians(3.0); wing.position = glm::dvec3(0.0, 1.509, -0.09); ControlSurface flap; flap.type = ControlSurfaceType::Flap; flap.start = 0.3; flap.end = 1.0; flap.fraction = 0.3; flap.minAngle = glm::radians(0.0); flap.maxAngle = glm::radians(30.0); wing.controlSurfaces.push_back(flap); WingSection wing2(naca2412); wing2.span = 3.8785; wing2.taper = 0.73; wing2.sweep = glm::radians(-2.5); wing2.twist = glm::radians(-3.0); wing2.twistPower = 1.5; wing2.dihedral = glm::radians(2.5); ControlSurface aileron; aileron.type = ControlSurfaceType::Aileron; aileron.start = 0.0; aileron.end = 0.95; aileron.fraction = 0.2; aileron.minAngle = glm::radians(-20.0); aileron.maxAngle = glm::radians(10.0); wing2.controlSurfaces.push_back(aileron); physics->addWing(new asim::Wing(std::vector<WingSection>({wing, wing2}))); } { WingSection elevator(naca2412zero); elevator.span = 1.7; elevator.chord = 1.3; elevator.taper = 0.5; elevator.position = glm::dvec3(0.0, 1.0, 4.82); ControlSurface flap; flap.type = ControlSurfaceType::Elevator; flap.start = 0.0; flap.end = 1.0; flap.fraction = 0.4; flap.minAngle = glm::radians(-23.0); flap.maxAngle = glm::radians(15.0); elevator.controlSurfaces.push_back(flap); physics->addWing(new asim::Wing(std::vector<WingSection>({elevator}))); } { WingSection rudder(naca2412zero); rudder.span = 1.7; rudder.chord = 1.5; rudder.taper = 0.4; rudder.sweep = glm::radians(39.0); rudder.dihedral = glm::radians(90.0); rudder.position = glm::dvec3(0.0, 1.1, 4.665); rudder.mirror = false; ControlSurface flap; flap.type = ControlSurfaceType::Rudder; flap.start = 0.0; flap.end = 1.0; flap.fraction = 0.5; flap.minAngle = glm::radians(-17.7); flap.maxAngle = glm::radians(17.7); rudder.controlSurfaces.push_back(flap); physics->addWing(new asim::Wing(std::vector<WingSection>({rudder}))); } addContactPoints(physics, body); return aircraft; } Aircraft *createYak55m() { auto physics = new AircraftPhysics(); auto aircraft = new Aircraft(physics); auto body = aircraft->getBody(); body->setMass(1000.0); body->setInertia(glm::dvec3(3000.0, 3500.0, 1200.0)); body->setMassCenter(glm::dvec3(0.0, 1.0, 0.0)); auto naca2412zero = createNaca2412Airfoil(0.0, "NACA2412_zero"); auto naca2412 = createNaca2412Airfoil(glm::radians(-2.5), "NACA2412"); { WingSection wing(naca2412); wing.span = 4.65; wing.chord = 2.095; wing.taper = 0.5; wing.sweep = glm::radians(-1.0); wing.dihedral = glm::radians(2.0); wing.twist = glm::radians(-2.5); wing.incidence = glm::radians(1.5); wing.position = glm::dvec3(0.0, 0.831, -0.1); ControlSurface flap; flap.type = ControlSurfaceType::Flap; flap.start = 0.1; flap.end = 0.4; flap.fraction = 0.4; flap.minAngle = glm::radians(0.0); flap.maxAngle = glm::radians(30.0); wing.controlSurfaces.push_back(flap); ControlSurface aileron; aileron.type = ControlSurfaceType::Aileron; aileron.start = 0.6; aileron.end = 0.95; aileron.fraction = 0.2; aileron.minAngle = glm::radians(0.0); aileron.maxAngle = glm::radians(30.0); wing.controlSurfaces.push_back(aileron); physics->addWing(new asim::Wing(std::vector<WingSection>({wing}))); } { WingSection elevator(naca2412zero); elevator.span = 1.607; elevator.chord = 1.184; elevator.taper = 0.6; elevator.sweep = glm::radians(2.0); elevator.dihedral = glm::radians(0.0); elevator.position = glm::dvec3(0.0, 1.387, 4.54); ControlSurface flap; flap.type = ControlSurfaceType::Elevator; flap.start = 0.0; flap.end = 1.0; flap.fraction = 0.5; flap.minAngle = glm::radians(-30.0); flap.maxAngle = glm::radians(30.0); elevator.controlSurfaces.push_back(flap); physics->addWing(new asim::Wing(std::vector<WingSection>({elevator}))); } { WingSection rudder(naca2412zero); rudder.span = 1.554; rudder.chord = 1.441; rudder.taper = 0.7; rudder.sweep = glm::radians(7.0); rudder.dihedral = glm::radians(90.0); rudder.position = glm::dvec3(0.0, 1.085, 4.54); rudder.mirror = false; ControlSurface flap; flap.type = ControlSurfaceType::Rudder; flap.start = 0.0; flap.end = 1.0; flap.fraction = 0.5; flap.minAngle = glm::radians(-30.0); flap.maxAngle = glm::radians(30.0); rudder.controlSurfaces.push_back(flap); physics->addWing(new asim::Wing(std::vector<WingSection>({rudder}))); } addContactPoints(physics, body); return aircraft; }