Example #1
0
void rocket::print() {
	printf("Time: %02i:%02i:%02i:%02i\n", (int)(time/3600), (int)(time/60)%60, (int)(time)%60, (int)(time*60)%60);
	for (int i = 0; i < parts.size(); i++) {
		parts[i]->print();
	}
	printf("	Velocity: %.4f\n", length(vel));
	printf("	Altitude: %.2f\n", altitude());
	printf("	"); printlatlon(pos);
	DEBUG(printf("	Air density: %f\n", airdensity(altitude())));
	DEBUG(printf("	Mass: %f\n", mass));
	DEBUG(float v = length(vel); printf("	Drag: %f\n", v * v * .5 * crosssection() * airdensity(altitude()) * dragcoef(v)));
}
Example #2
0
    void DiK2World::Load(const DiString& path)
    {
        DI_LOG("Loading world: %s", path.c_str());

        DiK2WorldSerial serial;
        serial.Load(path,this);
        mRootNode->AttachObject(mTerrain);
        
        // sun light
        mSun = make_shared<DiDirLight>();
        DiSceneManager* sm = DiBase::Driver->GetSceneManager();
        DiCullNode* dirNode = sm->GetRootNode()->CreateChild();
        dirNode->AttachObject(mSun);
        mSun->SetColor(DiColor());
        
        DiRadian altitude(DiDegree(mConfigs.mSunAltitude));
        DiVec3 dir(0,-DiMath::Sin(altitude),DiMath::Cos(altitude));
        
        DiRadian azimuth(DiDegree(mConfigs.mSunAzimuth));
        DiQuat rot(azimuth, DiVec3::UNIT_Y);
        dir = rot * dir;
        mSun->SetDirection(dir);
        
        sm->SetAmbientColor(DiColor());
    
        Demi::DiRenderBatchGroup* group = Driver->GetPipeline()->GetBatchGroup(Demi::BATCH_MODEL);
        group->SetPreProcess([this](){
            Driver->GetPipeline()->GetShaderEnvironment()->globalAmbient = mConfigs.mEntityAmbient;
            Driver->GetPipeline()->GetShaderEnvironment()->dirLightsColor[0] = mConfigs.mEntitySunColor;
        });
    }
