com.bbn.openmap.layer.daynight
Class SunPosition

java.lang.Object
  extended by com.bbn.openmap.layer.daynight.SunPosition

public class SunPosition
extends java.lang.Object

SunPosition calculates the latitude/longitude on the Earth that is closest to the Sun, the point on the Earth where the sun is directly overhead.

All of these calculations are based on an epoch, or a starting point where the Sun's position is known. From the reference book, the epoch is 1990 January 0.0.

Also, all of the equations, and understanding of this whole algorithm, was gained from a great book - Practical Astronomy with Your Calculator, by Peter Duffett-Smith, Third Edition, Cambridge University Press 1988.


Field Summary
static double ECCENTRICITY
          Eccentricity of orbit, from Duffett-Smith, chapter 46, table 6.
static double ECLIPTIC_LONGITUDE_EPOCH
          Ecliptic Longitude of earth at 1990 January epoch.
static double ECLIPTIC_LONGITUDE_PERIGEE
          Ecliptic Longitude of of perigee.
static double el0
          The algorithm representation for the moon MOON_EPOCH_MEAN_LONGITUDE, "l".
static double EPOCH_JULIAN_DATE
          Epoch Julian Date.
static double EPOCH_TIME_SECS
          Epoch start time in seconds.
static double epsilon_g
          Variable notation of ECLIPTIC_LONGITUDE_EPOCH from Duffett-Smith.
static double eye
          The algorithm representation for the moon MOON_ORBIT_INCLINATION, "i".
static double MAJOR_AXIS_MOON_ORBIT
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double MEAN_OBLIQUITY_OF_EPOCH
          MEAN_OBLIQUITY_OF_EPOCH gives the mean obliquity of the ecliptic, which is the angle between the planes of the equator and the ecliptic.
static double MOON_ANGULAR_SIZE
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double MOON_ECCENTRICITY
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double MOON_EPOCH_MEAN_LONGITUDE
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double MOON_ORBIT_INCLINATION
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double MOON_PARALLAX
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double N0
          The algorithm representation for the moon NODE_EPOCH_MEAN_LONGITUDE.
static double NODE_EPOCH_MEAN_LONGITUDE
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
static double omega_bar_g
          Variable notation of ECLIPTIC_LONGITUDE_PERIGEE from Duffett-Smith.
static double ORBIT_RADS_PER_DAY
          Constant denoting the number of radians an object would travel if it orbited around the earth in a day.
static double P0
          The algorithm representation for the moon PERIGEE_EPOCH_MEAN_LONGITUDE.
static double PERIGEE_EPOCH_MEAN_LONGITUDE
          Moon parameter, from Duffett-Smith, chapter 65, table 10.
 
Constructor Summary
SunPosition()
           
 
Method Summary
protected static double adjustWithin2PI(double num)
          Little function that resets the input to be within 0 - 2*PI, by adding or subtracting 2PI as needed.
static double calculateJulianDate(java.util.GregorianCalendar cal)
          Given a date from a gregorian calendar, give back a julian date.
static double eccentricAnomaly(double M)
          Use Kepllers's equation to find the eccentric anomaly.
protected static double eclipticToEquatorialAscension(double lambda, double beta)
          Conversion from ecliptic to equatorial coordinates for ascension.
protected static double eclipticToEquatorialDeclination(double lambda, double beta)
          Conversion from ecliptic to equatorial coordinates for declination.
static double greenwichSiderealTime(double julianDate, java.util.GregorianCalendar time)
          Calculate the greenwich sidereal time (GST).
static void main(java.lang.String[] arg)
           
static LatLonPoint moonPosition(long mssue)
          Given the number of milliseconds since the unix epoch, compute position on the earth (lat, lon) such that moon is directly overhead.
protected static double sunEclipticLongitude(double M0)
          Calculate the ecliptic longitude of sun, in radians.
protected static double sunMeanAnomaly(double daysSinceEpoch)
          Calculate the mean anomaly of sun, in radians.
static LatLonPoint sunPosition(long mssue)
          Given the number of milliseconds since the unix epoch, compute position on the earth (lat, lon) such that sun is directly overhead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EPOCH_JULIAN_DATE

public static final double EPOCH_JULIAN_DATE
Epoch Julian Date.

See Also:
Constant Field Values

EPOCH_TIME_SECS

public static final double EPOCH_TIME_SECS
Epoch start time in seconds.

See Also:
Constant Field Values

ORBIT_RADS_PER_DAY

public static double ORBIT_RADS_PER_DAY
Constant denoting the number of radians an object would travel if it orbited around the earth in a day.


ECLIPTIC_LONGITUDE_EPOCH

public static final double ECLIPTIC_LONGITUDE_EPOCH
Ecliptic Longitude of earth at 1990 January epoch. From Duffett-Smith, chapter 46, table 6. (279.403303 degrees converted to radians).

See Also:
Constant Field Values

epsilon_g

public static final double epsilon_g
Variable notation of ECLIPTIC_LONGITUDE_EPOCH from Duffett-Smith.

See Also:
Constant Field Values

ECLIPTIC_LONGITUDE_PERIGEE

public static final double ECLIPTIC_LONGITUDE_PERIGEE
Ecliptic Longitude of of perigee. From Duffett-Smith, chapter 46, table 6. (282.768422 degrees converted to radians).

See Also:
Constant Field Values

omega_bar_g

public static final double omega_bar_g
Variable notation of ECLIPTIC_LONGITUDE_PERIGEE from Duffett-Smith.

