- java.lang.Object
-
- eu.hansolo.tilesfx.tools.SunMoonCalculator
-
public class SunMoonCalculator extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSunMoonCalculator.TWILIGHTThe set of twilights to calculate (types of rise/set events).
-
Field Summary
Fields Modifier and Type Field Description static doubleAUstatic doubleDEG_TO_RADstatic doubleEARTH_RADIUSstatic doubleFOUR_PIstatic doubleJ2000static doubleJULIAN_DAYS_PER_CENTURYdoublemoonAgeValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonAzValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonDistValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonElValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonRiseValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonSetValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonTransitValues for azimuth, elevation, rise, set, and transit for the Moon.doublemoonTransitElevValues for azimuth, elevation, rise, set, and transit for the Moon.static doublePI_OVER_TWOstatic doubleRAD_TO_DAYstatic doubleRAD_TO_DEGstatic doubleRAD_TO_HOURstatic doubleSECONDS_PER_DAYstatic doubleSIDEREAL_DAY_LENGTHdoublesunAzValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunDistValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunElValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunriseValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunsetValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunTransitValues for azimuth, elevation, rise, set, and transit for the Sun.doublesunTransitElevValues for azimuth, elevation, rise, set, and transit for the Sun.static doubleTWO_PIstatic doubleTWO_PI_INVERSE
-
Constructor Summary
Constructors Constructor Description SunMoonCalculator(int YEAR, int MONTH, int DAY, double LAT_DEG, double LNG_DEG)Main constructor for Sun/Moon calculations.SunMoonCalculator(int year, int month, int day, int h, int m, int s, double latDeg, double lngDeg)Main constructor for Sun/Moon calculations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalcEphemeris(java.time.ZoneId ZONE_ID)voidcalcSunAndMoon()Calculates everything for the Sun and the Moon.static int[]getDate(double JULIAN_DAY)Transforms a Julian day (rise/set/transit fields) to a common date.static java.lang.StringgetDateAsString(double JULIAN_DAY)static java.lang.StringgetDateAsString(double JULIAN_DAY, int TIMEZONE_OFFSET)Returns a date as a string.double[]getMoonDiskOrientationAngles()java.time.ZonedDateTimegetSunrise()java.time.ZonedDateTimegetSunriseBlueHour()java.time.ZonedDateTimegetSunriseCivil()java.time.ZonedDateTimegetSunriseGoldenHour()java.time.ZonedDateTimegetSunset()java.time.ZonedDateTimegetSunsetBlueHour()java.time.ZonedDateTimegetSunsetCivil()java.time.ZonedDateTimegetSunsetGoldenHour()static java.time.ZonedDateTimegetZonedDateTime(double JULIAN_DAY, java.time.ZoneOffset ZONE_OFFSET)static doublenormalizeRadians(double r)Reduce an angle in radians to the range (0 - 2 Pi).voidsetDate(int year, int month, int day)voidsetDate(int year, int month, int day, int h, int m, int s)voidsetDate(java.time.LocalDate DATE)voidsetDate(java.time.LocalDateTime DATE_TIME)voidsetTwilight(SunMoonCalculator.TWILIGHT T)Sets the rise/set times to return.
-
-
-
Field Detail
-
RAD_TO_DEG
public static final double RAD_TO_DEG
- See Also:
- Constant Field Values
-
DEG_TO_RAD
public static final double DEG_TO_RAD
- See Also:
- Constant Field Values
-
RAD_TO_HOUR
public static final double RAD_TO_HOUR
- See Also:
- Constant Field Values
-
RAD_TO_DAY
public static final double RAD_TO_DAY
- See Also:
- Constant Field Values
-
AU
public static final double AU
- See Also:
- Constant Field Values
-
EARTH_RADIUS
public static final double EARTH_RADIUS
- See Also:
- Constant Field Values
-
TWO_PI
public static final double TWO_PI
- See Also:
- Constant Field Values
-
TWO_PI_INVERSE
public static final double TWO_PI_INVERSE
- See Also:
- Constant Field Values
-
FOUR_PI
public static final double FOUR_PI
- See Also:
- Constant Field Values
-
PI_OVER_TWO
public static final double PI_OVER_TWO
- See Also:
- Constant Field Values
-
SIDEREAL_DAY_LENGTH
public static final double SIDEREAL_DAY_LENGTH
- See Also:
- Constant Field Values
-
JULIAN_DAYS_PER_CENTURY
public static final double JULIAN_DAYS_PER_CENTURY
- See Also:
- Constant Field Values
-
SECONDS_PER_DAY
public static final double SECONDS_PER_DAY
- See Also:
- Constant Field Values
-
J2000
public static final double J2000
- See Also:
- Constant Field Values
-
sunAz
public double sunAz
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunEl
public double sunEl
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunrise
public double sunrise
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunset
public double sunset
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunTransit
public double sunTransit
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunTransitElev
public double sunTransitElev
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
sunDist
public double sunDist
Values for azimuth, elevation, rise, set, and transit for the Sun. Angles in radians, rise ... as Julian days in UT. Distance in AU.
-
moonAz
public double moonAz
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonEl
public double moonEl
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonRise
public double moonRise
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonSet
public double moonSet
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonTransit
public double moonTransit
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonAge
public double moonAge
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonTransitElev
public double moonTransitElev
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
moonDist
public double moonDist
Values for azimuth, elevation, rise, set, and transit for the Moon. Angles in radians, rise ... as Julian days in UT. Moon age is the number of days since last new Moon, in days, from 0 to 29.5. Distance in AU.
-
-
Constructor Detail
-
SunMoonCalculator
public SunMoonCalculator(int YEAR, int MONTH, int DAY, double LAT_DEG, double LNG_DEG) throws java.lang.ExceptionMain constructor for Sun/Moon calculations. Observer angles in degrees.- Parameters:
YEAR- The year.MONTH- The month.DAY- The day.LAT_DEG- Latitude for the observer.LNG_DEG- Longitude for the observer.- Throws:
java.lang.Exception- If the date does not exists.
-
SunMoonCalculator
public SunMoonCalculator(int year, int month, int day, int h, int m, int s, double latDeg, double lngDeg) throws java.lang.ExceptionMain constructor for Sun/Moon calculations. Time should be given in Universal Time (UT), observer angles in degrees.- Parameters:
year- The year.month- The month.day- The day.h- The hour.m- Minute.s- Second.latDeg- Latitude for the observer.lngDeg- Longitude for the observer.- Throws:
java.lang.Exception- If the date does not exists.
-
-
Method Detail
-
getDate
public static int[] getDate(double JULIAN_DAY) throws java.lang.ExceptionTransforms a Julian day (rise/set/transit fields) to a common date.- Parameters:
JULIAN_DAY- The Julian day.- Returns:
- A set of integers: year, month, day, hour, minute, second.
- Throws:
java.lang.Exception- If the input date does not exists.
-
getZonedDateTime
public static java.time.ZonedDateTime getZonedDateTime(double JULIAN_DAY, java.time.ZoneOffset ZONE_OFFSET) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDateAsString
public static java.lang.String getDateAsString(double JULIAN_DAY) throws java.lang.Exception- Throws:
java.lang.Exception
-
getDateAsString
public static java.lang.String getDateAsString(double JULIAN_DAY, int TIMEZONE_OFFSET) throws java.lang.ExceptionReturns a date as a string.- Parameters:
JULIAN_DAY- The Juliand day.- Returns:
- The String.
- Throws:
java.lang.Exception- If the date does not exists.
-
normalizeRadians
public static double normalizeRadians(double r)
Reduce an angle in radians to the range (0 - 2 Pi).- Parameters:
r- Value in radians.- Returns:
- The reduced radian value.
-
setTwilight
public void setTwilight(SunMoonCalculator.TWILIGHT T)
Sets the rise/set times to return. Default is for the local horizon.- Parameters:
T- The Twilight.
-
setDate
public void setDate(java.time.LocalDate DATE) throws java.lang.Exception- Throws:
java.lang.Exception
-
setDate
public void setDate(java.time.LocalDateTime DATE_TIME) throws java.lang.Exception- Throws:
java.lang.Exception
-
setDate
public void setDate(int year, int month, int day) throws java.lang.Exception- Throws:
java.lang.Exception
-
setDate
public void setDate(int year, int month, int day, int h, int m, int s) throws java.lang.Exception- Throws:
java.lang.Exception
-
calcSunAndMoon
public void calcSunAndMoon()
Calculates everything for the Sun and the Moon.
-
getMoonDiskOrientationAngles
public double[] getMoonDiskOrientationAngles()
-
calcEphemeris
public void calcEphemeris(java.time.ZoneId ZONE_ID)
-
getSunrise
public java.time.ZonedDateTime getSunrise()
-
getSunset
public java.time.ZonedDateTime getSunset()
-
getSunriseGoldenHour
public java.time.ZonedDateTime getSunriseGoldenHour()
-
getSunsetGoldenHour
public java.time.ZonedDateTime getSunsetGoldenHour()
-
getSunriseCivil
public java.time.ZonedDateTime getSunriseCivil()
-
getSunsetCivil
public java.time.ZonedDateTime getSunsetCivil()
-
getSunriseBlueHour
public java.time.ZonedDateTime getSunriseBlueHour()
-
getSunsetBlueHour
public java.time.ZonedDateTime getSunsetBlueHour()
-
-