Example #3
0
void GroundStation::sendDatagram()
{
    QByteArray datagram;
    QDataStream out(&datagram, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_4_3);
    out << altitude();

    udpSocket.writeDatagram(datagram, QHostAddress::LocalHost, 27015);
}
Example #4
0
GpsLayer::GpsLayer(MapWidget *map) :
    AbstractLayer(map),
    m_gps(new GpsClient(this)),
    m_pos(QPointF(0, 0)),
    m_alt(0),
    m_track(0),
    m_speed(0),
    m_fix(false)
{
    setVisible(false);
    connect(m_gps, SIGNAL(position(QPointF)), this, SLOT(position(QPointF)));
    connect(m_gps, SIGNAL(altitude(qreal)), this, SLOT(altitude(qreal)));
    connect(m_gps, SIGNAL(direction(qreal)), this, SLOT(direction(qreal)));
    connect(m_gps, SIGNAL(speed(qreal)), this, SLOT(speed(qreal)));
    connect(m_gps, SIGNAL(connected()), this, SLOT(connected()));
    connect(m_gps, SIGNAL(disconnected()), this, SLOT(disconnected()));
    connect(m_gps, SIGNAL(fixed(bool)), this, SLOT(fixed(bool)));
    m_gps->connectGps();
}
Example #5
0
void rocket::collision() {
	if (altitude() < 0) {
		if (length(vel) > 10) {
			print();
			printf("You crashed going really fast. (%f m/s)\n", length(vel));
			exit(1);
		}
		pos = normalize(pos)*R_EARTH;
		vel = 0;
	}
}
Example #6
0
//
//#############################################################################
//#############################################################################
//
Vector3D&
	Vector3D::operator=(const YawPitchRange &polar)
{
	Check_Object(this);
	Check_Object(&polar);

	Verify(
		Vector3D::Forward.z == 1.0f
		 && Vector3D::Left.x == 1.0f
		 && Vector3D::Up.y == 1.0f
	);
	SinCosPair azimuth(polar.yaw);
	SinCosPair altitude(polar.pitch);
	y = -polar.range * altitude.sine;

	Scalar len = polar.range * altitude.cosine;
	x = len * azimuth.sine;
	z = len * azimuth.cosine;
	return *this;
}
Example #7
0
void loop()
{
  while(1)
  { 
    Serial.print("UTC:");
    UTC();
    Serial.print("Lat:");
    latitude();
    Serial.print("Dir:");
    lat_dir();
    Serial.print("Lon:");
    longitude();
    Serial.print("Dir:");
    lon_dir();
    Serial.print("Alt:");
    altitude();
    Serial.println(' ');
    Serial.println(' ');
  }
}
Example #8
0
int main(int argc, char **argv)
{
    plan_tests(3);

    GeoPoint location(Angle::Degrees(7), Angle::Degrees(45));
    fixed altitude(1300);
    fixed average(2.5);
    SpeedVector wind(Angle::Degrees(60), fixed(20));

    GeoPoint ground_location(Angle::Zero(), Angle::Zero());
    fixed ground_alt;

    EstimateThermalBase(nullptr, location, altitude, average, wind,
                        ground_location, ground_alt);

    ok1(equals(ground_location.longitude.Degrees(), 7.114186));
    ok1(equals(ground_location.latitude.Degrees(), 45.046563));
    ok1(equals(ground_alt, 0));

    return exit_status();
}
Example #9
0
int data_passing(){
 
 
  /*accepting connection*/
  /*creating new socket and checking if the socket can be created*/
  
  

  while(1){
    
    receive = recv(new_socket,reciv_data,BUFFER_SIZE,0);
    
    /*printing in message send from the client*/
    
    reciv_data[receive]= '\0';
    
    if (strcmp(reciv_data,"quit")==0){
      close(new_socket);
      printf("Closing server\n");
      break;	   
    } 
    else if(strcmp(reciv_data,"setupGps")==0){
      //   void setupGPSSyetem();
      printf("In GPS setup\n");
    }
    else{
      printf("%s\n", reciv_data); 
      temp = atoi(reciv_data);
      start(temp);
      lift_off(temp);
      altitude(temp);
    }
  }
      close(socket_tcp);  
     /*Creating a tcp socket and checking if the socket is created suceffuly*/
   
 
      return 0;
   
}
Example #10
0
void ReachableList::addItemsToList(enum MapContents::ListID item)
{
  Distance distance;
  QRect bbox = MapCalc::areaBox(lastPosition, _maxReach);
  int r=0, a=0;
  //qDebug("bounding box: (%d, %d), (%d, %d) (%d x %d km)", bbox.left(),bbox.top(),bbox.right(),bbox.bottom(),0,0);

  if( item == MapContents::WaypointList )
    {
      // Waypoints have different structure treat them here
      QList<Waypoint> &wpList = _globalMapContents->getWaypointList();
      // qDebug("Nr of Waypoints: %d", wpList.count() );

      for ( int i=0; i < wpList.count(); i++ )
        {
          WGSPoint pt = wpList.at(i).wgsPoint;

          if (! bbox.contains(pt))
            {
              //qDebug("Not in bounding box, so ignore! (distance: %d, (%d, %d), %s)", (int)distance.getKilometers(), pt.x(),pt.y(), wpList.at(i)->name.latin1());
              r++;
              continue;
            }
          else
            {
              a++;
              //qDebug("In bounding box, so accept! (distance: %d, %s)", (int)distance.getKilometers(), wpList.at(i)->name.latin1());
            }

          distance.setKilometers(MapCalc::dist(&lastPosition, &pt));

          bool isLandable = false;

          if( wpList.at(i).rwyList.size() > 0 )
            {
              isLandable = wpList.at(i).rwyList.at(0).m_isOpen;
            }


          // check if point is a potential reachable candidate at best LD
          if ( (distance.getKilometers() > _maxReach ) ||
               ! (isLandable ||
                 (wpList.at(i).type == BaseMapElement::Outlanding) )  )
            {
              continue;
            }

          // calculate bearing
          double result = MapCalc::getBearing(lastPosition, pt);
          int bearing = int(rint(result * 180./M_PI));
          Altitude altitude(0);

          ReachablePoint rp( wpList[i],
                             false,
                             distance,
                             bearing,
                             altitude );

          append(rp);
        }
    }
  else
    {
      // get number of elements in the list
      int nr = _globalMapContents->getListLength(item);

      // qDebug("No of sites: %d type %d", nr, item );
      for (int i=0; i<nr; i++ )
        {
          // Get specific site data from current list. We have to distinguish
          // between AirfieldList, GilderSiteList and OutlandingList.
          Airfield* site;

          if( item == MapContents::AirfieldList )
            {
              // Fetch data from airport list
              site = _globalMapContents->getAirfield(i);
            }
          else if( item == MapContents::GliderfieldList )
            {
              // fetch data from glider site list
              site = _globalMapContents->getGliderfield(i);
            }
          else if( item == MapContents::OutLandingList )
            {
              // fetch data from glider site list
              site = _globalMapContents->getOutlanding(i);
            }
          else
            {
              qWarning( "ReachableList::addItemsToList: ListType %d is unknown",
                        item );
              break;
            }

          QString siteName = site->getWPName();
          QString siteIcao = site->getICAO();
          QString siteDescription = site->getName();
          QString siteCountry = site->getCountry();
          short siteType = site->getTypeID();
          float siteFrequency = site->getFrequency();
          WGSPoint siteWgsPosition = site->getWGSPosition();
          QPoint sitePosition = site->getPosition();
          float siteElevation = site->getElevation();
          QString siteComment = site->getComment();
          QList<Runway> siteRwyList = site->getRunwayList();

          if (! bbox.contains(siteWgsPosition) )
            {
              //qDebug("Not in bounding box, so ignore! (distance: %d, (%d, %d), %s)", (int)distance.getKilometers(), pt.x(),pt.y(), site->getName().latin1());
              r++;
              continue;
            }
          else
            {
              a++;
              //qDebug("In bounding box, so accept! (distance: %d, %s)", (int)distance.getKilometers(), site->getName().latin1());
            }
          distance.setKilometers(MapCalc::dist(&lastPosition,&siteWgsPosition));
          // qDebug("%d  %f %f", i, (float)distance.getKilometers(),_maxReach );
          // check if point is a potential reachable candidate at best LD
          if ( distance.getKilometers() > _maxReach )
            {
              continue;
            }

          // calculate bearing
          double result = MapCalc::getBearing(lastPosition, siteWgsPosition);
          short bearing = short(rint(result * 180./M_PI));
          Altitude altitude(0);

          // add all potential reachable points to the list, altitude is calculated later
          ReachablePoint rp( siteName,
                             siteIcao,
                             siteDescription,
                             siteCountry,
                             true,
                             siteType,
                             siteFrequency,
                             siteWgsPosition,
                             sitePosition,
                             siteElevation,
                             siteComment,
                             distance,
                             bearing,
                             altitude,
                             siteRwyList );
          append(rp);

          // qDebug("%s(%d) %f %d° %d", rp.getName().toLatin1().data(), rp.getElevation(),  rp.getDistance().getKilometers(), rp.getBearing(), (int)rp->getArrivalAlt().getMeters() );

        }
    }
  // qDebug("accepted: %d, rejected: %d. Percent reject: %f",a,r,(100.0*r)/(a+r));
}
int tester()
{
//description
  std::vector<std::string> neutrals;
  std::vector<std::string> ions;
  neutrals.push_back("N2");
  neutrals.push_back("CH4");
  neutrals.push_back("C2H");
//ionic system contains neutral system
  ions = neutrals;
  ions.push_back("N2+");
  Scalar MN(14.008L), MC(12.011), MH(1.008L);
  Scalar MN2 = 2.L*MN , MCH4 = MC + 4.L*MH, MC2H = 2.L * MC + MH;
  std::vector<Scalar> Mm;
  Mm.push_back(MN2);
  Mm.push_back(MCH4);
  Mm.push_back(MC2H);

//densities
  std::vector<Scalar> molar_frac;
  molar_frac.push_back(0.95999L);
  molar_frac.push_back(0.04000L);
  molar_frac.push_back(0.00001L);
  molar_frac.push_back(0.L);
  Scalar dens_tot(1e12L);

//hard sphere radius
  std::vector<Scalar> hard_sphere_radius;
  hard_sphere_radius.push_back(2.0675e-8L * 1e-2L); //N2  in cm -> m
  hard_sphere_radius.push_back(2.3482e-8L * 1e-2L); //CH4 in cm -> m
  hard_sphere_radius.push_back(0.L); //C2H

//zenith angle
//not necessary

//photon flux
//not necessary

////cross-section
//not necessary

//altitudes
  Scalar zmin(600.),zmax(1400.),zstep(10.);

//binary diffusion
  Scalar bCN1(1.04e-5 * 1e-4),bCN2(1.76); //cm2 -> m2
  Planet::DiffusionType CN_model(Planet::DiffusionType::Wakeham);
  Scalar bCC1(5.73e16 * 1e-4),bCC2(0.5); //cm2 -> m2
  Planet::DiffusionType CC_model(Planet::DiffusionType::Wilson);
  Scalar bNN1(0.1783 * 1e-4),bNN2(1.81); //cm2 -> m2
  Planet::DiffusionType NN_model(Planet::DiffusionType::Massman);

/************************
 * first level
 ************************/

//altitude
  Planet::Altitude<Scalar,std::vector<Scalar> > altitude(zmin,zmax,zstep);

//neutrals
  Antioch::ChemicalMixture<Scalar> neutral_species(neutrals); 

//ions
  Antioch::ChemicalMixture<Scalar> ionic_species(ions); 

//chapman
//not needed

//binary diffusion
  Planet::BinaryDiffusion<Scalar> N2N2(   Antioch::Species::N2,  Antioch::Species::N2 , bNN1, bNN2, NN_model);
  Planet::BinaryDiffusion<Scalar> N2CH4(  Antioch::Species::N2,  Antioch::Species::CH4, bCN1, bCN2, CN_model);
  Planet::BinaryDiffusion<Scalar> CH4CH4( Antioch::Species::CH4, Antioch::Species::CH4, bCC1, bCC2, CC_model);
  Planet::BinaryDiffusion<Scalar> N2C2H( Antioch::Species::N2, Antioch::Species::C2H);
  Planet::BinaryDiffusion<Scalar> CH4C2H( Antioch::Species::CH4, Antioch::Species::C2H);
  std::vector<std::vector<Planet::BinaryDiffusion<Scalar> > > bin_diff_coeff;
  bin_diff_coeff.resize(2);
  bin_diff_coeff[0].push_back(N2N2);
  bin_diff_coeff[0].push_back(N2CH4);
  bin_diff_coeff[0].push_back(N2C2H);
  bin_diff_coeff[1].push_back(N2CH4);
  bin_diff_coeff[1].push_back(CH4CH4);
  bin_diff_coeff[1].push_back(CH4C2H);


/************************
 * second level
 ************************/

//temperature
  std::vector<Scalar> T0,Tz;
  read_temperature<Scalar>(T0,Tz,"input/temperature.dat");
  std::vector<Scalar> neutral_temperature;
  linear_interpolation(T0,Tz,altitude.altitudes(),neutral_temperature);
  Planet::AtmosphericTemperature<Scalar, std::vector<Scalar> > temperature(neutral_temperature, neutral_temperature, altitude);

//photon opacity
//not needed

//reaction sets
//not needed

/************************
 * third level
 ************************/

//atmospheric mixture
  Planet::AtmosphericMixture<Scalar,std::vector<Scalar>, std::vector<std::vector<Scalar> > > composition(neutral_species, ionic_species, altitude, temperature);
  composition.init_composition(molar_frac,dens_tot);
  composition.set_hard_sphere_radius(hard_sphere_radius);
  composition.initialize();

//kinetics evaluators
//not needed

/************************
 * fourth level
 ************************/

//photon evaluator
//not needed

//molecular diffusion
  Planet::MolecularDiffusionEvaluator<Scalar,std::vector<Scalar>, std::vector<std::vector<Scalar> > > molecular_diffusion(bin_diff_coeff,
                                                                                                                          composition,
                                                                                                                          altitude,
                                                                                                                          temperature);
  molecular_diffusion.make_molecular_diffusion();

//eddy diffusion
//not needed

/************************
 * checks
 ************************/

  molar_frac.pop_back();//get the ion outta here
  Scalar Matm(0.L);
  for(unsigned int s = 0; s < molar_frac.size(); s++)
  {
     Matm += molar_frac[s] * composition.neutral_composition().M(s);
  }
  Matm *= 1e-3L; //to kg

  std::vector<std::vector<Scalar> > densities;
  calculate_densities(densities, dens_tot, molar_frac, zmin,zmax,zstep, temperature.neutral_temperature(), Mm);
//N2, CH4, C2H
  std::vector<std::vector<Scalar> > Dij;
  Dij.resize(2);
  Dij[0].resize(3,0.L);
  Dij[1].resize(3,0.L);

  int return_flag(0);
  for(unsigned int iz = 0; iz < altitude.altitudes().size(); iz++)
  {
      Scalar P = pressure(composition.total_density()[iz],temperature.neutral_temperature()[iz]);
      Scalar T = temperature.neutral_temperature()[iz];
      Dij[0][0] = binary_coefficient(T,P,bNN1,bNN2); //N2 N2
      Dij[1][1] = binary_coefficient(T,P,bCC1 * Antioch::ant_pow(Planet::Constants::Convention::T_standard<Scalar>(),bCC2 + Scalar(1.L)) 
                                              * Planet::Constants::Universal::kb<Scalar>()
                                              / Planet::Constants::Convention::P_normal<Scalar>(),bCC2 + Scalar(1.L)); //CH4 CH4
      Dij[0][1] = binary_coefficient(T,P,bCN1 * Antioch::ant_pow(Planet::Constants::Convention::T_standard<Scalar>(),bCN2),bCN2); //N2 CH4
      Dij[0][2] = binary_coefficient(Dij[0][0],Mm[0],Mm[2]); //N2 C2H
      Dij[1][2] = binary_coefficient(Dij[1][1],Mm[1],Mm[2]); //CH4 C2H
      Dij[1][0] = Dij[0][1]; //CH4 N2
      for(unsigned int s = 0; s < molar_frac.size(); s++)
      {
        Scalar tmp(0.L);
        Scalar M_diff(0.L);
        for(unsigned int medium = 0; medium < 2; medium++)
        {
           if(s == medium)continue;
           tmp += densities[medium][iz]/Dij[medium][s];
        }
        Scalar Ds = (barometry(zmin,altitude.altitudes()[iz],neutral_temperature[iz],Matm,dens_tot) - densities[s][iz]) / tmp;
        for(unsigned int j = 0; j < molar_frac.size(); j++)
        {
           if(s == j)continue;
           M_diff += composition.total_density()[iz] * composition.neutral_molar_fraction()[j][iz] * composition.neutral_composition().M(j);
        }
        M_diff /= Scalar(molar_frac.size() - 1);
        Scalar Dtilde = Ds / (Scalar(1.L) - composition.neutral_molar_fraction()[s][iz] * (Scalar(1.L) - composition.neutral_composition().M(s)/M_diff));

        return_flag = return_flag ||
                      check_test(Dtilde,molecular_diffusion.Dtilde()[s][iz],"D tilde of species at altitude");

      }
      return_flag = return_flag ||
                    check_test(Dij[0][0],molecular_diffusion.binary_coefficient(0,0,T,P),"binary molecular coefficient N2 N2 at altitude") || 
                    check_test(Dij[0][1],molecular_diffusion.binary_coefficient(0,1,T,P),"binary molecular coefficient N2 CH4 at altitude") || 
                    check_test(Dij[0][2],molecular_diffusion.binary_coefficient(0,2,T,P),"binary molecular coefficient N2 C2H at altitude") || 
                    check_test(Dij[1][1],molecular_diffusion.binary_coefficient(1,1,T,P),"binary molecular coefficient CH4 CH4 at altitude") || 
                    check_test(Dij[1][2],molecular_diffusion.binary_coefficient(1,2,T,P),"binary molecular coefficient CH4 C2H at altitude");
  }

  return return_flag;
}
Example #12
0
 bool GeoCoords::operator==(const GeoCoords &other) const
 {
     return (longitude() == other.longitude()
             && latitude() == other.latitude()
             && altitude() == other.altitude());
 }
Example #13
0
void rocket::drag() {
	vec3 dragforce = -vel;
	float v = length(vel);
	dragforce *= .5 * crosssection() * airdensity(altitude()) * dragcoef(v) * v;
	force(dragforce);
}