See Also:
Constant Field Values

ECCENTRICITY

public static final double ECCENTRICITY
Eccentricity of orbit, from Duffett-Smith, chapter 46, table 6.

See Also:
Constant Field Values

MEAN_OBLIQUITY_OF_EPOCH

public static final double MEAN_OBLIQUITY_OF_EPOCH
MEAN_OBLIQUITY_OF_EPOCH gives the mean obliquity of the ecliptic, which is the angle between the planes of the equator and the ecliptic. Using the algorithm described in Duffett-Smith, chapter 27, this is calculated for the 1990 January epoch to be .4091155 radians (23.440592 degrees).

See Also:
Constant Field Values

MOON_EPOCH_MEAN_LONGITUDE

public static final double MOON_EPOCH_MEAN_LONGITUDE
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values

el0

public static final double el0
The algorithm representation for the moon MOON_EPOCH_MEAN_LONGITUDE, "l".

See Also:
Constant Field Values

PERIGEE_EPOCH_MEAN_LONGITUDE

public static final double PERIGEE_EPOCH_MEAN_LONGITUDE
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values

P0

public static final double P0
The algorithm representation for the moon PERIGEE_EPOCH_MEAN_LONGITUDE.

See Also:
Constant Field Values

NODE_EPOCH_MEAN_LONGITUDE

public static final double NODE_EPOCH_MEAN_LONGITUDE
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values

N0

public static final double N0
The algorithm representation for the moon NODE_EPOCH_MEAN_LONGITUDE.

See Also:
Constant Field Values

MOON_ORBIT_INCLINATION

public static final double MOON_ORBIT_INCLINATION
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values

eye

public static final double eye
The algorithm representation for the moon MOON_ORBIT_INCLINATION, "i".

See Also:
Constant Field Values

MOON_ECCENTRICITY

public static final double MOON_ECCENTRICITY
Moon parameter, from Duffett-Smith, chapter 65, table 10.

See Also:
Constant Field Values

MAJOR_AXIS_MOON_ORBIT

public static final double MAJOR_AXIS_MOON_ORBIT
Moon parameter, from Duffett-Smith, chapter 65, table 10.

See Also:
Constant Field Values

MOON_ANGULAR_SIZE

public static final double MOON_ANGULAR_SIZE
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values

MOON_PARALLAX

public static final double MOON_PARALLAX
Moon parameter, from Duffett-Smith, chapter 65, table 10. In radians.

See Also:
Constant Field Values
Constructor Detail

SunPosition

public SunPosition()
Method Detail

eccentricAnomaly

public static double eccentricAnomaly(double M)
Use Kepllers's equation to find the eccentric anomaly. From Duffett-Smith, chapter 47.

Parameters:
M - the angle that the Sun has moved since it passed through perigee.

sunMeanAnomaly

protected static double sunMeanAnomaly(double daysSinceEpoch)
Calculate the mean anomaly of sun, in radians. From Duffett-Smith, chapter 47.

Parameters:
daysSinceEpoch - number of days since 1990 January epoch.

sunEclipticLongitude

protected static double sunEclipticLongitude(double M0)
Calculate the ecliptic longitude of sun, in radians. From Duffett-Smith, chapter 47.

Parameters:
M0 - sun's mean anomaly, calculated for the requested time relative to the 1990 epoch.

eclipticToEquatorialAscension

protected static double eclipticToEquatorialAscension(double lambda,
                                                      double beta)
Conversion from ecliptic to equatorial coordinates for ascension. From Duffett-Smith, chapter 27.

Parameters:
lambda - ecliptic longitude
beta - ecliptic latitude

eclipticToEquatorialDeclination

protected static double eclipticToEquatorialDeclination(double lambda,
                                                        double beta)
Conversion from ecliptic to equatorial coordinates for declination. From Duffett-Smith, chapter 27.

Parameters:
lambda - ecliptic longitude
beta - ecliptic latitude

calculateJulianDate

public static double calculateJulianDate(java.util.GregorianCalendar cal)
Given a date from a gregorian calendar, give back a julian date. From Duffett-Smith, chapter 4.

Parameters:
cal - Gregorian calendar for requested date.
Returns:
julian date of request.

greenwichSiderealTime

public static double greenwichSiderealTime(double julianDate,
                                           java.util.GregorianCalendar time)
Calculate the greenwich sidereal time (GST). From Duffett-Smith, chapter 12.

Parameters:
julianDate - julian date of request
time - calendar reflecting local time zone change to greenwich
Returns:
GST relative to unix epoch.

sunPosition

public static LatLonPoint sunPosition(long mssue)
Given the number of milliseconds since the unix epoch, compute position on the earth (lat, lon) such that sun is directly overhead. From Duffett-Smith, chapter 46-47.

Parameters:
mssue - milliseconds since unix epoch
Returns:
LatLonPoint of the point on the earth that is closest.

moonPosition

public static LatLonPoint moonPosition(long mssue)
Given the number of milliseconds since the unix epoch, compute position on the earth (lat, lon) such that moon is directly overhead. From Duffett-Smith, chapter 65. Note: This is acting like it works, but I don't have anything to test it against. No promises.

Parameters:
mssue - milliseconds since unix epoch
Returns:
LatLonPoint of the point on the earth that is closest.

adjustWithin2PI

protected static double adjustWithin2PI(double num)
Little function that resets the input to be within 0 - 2*PI, by adding or subtracting 2PI as needed.

Parameters:
num - The number to be modified, if needed.

main

public static void main(java.lang.String[] arg)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details