Irrlicht - from Noob to Pro: DatenSonnenSystem.h

#ifndef __DatenSonnenSystem_H
  #define __DatenSonnenSystem_H

#include "VSOP87DLL.h"
#include "Pluto_Moshier.hpp"

using namespace irr;
using namespace core;

/////////////////////////////////////////////////////
// Unsere Struktur zum Speichern der Planetendaten //
/////////////////////////////////////////////////////
struct TPlanetInfo
{
	f32 f_Durchmesser;	//Der Durchmesser des Planeten in km
	f32 f_Periphel;		//Der sonnennaheste Abstand in km
	f32 f_Aphel;		//Der sonnenfernste Abstand in km
	f32 f_Rotation;		//Rotation um 360° (Anzahl der Tage)
	f32 f_NeigungBahnebene;	//Neigung der Bahn (Grad)
	f32 f_NeigungRotAchse;	//Neigung der Rotationsachse (Grad)
	f32 f_OrbitalGeschwindigkeit;	//Tempo (km/s)
};


f32 fMassstab = 100000.0f; //Maßstab der Darstellung
f32 AU_to_KM = 149597870.691f; //AU (Astronomical Unit) in km

//////////////////////////
// Unsere Planetendaten //
//////////////////////////
//Sonne
TPlanetInfo Info_Sonne = { 1390000.0f, 0.0f, 0.0f, 25.4f, 0.0f, 0.0f, 0.0f };
//Merkur
TPlanetInfo Info_Merkur = { 4880.0f, 69700000.0f, 45900000.0f, 58.6f, 7.0f, 0.01f, 47.87f };
//Venus
TPlanetInfo Info_Venus = { 12103.6f, 107400000.0f, 109000000.0f, 224.701f, 3.395f, 177.36f, 35.02f };
//Erde
TPlanetInfo Info_Erde = { 12700.0f, 147100000.0f, 152100000.0f, 1.0f, 0.0f, 23.44f, 29.78f };
//Mond
TPlanetInfo Info_Mond = { 3476.0f, 363300.0f, 405500.0f, 27.322f, 5.145f, 6.68f, 1.023f };
//Mars
TPlanetInfo Info_Mars = { 6800.0f, 206700000.0f, 249100000.0f, 686.980f, 1.85f, 25.19f, 24.13f };
//Ceres
TPlanetInfo Info_Ceres = { 975.0f, 380500000.0f, 446800000.0f, 467.0f, 10.59f, 4.0f, 17.909f };
//Jupiter
TPlanetInfo Info_Jupiter = { 142800.0f, 740900000.0f, 815700000.0f, 4331.272f, 1.305f, 3.13f, 13.07f };
//Saturn
TPlanetInfo Info_Saturn = { 120500.0f, 1347000000.0f, 1507000000.0f, 10757.696f, 2.484f, 26.73f, 9.69f };
//Uranus
TPlanetInfo Info_Uranus = { 51118.0f, 2735000000.0f, 3004000000.0f, 30680.817f, 0.77f, 97.77f, 6.81f };
//Neptun
TPlanetInfo Info_Neptun = { 49528.0f, 4456000000.0f, 4537000000.0f, 60181.308f, 1.769f, 28.32f, 5.43f };
//Pluto
TPlanetInfo Info_Pluto = { 2390.0f, 4425000000.0f, 7375000000.0f, 90452.736f, 17.16f, 122.53f, 4.72f };
//Eris
TPlanetInfo Info_Eris = { 2450.0f, 5662000000.0f, 14593000000.0f, 203405.44f, 44.179f, 0.0f, 3.629f };

#pragma warning(disable : 4244) //Compilerwarnung (f64->f32) ausschalten

