forked from zpb1992/ReentryTrajectoryGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Atmosphere.cpp
49 lines (41 loc) · 850 Bytes
/
Atmosphere.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Atmosphere.h"
#include "json/json.h"
#include<fstream>
#include<cmath>
#include"Console.h"
Atmosphere::Atmosphere(std::string filename):Configuration(filename)
{
readConfig(filename);
}
Atmosphere::~Atmosphere()
{
}
bool Atmosphere::readConfig(std::string filename)
{
Json::Reader reader;
std::ifstream ifs(filename);
Json::Value root;
reader.parse(ifs, root);
if (ifs)
{
_density = root[getKeyByVar(ToString(_density))].asDouble();
_densityHeight = root[getKeyByVar(ToString(_densityHeight))].asDouble();
}
else
{
//Console::instance()->error("atmosphere read config");
}
return true;
}
bool Atmosphere::writeConfig(std::string filename)
{
return false;
}
double Atmosphere::getAirDensity(double height)
{
return _density*exp(-height/_densityHeight);
}
double Atmosphere::getAirDensity()
{
return _density;
}