astro
Class MoonPosition

java.lang.Object
  extended by astro.MoonPosition

public class MoonPosition
extends Object

A class calculating the position of the moon. It is based on the AstroLib package provided by Mark Huss. He gives no hint about the precision of the formulas used, but from a first test I estimate an accuracy of down to one arc minute.


Nested Class Summary
static class MoonPosition.Test
          Testing purpose mainly.
 
Field Summary
private  double dec
          The declination of the moon.
private  com.mhuss.AstroLib.Lunar moon
          The helper object calculating the moon position.
private  double ra
          The right ascension of the moon.
private  boolean radecvalid
          True if ra,dec are valid.
private  Date when
          The date for which the moon position is valid.
 
Constructor Summary
MoonPosition()
          Constructs a new moon position object.
MoonPosition(Date fordate)
          Constructs a new moon position object for the given date.
 
Method Summary
private  void calcRaDec()
          Calculates the right ascension and the declination of the moon.
 double getDec()
          Returns the declination of the moon for the center of the earth in radians.
 double getDistance()
          Returns the distance to the moon in kilometers.
 double getIlluminatedFraction()
           
 double getLatitude()
          Returns the ecliptical latitude of the moon for the center of the earth in radians.
 double getLongitude()
          Returns the ecliptical longitude of the moon for the center of the earth in radians.
 double getRa()
          Returns the right ascension of the moon for the center of the earth in radians.
 void setDate(Date fordate)
          Sets a (new) date for the moon position object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

when

private Date when
The date for which the moon position is valid.


moon

private com.mhuss.AstroLib.Lunar moon
The helper object calculating the moon position.


ra

private double ra
The right ascension of the moon.


dec

private double dec
The declination of the moon.


radecvalid

private boolean radecvalid
True if ra,dec are valid.

Constructor Detail

MoonPosition

public MoonPosition()
Constructs a new moon position object. The position data may only be retrieved after a date was set.


MoonPosition

public MoonPosition(Date fordate)
Constructs a new moon position object for the given date. Data retrieval may proceed at once.

Method Detail

setDate

public void setDate(Date fordate)
Sets a (new) date for the moon position object. Right ascension and declination are invalidated.


getLongitude

public double getLongitude()
Returns the ecliptical longitude of the moon for the center of the earth in radians.

Throws:
IllegalArgumentException - If no date was set.

getLatitude

public double getLatitude()
Returns the ecliptical latitude of the moon for the center of the earth in radians.

Throws:
IllegalArgumentException - If no date was set.

getRa

public double getRa()
Returns the right ascension of the moon for the center of the earth in radians.

Throws:
IllegalArgumentException - If no date was set.

getDec

public double getDec()
Returns the declination of the moon for the center of the earth in radians.

Throws:
IllegalArgumentException - If no date was set.

getDistance

public double getDistance()
Returns the distance to the moon in kilometers.

Throws:
IllegalArgumentException - If no date was set.

getIlluminatedFraction

public double getIlluminatedFraction()

calcRaDec

private void calcRaDec()
Calculates the right ascension and the declination of the moon. Stores both values for later retrieval.