2001-11-27 18:50:04 -07:00
|
|
|
// astro.h
|
|
|
|
//
|
|
|
|
// Copyright (C) 2001 Chris Laurel <claurel@shatters.net>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
#ifndef _ASTRO_H_
|
|
|
|
#define _ASTRO_H_
|
|
|
|
|
|
|
|
#include <iostream>
|
2002-11-04 10:51:56 -07:00
|
|
|
#include <string>
|
2001-11-27 18:50:04 -07:00
|
|
|
#include <celmath/vecmath.h>
|
|
|
|
#include <celengine/univcoord.h>
|
|
|
|
|
|
|
|
#define SOLAR_ABSMAG 4.83f
|
|
|
|
#define LN_MAG 1.085736
|
2001-12-18 16:00:26 -07:00
|
|
|
#define LY_PER_PARSEC 3.26167
|
2001-11-27 18:50:04 -07:00
|
|
|
#define KM_PER_LY 9466411842000.000
|
|
|
|
#define KM_PER_AU 149597870.7
|
|
|
|
#define AU_PER_LY (KM_PER_LY / KM_PER_AU)
|
|
|
|
|
|
|
|
namespace astro
|
|
|
|
{
|
|
|
|
class Date
|
|
|
|
{
|
|
|
|
public:
|
2002-11-04 10:51:56 -07:00
|
|
|
Date();
|
2001-11-27 18:50:04 -07:00
|
|
|
Date(int Y, int M, int D);
|
|
|
|
Date(double);
|
|
|
|
|
|
|
|
operator double() const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
int year;
|
|
|
|
int month;
|
|
|
|
int day;
|
|
|
|
int hour;
|
|
|
|
int minute;
|
|
|
|
double seconds;
|
|
|
|
};
|
|
|
|
|
2002-10-27 22:21:16 -07:00
|
|
|
bool parseDate(const std::string&, Date&);
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
enum CoordinateSystem
|
|
|
|
{
|
|
|
|
Universal = 0,
|
|
|
|
Ecliptical = 1,
|
|
|
|
Equatorial = 2,
|
|
|
|
Geographic = 3,
|
|
|
|
ObserverLocal = 4,
|
2002-03-14 14:43:52 -07:00
|
|
|
PhaseLock = 5,
|
2002-03-18 18:07:24 -07:00
|
|
|
Chase = 6,
|
2001-11-27 18:50:04 -07:00
|
|
|
};
|
|
|
|
|
2004-03-10 04:01:48 -07:00
|
|
|
enum ReferencePlane
|
|
|
|
{
|
|
|
|
BodyEquator, // planet equator if moon, ecliptic if planet
|
|
|
|
Ecliptic_J2000,
|
|
|
|
Equator_J2000,
|
|
|
|
};
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
float lumToAbsMag(float lum);
|
|
|
|
float lumToAppMag(float lum, float lyrs);
|
|
|
|
float absMagToLum(float mag);
|
|
|
|
float appMagToLum(float mag, float lyrs);
|
|
|
|
float absToAppMag(float absMag, float lyrs);
|
|
|
|
float appToAbsMag(float appMag, float lyrs);
|
|
|
|
float lightYearsToParsecs(float);
|
2005-07-18 11:21:58 -06:00
|
|
|
double lightYearsToParsecs(double);
|
2001-11-27 18:50:04 -07:00
|
|
|
float parsecsToLightYears(float);
|
2005-07-18 11:21:58 -06:00
|
|
|
double parsecsToLightYears(double);
|
2001-11-27 18:50:04 -07:00
|
|
|
float lightYearsToKilometers(float);
|
|
|
|
double lightYearsToKilometers(double);
|
|
|
|
float kilometersToLightYears(float);
|
|
|
|
double kilometersToLightYears(double);
|
|
|
|
float lightYearsToAU(float);
|
|
|
|
double lightYearsToAU(double);
|
|
|
|
float AUtoLightYears(float);
|
|
|
|
float AUtoKilometers(float);
|
2004-03-10 04:01:48 -07:00
|
|
|
double AUtoKilometers(double);
|
2001-11-27 18:50:04 -07:00
|
|
|
float kilometersToAU(float);
|
2002-03-21 15:37:28 -07:00
|
|
|
double kilometersToAU(double);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
2002-03-14 14:43:52 -07:00
|
|
|
float microLightYearsToKilometers(float);
|
|
|
|
double microLightYearsToKilometers(double);
|
|
|
|
float kilometersToMicroLightYears(float);
|
|
|
|
double kilometersToMicroLightYears(double);
|
|
|
|
float microLightYearsToAU(float);
|
|
|
|
double microLightYearsToAU(double);
|
|
|
|
float AUtoMicroLightYears(float);
|
|
|
|
double AUtoMicroLightYears(double);
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
double secondsToJulianDate(double);
|
|
|
|
double julianDateToSeconds(double);
|
|
|
|
|
2001-11-28 09:03:11 -07:00
|
|
|
void decimalToDegMinSec(double angle, int& hours, int& minutes, double& seconds);
|
|
|
|
double degMinSecToDecimal(int hours, int minutes, double seconds);
|
|
|
|
|
2001-11-27 18:50:04 -07:00
|
|
|
float sphereIlluminationFraction(Point3d spherePos,
|
|
|
|
Point3d viewerPos);
|
|
|
|
|
2002-03-21 15:37:28 -07:00
|
|
|
Point3d heliocentricPosition(const UniversalCoord& universal,
|
|
|
|
const Point3f& starPosition);
|
|
|
|
UniversalCoord universalPosition(const Point3d& heliocentric,
|
|
|
|
const Point3f& starPosition);
|
2004-09-28 01:44:34 -06:00
|
|
|
UniversalCoord universalPosition(const Point3d& heliocentric,
|
|
|
|
const UniversalCoord& starPosition);
|
2001-11-27 18:50:04 -07:00
|
|
|
|
|
|
|
Point3f equatorialToCelestialCart(float ra, float dec, float distance);
|
|
|
|
Point3d equatorialToCelestialCart(double ra, double dec, double distance);
|
|
|
|
|
2005-07-13 04:09:58 -06:00
|
|
|
void anomaly(double meanAnomaly, double eccentricity,
|
2001-11-27 18:50:04 -07:00
|
|
|
double& trueAnomaly, double& eccentricAnomaly);
|
|
|
|
double meanEclipticObliquity(double jd);
|
|
|
|
|
|
|
|
extern const double J2000;
|
|
|
|
extern const double speedOfLight; // km/s
|
2002-04-30 00:52:46 -06:00
|
|
|
extern const double G; // gravitational constant
|
|
|
|
extern const double SolarMass;
|
|
|
|
extern const double EarthMass;
|
2002-11-05 01:18:00 -07:00
|
|
|
extern const double LunarMass;
|
2001-11-27 18:50:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// Convert a date structure to a Julian date
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& s, const astro::Date);
|
|
|
|
|
|
|
|
#endif // _ASTRO_H_
|
|
|
|
|