///////////////////////////////////////////////
// VSOP87-Positionsberechnung eines Planeten //
///////////////////////////////////////////////
core::vector3df BerechnePosition_Planet(f32 JulDat, int ubPlanet = 0)
{
	//Julianisches Datum ab dem Jahr 2000 berechnen
	f32 fTime = (JulDat - 2451545.0f) / 365250.0f;
	//Heliozentrische Koordinaten
	f64 hXp = 0, hYp = 0, hZp = 0;
	switch(ubPlanet)
	{
	//Merkur
	case 1: hXp = Mercury_X0(fTime) + Mercury_X1(fTime) + Mercury_X2(fTime)
			   + Mercury_X3(fTime) + Mercury_X4(fTime) + Mercury_X5(fTime);
			hYp = Mercury_Y0(fTime) + Mercury_Y1(fTime) + Mercury_Y2(fTime)
			   + Mercury_Y3(fTime) + Mercury_Y4(fTime) + Mercury_Y5(fTime);
			hZp = Mercury_Z0(fTime) + Mercury_Z1(fTime) + Mercury_Z2(fTime)
			   + Mercury_Z3(fTime) + Mercury_Z4(fTime) + Mercury_Z5(fTime);
			break;
	//Venus
	case 2: hXp = Venus_X0(fTime) + Venus_X1(fTime) + Venus_X2(fTime)
				+ Venus_X3(fTime) + Venus_X4(fTime) + Venus_X5(fTime);
			hYp = Venus_Y0(fTime) + Venus_Y1(fTime) + Venus_Y2(fTime)
			   + Venus_Y3(fTime) + Venus_Y4(fTime) + Venus_Y5(fTime);
			hZp = Venus_Z0(fTime) + Venus_Z1(fTime) + Venus_Z2(fTime)
			   + Venus_Z3(fTime) + Venus_Z4(fTime) + Venus_Z5(fTime);
			break; 
	//Erde
	case 3: hXp = Earth_X0(fTime) + Earth_X1(fTime) + Earth_X2(fTime)
			   + Earth_X3(fTime) + Earth_X4(fTime) + Earth_X5(fTime);
			hYp = Earth_Y0(fTime) + Earth_Y1(fTime) + Earth_Y2(fTime)
			   + Earth_Y3(fTime) + Earth_Y4(fTime) + Earth_Y5(fTime);
			hZp = Earth_Z0(fTime) + Earth_Z1(fTime) + Earth_Z2(fTime)
			   + Earth_Z3(fTime) + Earth_Z4(fTime) + Earth_Z5(fTime);
			break;
	//Mars
	case 4: hXp = Mars_X0(fTime) + Mars_X1(fTime) + Mars_X2(fTime)
			   + Mars_X3(fTime) + Mars_X4(fTime) + Mars_X5(fTime);
			hYp = Mars_Y0(fTime) + Mars_Y1(fTime) + Mars_Y2(fTime)
			   + Mars_Y3(fTime) + Mars_Y4(fTime) + Mars_Y5(fTime);
			hZp = Mars_Z0(fTime) + Mars_Z1(fTime) + Mars_Z2(fTime)
			   + Mars_Z3(fTime) + Mars_Z4(fTime) + Mars_Z5(fTime);
			break;
	//Jupiter
	case 5: hXp = Jupiter_X0(fTime) + Jupiter_X1(fTime) + Jupiter_X2(fTime)
			    + Jupiter_X3(fTime) + Jupiter_X4(fTime) + Jupiter_X5(fTime);
			hYp = Jupiter_Y0(fTime) + Jupiter_Y1(fTime) + Jupiter_Y2(fTime)
			    + Jupiter_Y3(fTime) + Jupiter_Y4(fTime) + Jupiter_Y5(fTime);
			hZp = Jupiter_Z0(fTime) + Jupiter_Z1(fTime) + Jupiter_Z2(fTime)
			    + Jupiter_Z3(fTime) + Jupiter_Z4(fTime) + Jupiter_Z5(fTime);
			break;
	//Saturn
	case 6: hXp = Saturn_X0(fTime) + Saturn_X1(fTime) + Saturn_X2(fTime)
			    + Saturn_X3(fTime) + Saturn_X4(fTime) + Saturn_X5(fTime);
			hYp = Saturn_Y0(fTime) + Saturn_Y1(fTime) + Saturn_Y2(fTime)
			    + Saturn_Y3(fTime) + Saturn_Y4(fTime) + Saturn_Y5(fTime);
			hZp = Saturn_Z0(fTime) + Saturn_Z1(fTime) + Saturn_Z2(fTime)
			    + Saturn_Z3(fTime) + Saturn_Z4(fTime) + Saturn_Z5(fTime);
			break;
	//Uranus
	case 7: hXp = Uranus_X0(fTime) + Uranus_X1(fTime) + Uranus_X2(fTime)
			    + Uranus_X3(fTime) + Uranus_X4(fTime) + Uranus_X5(fTime);
			hYp = Uranus_Y0(fTime) + Uranus_Y1(fTime) + Uranus_Y2(fTime)
			    + Uranus_Y3(fTime) + Uranus_Y4(fTime) + Uranus_Y5(fTime);
			hZp = Uranus_Z0(fTime) + Uranus_Z1(fTime) + Uranus_Z2(fTime)
			    + Uranus_Z3(fTime) + Uranus_Z4(fTime) + Uranus_Z5(fTime);
			break;
	//Neptun
	case 8: hXp = Neptune_X0(fTime) + Neptune_X1(fTime) + Neptune_X2(fTime)
			    + Neptune_X3(fTime) + Neptune_X4(fTime) + Neptune_X5(fTime);
			hYp = Neptune_Y0(fTime) + Neptune_Y1(fTime) + Neptune_Y2(fTime)
			    + Neptune_Y3(fTime) + Neptune_Y4(fTime) + Neptune_Y5(fTime);
			hZp = Neptune_Z0(fTime) + Neptune_Z1(fTime) + Neptune_Z2(fTime)
			    + Neptune_Z3(fTime) + Neptune_Z4(fTime) + Neptune_Z5(fTime);
			break; 
	//Pluto
	case 9: double polar[3];
			kepler(JulDat, &orb, polar);
			dms( modtp( polar[0] ) );
			dms( modtp( polar[1] ) );
			hXp = (polar[2] * cos(polar[0]) * cos(polar[1]));
			hYp = (polar[2] * sin(polar[0]) * cos(polar[1]));
			hZp = (polar[2] * sin(polar[1]));
			break;
	}
	//XZY
	return core::vector3df((hXp * AU_to_KM) / fMassstab,
							(hZp * AU_to_KM) / fMassstab, 
							(hYp * AU_to_KM) / fMassstab);
}
#endif