1f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/************************************************************************ 2f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Copyright (C) 1996-2008, International Business Machines Corporation * 3f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and others. All Rights Reserved. * 4f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) ************************************************************************ 5f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 2003-nov-07 srl Port from Java 6f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 7f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 8f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#ifndef ASTRO_H 9f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#define ASTRO_H 10f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 11f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/utypes.h" 12f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 13f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#if !UCONFIG_NO_FORMATTING 14f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 15f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "gregoimp.h" // for Math 16f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#include "unicode/unistr.h" 17f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 18f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_BEGIN 19f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 20f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/** 21f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <code>CalendarAstronomer</code> is a class that can perform the calculations to 22f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * determine the positions of the sun and moon, the time of sunrise and 23f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * sunset, and other astronomy-related data. The calculations it performs 24f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * are in some cases quite complicated, and this utility class saves you 25f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the trouble of worrying about them. 26f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 27f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The measurement of time is a very important part of astronomy. Because 28f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * astronomical bodies are constantly in motion, observations are only valid 29f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * at a given moment in time. Accordingly, each <code>CalendarAstronomer</code> 30f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * object has a <code>time</code> property that determines the date 31f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and time for which its calculations are performed. You can set and 32f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * retrieve this property with {@link #setDate setDate}, {@link #getDate getDate} 33f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and related methods. 34f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 35f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Almost all of the calculations performed by this class, or by any 36f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * astronomer, are approximations to various degrees of accuracy. The 37f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * calculations in this class are mostly modelled after those described 38f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * in the book 39f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <a href="http://www.amazon.com/exec/obidos/ISBN=0521356997" target="_top"> 40f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Practical Astronomy With Your Calculator</a>, by Peter J. 41f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Duffett-Smith, Cambridge University Press, 1990. This is an excellent 42f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * book, and if you want a greater understanding of how these calculations 43f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * are performed it a very good, readable starting point. 44f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 45f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <strong>WARNING:</strong> This class is very early in its development, and 46f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * it is highly likely that its API will change to some degree in the future. 47f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * At the moment, it basically does just enough to support {@link IslamicCalendar} 48f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and {@link ChineseCalendar}. 49f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 50f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @author Laura Werner 51f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @author Alan Liu 52f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 53f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 54f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class U_I18N_API CalendarAstronomer : public UMemory { 55f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 56f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // some classes 57f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 58f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 59f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 60f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Represents the position of an object in the sky relative to the ecliptic, 61f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the plane of the earth's orbit around the Sun. 62f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This is a spherical coordinate system in which the latitude 63f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * specifies the position north or south of the plane of the ecliptic. 64f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The longitude specifies the position along the ecliptic plane 65f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * relative to the "First Point of Aries", which is the Sun's position in the sky 66f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * at the Vernal Equinox. 67f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 68f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note that Ecliptic objects are immutable and cannot be modified 69f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * once they are constructed. This allows them to be passed and returned by 70f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * value without worrying about whether other code will modify them. 71f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 72f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Equatorial 73f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Horizon 74f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 75f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 76f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class U_I18N_API Ecliptic : public UMemory { 77f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 78f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 79f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constructs an Ecliptic coordinate object. 80f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 81f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param lat The ecliptic latitude, measured in radians. 82f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param lon The ecliptic longitude, measured in radians. 83f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 84f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 85f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Ecliptic(double lat = 0, double lon = 0) { 86f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) latitude = lat; 87f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) longitude = lon; 88f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) } 89f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 90f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 91f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Setter for Ecliptic Coordinate object 92f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param lat The ecliptic latitude, measured in radians. 93f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param lon The ecliptic longitude, measured in radians. 94f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 95f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 96f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void set(double lat, double lon) { 97f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) latitude = lat; 98f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) longitude = lon; 99f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) } 100f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 101f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 102f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return a string representation of this object 103f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 104f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 105f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UnicodeString toString() const; 106f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 107f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 108f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The ecliptic latitude, in radians. This specifies an object's 109f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * position north or south of the plane of the ecliptic, 110f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * with positive angles representing north. 111f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 112f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 113f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double latitude; 114f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 115f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 116f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The ecliptic longitude, in radians. 117f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This specifies an object's position along the ecliptic plane 118f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * relative to the "First Point of Aries", which is the Sun's position 119f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * in the sky at the Vernal Equinox, 120f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * with positive angles representing east. 121f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 122f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * A bit of trivia: the first point of Aries is currently in the 123f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * constellation Pisces, due to the precession of the earth's axis. 124f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 125f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 126f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double longitude; 127f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 128f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 129f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 130f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Represents the position of an 131f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * object in the sky relative to the plane of the earth's equator. 132f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The <i>Right Ascension</i> specifies the position east or west 133f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * along the equator, relative to the sun's position at the vernal 134f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * equinox. The <i>Declination</i> is the position north or south 135f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * of the equatorial plane. 136f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 137f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note that Equatorial objects are immutable and cannot be modified 138f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * once they are constructed. This allows them to be passed and returned by 139f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * value without worrying about whether other code will modify them. 140f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 141f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Ecliptic 142f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Horizon 143f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 144f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 145f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class U_I18N_API Equatorial : public UMemory { 146f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 147f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 148f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constructs an Equatorial coordinate object. 149f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 150f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param asc The right ascension, measured in radians. 151f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param dec The declination, measured in radians. 152f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 153f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 154f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial(double asc = 0, double dec = 0) 155f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) : ascension(asc), declination(dec) { } 156f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 157f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 158f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Setter 159f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param asc The right ascension, measured in radians. 160f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param dec The declination, measured in radians. 161f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 162f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 163f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void set(double asc, double dec) { 164f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) ascension = asc; 165f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) declination = dec; 166f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) } 167f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 168f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 169f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return a string representation of this object, with the 170f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * angles measured in degrees. 171f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 172f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 173f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UnicodeString toString() const; 174f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 175f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 176f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return a string representation of this object with the right ascension 177f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * measured in hours, minutes, and seconds. 178f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 179f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 180f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //String toHmsString() { 181f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //return radToHms(ascension) + "," + radToDms(declination); 182f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //} 183f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 184f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 185f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The right ascension, in radians. 186f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This is the position east or west along the equator 187f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * relative to the sun's position at the vernal equinox, 188f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * with positive angles representing East. 189f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 190f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 191f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double ascension; 192f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 193f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 194f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The declination, in radians. 195f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This is the position north or south of the equatorial plane, 196f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * with positive angles representing north. 197f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 198f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 199f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double declination; 200f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 201f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 202f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 203f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Represents the position of an object in the sky relative to 204f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the local horizon. 205f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The <i>Altitude</i> represents the object's elevation above the horizon, 206f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * with objects below the horizon having a negative altitude. 207f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The <i>Azimuth</i> is the geographic direction of the object from the 208f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * observer's position, with 0 representing north. The azimuth increases 209f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * clockwise from north. 210f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 211f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note that Horizon objects are immutable and cannot be modified 212f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * once they are constructed. This allows them to be passed and returned by 213f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * value without worrying about whether other code will modify them. 214f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 215f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Ecliptic 216f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see CalendarAstronomer.Equatorial 217f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 218f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 219f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class U_I18N_API Horizon : public UMemory { 220f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 221f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 222f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constructs a Horizon coordinate object. 223f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 224f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param alt The altitude, measured in radians above the horizon. 225f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param azim The azimuth, measured in radians clockwise from north. 226f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 227f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 228f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Horizon(double alt=0, double azim=0) 229f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) : altitude(alt), azimuth(azim) { } 230f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 231f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 232f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Setter for Ecliptic Coordinate object 233f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param alt The altitude, measured in radians above the horizon. 234f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param azim The azimuth, measured in radians clockwise from north. 235f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 236f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 237f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void set(double alt, double azim) { 238f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) altitude = alt; 239f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) azimuth = azim; 240f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) } 241f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 242f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 243f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return a string representation of this object, with the 244f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * angles measured in degrees. 245f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 246f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 247f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UnicodeString toString() const; 248f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 249f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 250f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The object's altitude above the horizon, in radians. 251f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 252f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 253f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double altitude; 254f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 255f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 256f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The object's direction, in radians clockwise from north. 257f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 258f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 259f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double azimuth; 260f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 261f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 262f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 263f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 264f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Assorted private data used for conversions 265f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 266f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 267f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // My own copies of these so compilers are more likely to optimize them away 268f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static const double PI; 269f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 270f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 271f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The average number of solar days from one new moon to the next. This is the time 272f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * it takes for the moon to return the same ecliptic longitude as the sun. 273f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * It is longer than the sidereal month because the sun's longitude increases 274f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * during the year due to the revolution of the earth around the sun. 275f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Approximately 29.53. 276f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 277f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #SIDEREAL_MONTH 278f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 279f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @deprecated ICU 2.4. This class may be removed or modified. 280f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 281f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static const double SYNODIC_MONTH; 282f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 283f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 284f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Constructors 285f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 286f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 287f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 288f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Construct a new <code>CalendarAstronomer</code> object that is initialized to 289f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the current date and time. 290f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 291f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 292f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) CalendarAstronomer(); 293f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 294f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 295f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Construct a new <code>CalendarAstronomer</code> object that is initialized to 296f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the specified date and time. 297f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 298f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 299f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) CalendarAstronomer(UDate d); 300f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 301f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 302f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Construct a new <code>CalendarAstronomer</code> object with the given 303f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * latitude and longitude. The object's time is set to the current 304f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * date and time. 305f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 306f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param longitude The desired longitude, in <em>degrees</em> east of 307f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the Greenwich meridian. 308f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 309f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param latitude The desired latitude, in <em>degrees</em>. Positive 310f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * values signify North, negative South. 311f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 312f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see java.util.Date#getTime() 313f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 314f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 315f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) CalendarAstronomer(double longitude, double latitude); 316f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 317f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 318f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Destructor 319f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 320f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 321f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) ~CalendarAstronomer(); 322f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 323f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 324f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Time and date getters and setters 325f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 326f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 327f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 328f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Set the current date and time of this <code>CalendarAstronomer</code> object. All 329f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * astronomical calculations are performed based on this time setting. 330f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 331f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param aTime the date and time, expressed as the number of milliseconds since 332f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1/1/1970 0:00 GMT (Gregorian). 333f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 334f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #setDate 335f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getTime 336f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 337f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 338f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void setTime(UDate aTime); 339f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 340f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 341f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 342f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Set the current date and time of this <code>CalendarAstronomer</code> object. All 343f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * astronomical calculations are performed based on this time setting. 344f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 345f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param aTime the date and time, expressed as the number of milliseconds since 346f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1/1/1970 0:00 GMT (Gregorian). 347f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 348f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getTime 349f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 350f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 351f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void setDate(UDate aDate) { setTime(aDate); } 352f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 353f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 354f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Set the current date and time of this <code>CalendarAstronomer</code> object. All 355f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * astronomical calculations are performed based on this time setting. 356f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 357f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param jdn the desired time, expressed as a "julian day number", 358f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * which is the number of elapsed days since 359f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1/1/4713 BC (Julian), 12:00 GMT. Note that julian day 360f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * numbers start at <em>noon</em>. To get the jdn for 361f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the corresponding midnight, subtract 0.5. 362f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 363f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getJulianDay 364f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #JULIAN_EPOCH_MS 365f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 366f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 367f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void setJulianDay(double jdn); 368f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 369f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 370f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Get the current time of this <code>CalendarAstronomer</code> object, 371f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * represented as the number of milliseconds since 372f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1/1/1970 AD 0:00 GMT (Gregorian). 373f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 374f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #setTime 375f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getDate 376f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 377f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 378f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getTime(); 379f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 380f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 381f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Get the current time of this <code>CalendarAstronomer</code> object, 382f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * expressed as a "julian day number", which is the number of elapsed 383f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * days since 1/1/4713 BC (Julian), 12:00 GMT. 384f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 385f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #setJulianDay 386f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #JULIAN_EPOCH_MS 387f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 388f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 389f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getJulianDay(); 390f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 391f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 392f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return this object's time expressed in julian centuries: 393f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the number of centuries after 1/1/1900 AD, 12:00 GMT 394f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 395f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getJulianDay 396f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 397f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 398f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getJulianCentury(); 399f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 400f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 401f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Returns the current Greenwich sidereal time, measured in hours 402f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 403f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 404f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getGreenwichSidereal(); 405f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 406f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private: 407f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getSiderealOffset(); 408f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 409f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 410f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Returns the current local sidereal time, measured in hours 411f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 412f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 413f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getLocalSidereal(); 414f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 415f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 416f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Converts local sidereal time to Universal Time. 417f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 418f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param lst The Local Sidereal Time, in hours since sidereal midnight 419f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * on this object's current date. 420f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 421f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return The corresponding Universal Time, in milliseconds since 422f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 1 Jan 1970, GMT. 423f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 424f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //private: 425f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double lstToUT(double lst); 426f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 427f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 428f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 429f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Convert from ecliptic to equatorial coordinates. 430f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 431f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param ecliptic The ecliptic 432f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param result Fillin result 433f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return reference to result 434f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 435f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial& eclipticToEquatorial(Equatorial& result, const Ecliptic& ecliptic); 436f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 437f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 438f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Convert from ecliptic to equatorial coordinates. 439f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 440f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param eclipLong The ecliptic longitude 441f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param eclipLat The ecliptic latitude 442f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 443f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return The corresponding point in equatorial coordinates. 444f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 445f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 446f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial& eclipticToEquatorial(Equatorial& result, double eclipLong, double eclipLat); 447f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 448f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 449f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Convert from ecliptic longitude to equatorial coordinates. 450f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 451f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param eclipLong The ecliptic longitude 452f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 453f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return The corresponding point in equatorial coordinates. 454f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 455f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 456f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial& eclipticToEquatorial(Equatorial& result, double eclipLong) ; 457f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 458f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 459f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 460f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 461f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Horizon& eclipticToHorizon(Horizon& result, double eclipLong) ; 462f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 463f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 464f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // The Sun 465f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 466f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 467f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 468f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The longitude of the sun at the time specified by this object. 469f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The longitude is measured in radians along the ecliptic 470f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * from the "first point of Aries," the point at which the ecliptic 471f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * crosses the earth's equatorial plane at the vernal equinox. 472f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 473f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Currently, this method uses an approximation of the two-body Kepler's 474f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * equation for the earth and the sun. It does not take into account the 475f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * perturbations caused by the other planets, the moon, etc. 476f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 477f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 478f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getSunLongitude(); 479f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 480f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 481f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * TODO Make this public when the entire class is package-private. 482f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 483f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /*public*/ void getSunLongitude(double julianDay, double &longitude, double &meanAnomaly); 484f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 485f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 486f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The position of the sun at this object's current date and time, 487f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * in equatorial coordinates. 488f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param result fillin for the result 489f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 490f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 491f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial& getSunPosition(Equatorial& result); 492f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 493f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 494f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 495f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the vernal equinox. 496f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getSunTime getSunTime}. 497f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note: In this case, "vernal" refers to the northern hemisphere's seasons. 498f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 499f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 500f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// static double VERNAL_EQUINOX(); 501f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 502f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 503f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the summer solstice. 504f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getSunTime getSunTime}. 505f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note: In this case, "summer" refers to the northern hemisphere's seasons. 506f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 507f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 508f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static double SUMMER_SOLSTICE(); 509f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 510f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 511f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the autumnal equinox. 512f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getSunTime getSunTime}. 513f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note: In this case, "autumn" refers to the northern hemisphere's seasons. 514f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 515f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 516f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// static double AUTUMN_EQUINOX(); 517f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 518f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 519f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the winter solstice. 520f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getSunTime getSunTime}. 521f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Note: In this case, "winter" refers to the northern hemisphere's seasons. 522f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 523f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 524f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static double WINTER_SOLSTICE(); 525f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 526f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 527f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Find the next time at which the sun's ecliptic longitude will have 528f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the desired value. 529f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 530f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 531f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getSunTime(double desired, UBool next); 532f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 533f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 534f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Returns the time (GMT) of sunrise or sunset on the local date to which 535f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * this calendar is currently set. 536f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 537f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * NOTE: This method only works well if this object is set to a 538f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * time near local noon. Because of variations between the local 539f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * official time zone and the geographic longitude, the 540f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * computation can flop over into an adjacent day if this object 541f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * is set to a time near local midnight. 542f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 543f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 544f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 545f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getSunRiseSet(UBool rise); 546f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 547f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 548f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // The Moon 549f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 550f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 551f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 552f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The position of the moon at the time set on this 553f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * object, in equatorial coordinates. 554f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 555f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return const reference to internal field of calendar astronomer. Do not use outside of the lifetime of this astronomer. 556f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 557f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) const Equatorial& getMoonPosition(); 558f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 559f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 560f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The "age" of the moon at the time specified in this object. 561f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * This is really the angle between the 562f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * current ecliptic longitudes of the sun and the moon, 563f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * measured in radians. 564f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 565f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getMoonPhase 566f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 567f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 568f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getMoonAge(); 569f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 570f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 571f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Calculate the phase of the moon at the time set in this object. 572f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * The returned phase is a <code>double</code> in the range 573f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <code>0 <= phase < 1</code>, interpreted as follows: 574f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <ul> 575f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <li>0.00: New moon 576f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <li>0.25: First quarter 577f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <li>0.50: Full moon 578f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <li>0.75: Last quarter 579f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * </ul> 580f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 581f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see #getMoonAge 582f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 583f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 584f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double getMoonPhase(); 585f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 586f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class U_I18N_API MoonAge : public UMemory { 587f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 588f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) MoonAge(double l) 589f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) : value(l) { } 590f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void set(double l) { value = l; } 591f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double value; 592f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 593f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 594f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 595f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing a new moon. 596f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getMoonTime getMoonTime} 597f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 598f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 599f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static const MoonAge NEW_MOON(); 600f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 601f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 602f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the moon's first quarter. 603f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getMoonTime getMoonTime} 604f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 605f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 606f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// static const MoonAge FIRST_QUARTER(); 607f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 608f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 609f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing a full moon. 610f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getMoonTime getMoonTime} 611f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 612f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 613f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static const MoonAge FULL_MOON(); 614f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 615f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 616f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Constant representing the moon's last quarter. 617f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * For use with {@link #getMoonTime getMoonTime} 618f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 619f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 620f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// static const MoonAge LAST_QUARTER(); 621f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 622f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 623f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Find the next or previous time at which the Moon's ecliptic 624f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * longitude will have the desired value. 625f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * <p> 626f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param desired The desired longitude. 627f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @param next <tt>true</tt> if the next occurrance of the phase 628f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * is desired, <tt>false</tt> for the previous occurrance. 629f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 630f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 631f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getMoonTime(double desired, UBool next); 632f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getMoonTime(const MoonAge& desired, UBool next); 633f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 634f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 635f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Returns the time (GMT) of sunrise or sunset on the local date to which 636f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * this calendar is currently set. 637f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 638f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 639f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate getMoonRiseSet(UBool rise); 640f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 641f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 642f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Interpolation methods for finding the time at which a given event occurs 643f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 644f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 645f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // private 646f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class AngleFunc : public UMemory { 647f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 648f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) virtual double eval(CalendarAstronomer&) = 0; 649f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) virtual ~AngleFunc(); 650f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 651f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) friend class AngleFunc; 652f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 653f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate timeOfAngle(AngleFunc& func, double desired, 654f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double periodDays, double epsilon, UBool next); 655f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 656f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) class CoordFunc : public UMemory { 657f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) public: 658f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) virtual void eval(Equatorial& result, CalendarAstronomer&) = 0; 659f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) virtual ~CoordFunc(); 660f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) }; 661f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) friend class CoordFunc; 662f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 663f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double riseOrSet(CoordFunc& func, UBool rise, 664f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double diameter, double refraction, 665f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double epsilon); 666f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 667f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 668f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Other utility methods 669f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 670f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private: 671f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 672f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 673f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Return the obliquity of the ecliptic (the angle between the ecliptic 674f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and the earth's equator) at the current time. This varies due to 675f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * the precession of the earth's axis. 676f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * 677f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @return the obliquity of the ecliptic relative to the equator, 678f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * measured in radians. 679f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 680f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double eclipticObliquity(); 681f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 682f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 683f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // Private data 684f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) //------------------------------------------------------------------------- 685f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private: 686f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 687f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Current time in milliseconds since 1/1/1970 AD 688f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @see java.util.Date#getTime 689f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 690f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UDate fTime; 691f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 692f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /* These aren't used yet, but they'll be needed for sunset calculations 693f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * and equatorial to horizon coordinate conversions 694f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 695f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double fLongitude; 696f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double fLatitude; 697f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double fGmtOffset; 698f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 699f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // 700f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // The following fields are used to cache calculated results for improved 701f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // performance. These values all depend on the current time setting 702f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // of this object, so the clearCache method is provided. 703f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) // 704f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 705f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double julianDay; 706f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double julianCentury; 707f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double sunLongitude; 708f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double meanAnomalySun; 709f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double moonLongitude; 710f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double moonEclipLong; 711f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double meanAnomalyMoon; 712f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double eclipObliquity; 713f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double siderealT0; 714f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) double siderealTime; 715f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 716f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) void clearCache(); 717f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 718f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) Equatorial moonPosition; 719f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UBool moonPositionSet; 720f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 721f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 722f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 723f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 724f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)// UDate local(UDate localMillis); 725f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}; 726f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 727f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_END 728f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 729f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)struct UHashtable; 730f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 731f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_BEGIN 732f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 733f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)/** 734f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * Cache of month -> julian day 735f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * @internal 736f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 737f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)class CalendarCache : public UMemory { 738f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)public: 739f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static int32_t get(CalendarCache** cache, int32_t key, UErrorCode &status); 740f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static void put(CalendarCache** cache, int32_t key, int32_t value, UErrorCode &status); 741f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) virtual ~CalendarCache(); 742f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)private: 743f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) CalendarCache(int32_t size, UErrorCode& status); 744f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) static void createCache(CalendarCache** cache, UErrorCode& status); 745f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) /** 746f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) * not implemented 747f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) */ 748f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) CalendarCache(); 749f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) UHashtable *fTable; 750f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)}; 751f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 752f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)U_NAMESPACE_END 753f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles) 754f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif 755f4ed1cf5d184064c4cf0e4359c6d5d8aadb50afaTorne (Richard Coles)#endif 756