11 #ifndef GlobeEngine_AstroCommon_h
12 #define GlobeEngine_AstroCommon_h
14 #include "OpenGL_Includes.h"
15 #include <vmmlib/vector.hpp>
46 selectionType(_selectionType), selectionIndex(_selectionIndex)
63 systemInFocus(_systemInFocus), selectionType(_selectionType), selectionIndex(_selectionIndex)
67 static vmml::Vector3i getGregorianDate(
double _currentJulianDate){
70 int a = _currentJulianDate + 32044;
71 int b = (4 * a + 3) / 146097;
72 int c = a - (b * 146097) / 4;
74 int d = (4 * c + 3) / 1461;
75 int e = c - (1461 * d) / 4;
76 int m = (5 * e + 2) / 153;
78 int day = e - (153 * m + 2) / 5 + 1;
79 int month = m + 3 - 12 * (m / 10);
80 int year = b * 100 + d - 4800 + m / 10;
82 return vmml::Vector3i(day, month, year);
102 static double getAUfromParsec(
double distanceInParsec){
103 return distanceInParsec * 206264.806247;
106 static double getKmFromAU(
double rad){
110 static double getAUFromKm(
double rad){
114 static double getAUFromSolarRadii(
double rad){
118 static double getAUFromJupiterRadii(
double rad){
122 static double getKgFromSolarMasses(
double _mass){
126 static double getKgFromJupiterMasses(
double _mass){
130 static double getTonnesFromKg(
double _mass){
131 return _mass * 0.001;
134 static double getDegreesFromHours(
double _hours){
138 static double getDegreesFromMinutes(
double _minutes){
142 static double getDegreesFromSeconds(
double _seconds){
146 static double getDegreesFromArcminutes(
double _arcminutes){
150 static double getDegreesFromArcseconds(
double _arcseconds){
154 static double getRightAscensionFromString(std::string rightAscensionAsString){
155 double rightAscensionHours = atof(rightAscensionAsString.substr(0, 2).c_str());
156 double rightAscensionMinutes = atof(rightAscensionAsString.substr(3, 2).c_str());
157 double rightAscensionSeconds = atof(rightAscensionAsString.substr(6, 2).c_str());
158 double rightAscension = geAstro::getDegreesFromHours(rightAscensionHours) + geAstro::getDegreesFromMinutes(rightAscensionMinutes)
159 + geAstro::getDegreesFromSeconds(rightAscensionSeconds);
161 return rightAscension;
164 static double getDeclinationFromString(std::string declinationAsString){
165 double declinationSignFactor = declinationAsString.substr(0, 1) ==
"-" ? -1.0 : 1.0;
166 double declinationDegrees = atof(declinationAsString.substr(1, 2).c_str());
167 double declinationArcMinutes = atof(declinationAsString.substr(4, 2).c_str());
168 double declinationArcSeconds = atof(declinationAsString.substr(7, 2).c_str());
169 double declination = declinationSignFactor * (declinationDegrees + geAstro::getDegreesFromArcminutes(declinationArcMinutes) +
170 geAstro::getDegreesFromArcseconds(declinationArcSeconds));
174 static int getTemperatureFromSpectralType(std::string st) {
175 if (st.length() == 0){
179 char letter = st.at(0);
181 if (st.length() > 1){
182 if (isdigit(st.at(1))){
183 dig = st.at(1) -
'0';
189 if (letter ==
'O'){
return 30000; }
190 else if (letter ==
'B'){
return 10000 + (9 - dig) * (30000 - 10000) / 9; }
191 else if (letter ==
'A'){
return 7500 + (9 - dig) * (10000 - 7500) / 9; }
192 else if (letter ==
'F'){
return 6000 + (9 - dig) * (7500 - 6000) / 9; }
193 else if (letter ==
'G'){
return 5200 + (9 - dig) * (6000 - 5200) / 9; }
194 else if (letter ==
'K'){
return 3700 + (9 - dig) * (5200 - 3700) / 9; }
195 else if (letter ==
'M'){
return 2400 + (9 - dig) * (3700 - 2400) / 9; }
196 else if (letter ==
'T'){
return 700 + (9 - dig) * (1300 - 700) / 9; }
197 else if (letter ==
'Y'){
return 350; }
int selectionIndex
Definition: AstroCommon.h:38
const double AUperKm
Definition: AstroCommon.h:87
Definition: AstroCommon.h:20
Definition: AstroCommon.h:20
const double solarMass
Definition: AstroCommon.h:90
const double arcMinutesToDegreesFactor
Definition: AstroCommon.h:97
const double minutesToDegreesFactor
Definition: AstroCommon.h:94
Definition: AstroCommon.h:20
Definition: AstroCommon.h:50
UniverseSelectionType
Definition: AstroCommon.h:20
Definition: AstroCommon.h:18
const double KMperAU
Definition: AstroCommon.h:86
Definition: AstroCommon.h:20
int systemInFocus
Definition: AstroCommon.h:52
Definition: AstroCommon.h:20
Definition: AstroCommon.h:20
const double secondsToDegreesFactor
Definition: AstroCommon.h:95
const double jupiterRadiusInAU
Definition: AstroCommon.h:89
int selectionIndex
Definition: AstroCommon.h:54
SystemSelection()
Definition: AstroCommon.h:40
const double jupiterMass
Definition: AstroCommon.h:91
UniverseSelectionType selectionType
Definition: AstroCommon.h:37
UniverseSelection()
Definition: AstroCommon.h:56
Definition: AstroCommon.h:20
const double arcSecondsToDegreesFactor
Definition: AstroCommon.h:98
UniverseSelection(int _systemInFocus, UniverseSelectionType _selectionType, int _selectionIndex)
Definition: AstroCommon.h:62
const double solarRadiusInAU
Definition: AstroCommon.h:88
UniverseSelectionType selectionType
Definition: AstroCommon.h:53
const double hoursToDegreesFactor
Definition: AstroCommon.h:93
Definition: AstroCommon.h:35
SystemSelection(UniverseSelectionType _selectionType, int _selectionIndex)
Definition: AstroCommon.h:45