astro
Class SimpleSol

java.lang.Object
  extended by astro.SimpleSol
All Implemented Interfaces:
SolarPosition

public class SimpleSol
extends Object
implements SolarPosition

A class implementing SolarPosition. It uses a very simple algorithm to calculate the Sun's celestial position.

See Also:
sunpos

Nested Class Summary
static class SimpleSol.Test
          Test purpose.
 
Nested classes/interfaces inherited from interface astro.SolarPosition
SolarPosition.Plato
 
Field Summary
private static double ASUN
          The constant coefficient.
private static double BSUN
          The linear coefficient.
private  Date Clock
          The date used for the calculations.
private static double CSUN
          The quadratic coefficient.
private  double Dec
          Declination of Sun, radians.
private static double LAM
          Constant for excentricity offset.
private  double Lambda
          Ecliptical longitude of the Sun, radians.
private static double NYA
          Constant coefficient for calculating mean anamoly.
private static double NYB
          Linear coefficient for calculating mean anamoly.
private static double NYC
          Quadratic coefficient for calculating mean anamoly.
private  double Ra
          Right ascension of the Sun, radians.
private  boolean RaDecValid
          A boolean marking the availability of ra and declination.
 
Constructor Summary
SimpleSol()
          Constructs an invalid solar position instance.
SimpleSol(Date time)
          Constructs a solar position instance with a specified date.
 
Method Summary
protected  void calcLambda()
          Calculates the ecliptical longitude of the Sun and transfers it into Lambda.
protected  void calcRaDec()
          Calculates the right ascension and the declination of an object with the given ecliptical longitude and a latitude of zero.
 double getDec()
          Returns the declination of the Sun.
 double getEclipticalLongitude()
          Returns the ecliptical longitude of the Sun.
 double getRa()
          Returns the right ascension of the Sun.
 void setDate(Date time)
          Sets the date for which the Sun's position should be evaluated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASUN

private static final double ASUN
The constant coefficient.

See Also:
Constant Field Values

BSUN

private static final double BSUN
The linear coefficient.

See Also:
Constant Field Values

CSUN

private static final double CSUN
The quadratic coefficient.

See Also:
Constant Field Values

LAM

private static final double LAM
Constant for excentricity offset.

See Also:
Constant Field Values

NYA

private static final double NYA
Constant coefficient for calculating mean anamoly.

See Also:
Constant Field Values

NYB

private static final double NYB
Linear coefficient for calculating mean anamoly.

See Also:
Constant Field Values

NYC

private static final double NYC
Quadratic coefficient for calculating mean anamoly.

See Also:
Constant Field Values

Lambda

private double Lambda
Ecliptical longitude of the Sun, radians.


RaDecValid

private boolean RaDecValid
A boolean marking the availability of ra and declination.


Ra

private double Ra
Right ascension of the Sun, radians.


Dec

private double Dec
Declination of Sun, radians.


Clock

private Date Clock
The date used for the calculations.

Constructor Detail

SimpleSol

public SimpleSol()
Constructs an invalid solar position instance. Use of this constructor requires the time to be set with setDate(java.util.Date) before calling any of the position retrieving methods, or an IllegalStateException will be thrown.


SimpleSol

public SimpleSol(Date time)
Constructs a solar position instance with a specified date. With this constructor, all positional retrieving methods can be used instantely.

Method Detail

setDate

public void setDate(Date time)
Sets the date for which the Sun's position should be evaluated. Additionally calculates the ecliptical longitude of the Sun. Invalids ra and dec of the Sun, regardless of equality of this date to the former call to this method.

Specified by:
setDate in interface SolarPosition
Parameters:
time - The date used for calculating the Sun's position.

calcLambda

protected void calcLambda()
Calculates the ecliptical longitude of the Sun and transfers it into Lambda. This method is protected to allow subclasses to interfere with the lambda calculation. It is onlt called after a set of the time with setDate(java.util.Date), therefore a valid date always means a valid lambda.

This method is quadratic in time.


getEclipticalLongitude

public double getEclipticalLongitude()
Returns the ecliptical longitude of the Sun. If this method is called without a prior call to setDate, this method throws an IllegalStateException.

Specified by:
getEclipticalLongitude in interface SolarPosition
Returns:
The ecliptical longitude in radians, confined to 0 to 2PI.

getRa

public double getRa()
Returns the right ascension of the Sun. This method uses a flag to remember prior calls to getRa or getDec to speed up multiple use of this methods.

If this method is called without a prior call to setDate, this method throws an IllegalStateException.

Specified by:
getRa in interface SolarPosition
Returns:
The right ascension in radians, confined to 0 to 2PI.

getDec

public double getDec()
Returns the declination of the Sun. This method uses a flag to remember prior calls to getRa or getDec to speed up multiple use of this methods.

If this method is called without a prior call to setDate, this method throws an IllegalStateException.

Specified by:
getDec in interface SolarPosition
Returns:
The declination in radians.

calcRaDec

protected void calcRaDec()
Calculates the right ascension and the declination of an object with the given ecliptical longitude and a latitude of zero. Relies on a valid Lambda.