intl/icu/source/i18n/astro.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/astro.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,755 @@
     1.4 +/************************************************************************
     1.5 + * Copyright (C) 1996-2008, International Business Machines Corporation *
     1.6 + * and others. All Rights Reserved.                                     *
     1.7 + ************************************************************************
     1.8 + *  2003-nov-07   srl       Port from Java
     1.9 + */
    1.10 +
    1.11 +#ifndef ASTRO_H
    1.12 +#define ASTRO_H
    1.13 +
    1.14 +#include "unicode/utypes.h"
    1.15 +
    1.16 +#if !UCONFIG_NO_FORMATTING
    1.17 +
    1.18 +#include "gregoimp.h"  // for Math
    1.19 +#include "unicode/unistr.h"
    1.20 +
    1.21 +U_NAMESPACE_BEGIN
    1.22 +
    1.23 +/**
    1.24 + * <code>CalendarAstronomer</code> is a class that can perform the calculations to
    1.25 + * determine the positions of the sun and moon, the time of sunrise and
    1.26 + * sunset, and other astronomy-related data.  The calculations it performs
    1.27 + * are in some cases quite complicated, and this utility class saves you
    1.28 + * the trouble of worrying about them.
    1.29 + * <p>
    1.30 + * The measurement of time is a very important part of astronomy.  Because
    1.31 + * astronomical bodies are constantly in motion, observations are only valid
    1.32 + * at a given moment in time.  Accordingly, each <code>CalendarAstronomer</code>
    1.33 + * object has a <code>time</code> property that determines the date
    1.34 + * and time for which its calculations are performed.  You can set and
    1.35 + * retrieve this property with {@link #setDate setDate}, {@link #getDate getDate}
    1.36 + * and related methods.
    1.37 + * <p>
    1.38 + * Almost all of the calculations performed by this class, or by any
    1.39 + * astronomer, are approximations to various degrees of accuracy.  The
    1.40 + * calculations in this class are mostly modelled after those described
    1.41 + * in the book
    1.42 + * <a href="http://www.amazon.com/exec/obidos/ISBN=0521356997" target="_top">
    1.43 + * Practical Astronomy With Your Calculator</a>, by Peter J.
    1.44 + * Duffett-Smith, Cambridge University Press, 1990.  This is an excellent
    1.45 + * book, and if you want a greater understanding of how these calculations
    1.46 + * are performed it a very good, readable starting point.
    1.47 + * <p>
    1.48 + * <strong>WARNING:</strong> This class is very early in its development, and
    1.49 + * it is highly likely that its API will change to some degree in the future.
    1.50 + * At the moment, it basically does just enough to support {@link IslamicCalendar}
    1.51 + * and {@link ChineseCalendar}.
    1.52 + *
    1.53 + * @author Laura Werner
    1.54 + * @author Alan Liu
    1.55 + * @internal
    1.56 + */
    1.57 +class U_I18N_API CalendarAstronomer : public UMemory {
    1.58 +public:
    1.59 +  // some classes
    1.60 +
    1.61 +public:
    1.62 +  /**
    1.63 +   * Represents the position of an object in the sky relative to the ecliptic,
    1.64 +   * the plane of the earth's orbit around the Sun.
    1.65 +   * This is a spherical coordinate system in which the latitude
    1.66 +   * specifies the position north or south of the plane of the ecliptic.
    1.67 +   * The longitude specifies the position along the ecliptic plane
    1.68 +   * relative to the "First Point of Aries", which is the Sun's position in the sky
    1.69 +   * at the Vernal Equinox.
    1.70 +   * <p>
    1.71 +   * Note that Ecliptic objects are immutable and cannot be modified
    1.72 +   * once they are constructed.  This allows them to be passed and returned by
    1.73 +   * value without worrying about whether other code will modify them.
    1.74 +   *
    1.75 +   * @see CalendarAstronomer.Equatorial
    1.76 +   * @see CalendarAstronomer.Horizon
    1.77 +   * @internal
    1.78 +   */
    1.79 +  class U_I18N_API Ecliptic : public UMemory {
    1.80 +  public:
    1.81 +    /**
    1.82 +     * Constructs an Ecliptic coordinate object.
    1.83 +     * <p>
    1.84 +     * @param lat The ecliptic latitude, measured in radians.
    1.85 +     * @param lon The ecliptic longitude, measured in radians.
    1.86 +     * @internal
    1.87 +     */
    1.88 +    Ecliptic(double lat = 0, double lon = 0) {
    1.89 +      latitude = lat;
    1.90 +      longitude = lon;
    1.91 +    }
    1.92 +
    1.93 +    /**
    1.94 +     * Setter for Ecliptic Coordinate object
    1.95 +     * @param lat The ecliptic latitude, measured in radians.
    1.96 +     * @param lon The ecliptic longitude, measured in radians.
    1.97 +     * @internal
    1.98 +     */
    1.99 +    void set(double lat, double lon) {
   1.100 +      latitude = lat;
   1.101 +      longitude = lon;
   1.102 +    }
   1.103 +
   1.104 +    /**
   1.105 +     * Return a string representation of this object
   1.106 +     * @internal
   1.107 +     */
   1.108 +    UnicodeString toString() const;
   1.109 +
   1.110 +    /**
   1.111 +     * The ecliptic latitude, in radians.  This specifies an object's
   1.112 +     * position north or south of the plane of the ecliptic,
   1.113 +     * with positive angles representing north.
   1.114 +     * @internal
   1.115 +     */
   1.116 +    double latitude;
   1.117 +
   1.118 +    /**
   1.119 +     * The ecliptic longitude, in radians.
   1.120 +     * This specifies an object's position along the ecliptic plane
   1.121 +     * relative to the "First Point of Aries", which is the Sun's position
   1.122 +     * in the sky at the Vernal Equinox,
   1.123 +     * with positive angles representing east.
   1.124 +     * <p>
   1.125 +     * A bit of trivia: the first point of Aries is currently in the
   1.126 +     * constellation Pisces, due to the precession of the earth's axis.
   1.127 +     * @internal
   1.128 +     */
   1.129 +    double longitude;
   1.130 +  };
   1.131 +
   1.132 +  /**
   1.133 +   * Represents the position of an
   1.134 +   * object in the sky relative to the plane of the earth's equator.
   1.135 +   * The <i>Right Ascension</i> specifies the position east or west
   1.136 +   * along the equator, relative to the sun's position at the vernal
   1.137 +   * equinox.  The <i>Declination</i> is the position north or south
   1.138 +   * of the equatorial plane.
   1.139 +   * <p>
   1.140 +   * Note that Equatorial objects are immutable and cannot be modified
   1.141 +   * once they are constructed.  This allows them to be passed and returned by
   1.142 +   * value without worrying about whether other code will modify them.
   1.143 +   *
   1.144 +   * @see CalendarAstronomer.Ecliptic
   1.145 +   * @see CalendarAstronomer.Horizon
   1.146 +   * @internal
   1.147 +   */
   1.148 +  class U_I18N_API Equatorial : public UMemory {
   1.149 +  public:
   1.150 +    /**
   1.151 +     * Constructs an Equatorial coordinate object.
   1.152 +     * <p>
   1.153 +     * @param asc The right ascension, measured in radians.
   1.154 +     * @param dec The declination, measured in radians.
   1.155 +     * @internal
   1.156 +     */
   1.157 +    Equatorial(double asc = 0, double dec = 0)
   1.158 +      : ascension(asc), declination(dec) { }
   1.159 +
   1.160 +    /**
   1.161 +     * Setter
   1.162 +     * @param asc The right ascension, measured in radians.
   1.163 +     * @param dec The declination, measured in radians.
   1.164 +     * @internal
   1.165 +     */
   1.166 +    void set(double asc, double dec) {
   1.167 +      ascension = asc;
   1.168 +      declination = dec;
   1.169 +    }
   1.170 +
   1.171 +    /**
   1.172 +     * Return a string representation of this object, with the
   1.173 +     * angles measured in degrees.
   1.174 +     * @internal
   1.175 +     */
   1.176 +    UnicodeString toString() const;
   1.177 +
   1.178 +    /**
   1.179 +     * Return a string representation of this object with the right ascension
   1.180 +     * measured in hours, minutes, and seconds.
   1.181 +     * @internal
   1.182 +     */
   1.183 +    //String toHmsString() {
   1.184 +    //return radToHms(ascension) + "," + radToDms(declination);
   1.185 +    //}
   1.186 +
   1.187 +    /**
   1.188 +     * The right ascension, in radians.
   1.189 +     * This is the position east or west along the equator
   1.190 +     * relative to the sun's position at the vernal equinox,
   1.191 +     * with positive angles representing East.
   1.192 +     * @internal
   1.193 +     */
   1.194 +    double ascension;
   1.195 +
   1.196 +    /**
   1.197 +     * The declination, in radians.
   1.198 +     * This is the position north or south of the equatorial plane,
   1.199 +     * with positive angles representing north.
   1.200 +     * @internal
   1.201 +     */
   1.202 +    double declination;
   1.203 +  };
   1.204 +
   1.205 +  /**
   1.206 +   * Represents the position of an  object in the sky relative to
   1.207 +   * the local horizon.
   1.208 +   * The <i>Altitude</i> represents the object's elevation above the horizon,
   1.209 +   * with objects below the horizon having a negative altitude.
   1.210 +   * The <i>Azimuth</i> is the geographic direction of the object from the
   1.211 +   * observer's position, with 0 representing north.  The azimuth increases
   1.212 +   * clockwise from north.
   1.213 +   * <p>
   1.214 +   * Note that Horizon objects are immutable and cannot be modified
   1.215 +   * once they are constructed.  This allows them to be passed and returned by
   1.216 +   * value without worrying about whether other code will modify them.
   1.217 +   *
   1.218 +   * @see CalendarAstronomer.Ecliptic
   1.219 +   * @see CalendarAstronomer.Equatorial
   1.220 +   * @internal
   1.221 +   */
   1.222 +  class U_I18N_API Horizon : public UMemory {
   1.223 +  public:
   1.224 +    /**
   1.225 +     * Constructs a Horizon coordinate object.
   1.226 +     * <p>
   1.227 +     * @param alt  The altitude, measured in radians above the horizon.
   1.228 +     * @param azim The azimuth, measured in radians clockwise from north.
   1.229 +     * @internal
   1.230 +     */
   1.231 +    Horizon(double alt=0, double azim=0)
   1.232 +      : altitude(alt), azimuth(azim) { }
   1.233 +
   1.234 +    /**
   1.235 +     * Setter for Ecliptic Coordinate object
   1.236 +     * @param alt  The altitude, measured in radians above the horizon.
   1.237 +     * @param azim The azimuth, measured in radians clockwise from north.
   1.238 +     * @internal
   1.239 +     */
   1.240 +    void set(double alt, double azim) {
   1.241 +      altitude = alt;
   1.242 +      azimuth = azim;
   1.243 +    }
   1.244 +
   1.245 +    /**
   1.246 +     * Return a string representation of this object, with the
   1.247 +     * angles measured in degrees.
   1.248 +     * @internal
   1.249 +     */
   1.250 +    UnicodeString toString() const;
   1.251 +
   1.252 +    /**
   1.253 +     * The object's altitude above the horizon, in radians.
   1.254 +     * @internal
   1.255 +     */
   1.256 +    double altitude;
   1.257 +
   1.258 +    /**
   1.259 +     * The object's direction, in radians clockwise from north.
   1.260 +     * @internal
   1.261 +     */
   1.262 +    double azimuth;
   1.263 +  };
   1.264 +
   1.265 +public:
   1.266 +  //-------------------------------------------------------------------------
   1.267 +  // Assorted private data used for conversions
   1.268 +  //-------------------------------------------------------------------------
   1.269 +
   1.270 +  // My own copies of these so compilers are more likely to optimize them away
   1.271 +  static const double PI;
   1.272 +
   1.273 +  /**
   1.274 +   * The average number of solar days from one new moon to the next.  This is the time
   1.275 +   * it takes for the moon to return the same ecliptic longitude as the sun.
   1.276 +   * It is longer than the sidereal month because the sun's longitude increases
   1.277 +   * during the year due to the revolution of the earth around the sun.
   1.278 +   * Approximately 29.53.
   1.279 +   *
   1.280 +   * @see #SIDEREAL_MONTH
   1.281 +   * @internal
   1.282 +   * @deprecated ICU 2.4. This class may be removed or modified.
   1.283 +   */
   1.284 +  static const double SYNODIC_MONTH;
   1.285 +
   1.286 +  //-------------------------------------------------------------------------
   1.287 +  // Constructors
   1.288 +  //-------------------------------------------------------------------------
   1.289 +
   1.290 +  /**
   1.291 +   * Construct a new <code>CalendarAstronomer</code> object that is initialized to
   1.292 +   * the current date and time.
   1.293 +   * @internal
   1.294 +   */
   1.295 +  CalendarAstronomer();
   1.296 +
   1.297 +  /**
   1.298 +   * Construct a new <code>CalendarAstronomer</code> object that is initialized to
   1.299 +   * the specified date and time.
   1.300 +   * @internal
   1.301 +   */
   1.302 +  CalendarAstronomer(UDate d);
   1.303 +
   1.304 +  /**
   1.305 +   * Construct a new <code>CalendarAstronomer</code> object with the given
   1.306 +   * latitude and longitude.  The object's time is set to the current
   1.307 +   * date and time.
   1.308 +   * <p>
   1.309 +   * @param longitude The desired longitude, in <em>degrees</em> east of
   1.310 +   *                  the Greenwich meridian.
   1.311 +   *
   1.312 +   * @param latitude  The desired latitude, in <em>degrees</em>.  Positive
   1.313 +   *                  values signify North, negative South.
   1.314 +   *
   1.315 +   * @see java.util.Date#getTime()
   1.316 +   * @internal
   1.317 +   */
   1.318 +  CalendarAstronomer(double longitude, double latitude);
   1.319 +
   1.320 +  /**
   1.321 +   * Destructor
   1.322 +   * @internal
   1.323 +   */
   1.324 +  ~CalendarAstronomer();
   1.325 +
   1.326 +  //-------------------------------------------------------------------------
   1.327 +  // Time and date getters and setters
   1.328 +  //-------------------------------------------------------------------------
   1.329 +
   1.330 +  /**
   1.331 +   * Set the current date and time of this <code>CalendarAstronomer</code> object.  All
   1.332 +   * astronomical calculations are performed based on this time setting.
   1.333 +   *
   1.334 +   * @param aTime the date and time, expressed as the number of milliseconds since
   1.335 +   *              1/1/1970 0:00 GMT (Gregorian).
   1.336 +   *
   1.337 +   * @see #setDate
   1.338 +   * @see #getTime
   1.339 +   * @internal
   1.340 +   */
   1.341 +  void setTime(UDate aTime);
   1.342 +
   1.343 +
   1.344 +  /**
   1.345 +   * Set the current date and time of this <code>CalendarAstronomer</code> object.  All
   1.346 +   * astronomical calculations are performed based on this time setting.
   1.347 +   *
   1.348 +   * @param aTime the date and time, expressed as the number of milliseconds since
   1.349 +   *              1/1/1970 0:00 GMT (Gregorian).
   1.350 +   *
   1.351 +   * @see #getTime
   1.352 +   * @internal
   1.353 +   */
   1.354 +  void setDate(UDate aDate) { setTime(aDate); }
   1.355 +
   1.356 +  /**
   1.357 +   * Set the current date and time of this <code>CalendarAstronomer</code> object.  All
   1.358 +   * astronomical calculations are performed based on this time setting.
   1.359 +   *
   1.360 +   * @param jdn   the desired time, expressed as a "julian day number",
   1.361 +   *              which is the number of elapsed days since
   1.362 +   *              1/1/4713 BC (Julian), 12:00 GMT.  Note that julian day
   1.363 +   *              numbers start at <em>noon</em>.  To get the jdn for
   1.364 +   *              the corresponding midnight, subtract 0.5.
   1.365 +   *
   1.366 +   * @see #getJulianDay
   1.367 +   * @see #JULIAN_EPOCH_MS
   1.368 +   * @internal
   1.369 +   */
   1.370 +  void setJulianDay(double jdn);
   1.371 +
   1.372 +  /**
   1.373 +   * Get the current time of this <code>CalendarAstronomer</code> object,
   1.374 +   * represented as the number of milliseconds since
   1.375 +   * 1/1/1970 AD 0:00 GMT (Gregorian).
   1.376 +   *
   1.377 +   * @see #setTime
   1.378 +   * @see #getDate
   1.379 +   * @internal
   1.380 +   */
   1.381 +  UDate getTime();
   1.382 +
   1.383 +  /**
   1.384 +   * Get the current time of this <code>CalendarAstronomer</code> object,
   1.385 +   * expressed as a "julian day number", which is the number of elapsed
   1.386 +   * days since 1/1/4713 BC (Julian), 12:00 GMT.
   1.387 +   *
   1.388 +   * @see #setJulianDay
   1.389 +   * @see #JULIAN_EPOCH_MS
   1.390 +   * @internal
   1.391 +   */
   1.392 +  double getJulianDay();
   1.393 +
   1.394 +  /**
   1.395 +   * Return this object's time expressed in julian centuries:
   1.396 +   * the number of centuries after 1/1/1900 AD, 12:00 GMT
   1.397 +   *
   1.398 +   * @see #getJulianDay
   1.399 +   * @internal
   1.400 +   */
   1.401 +  double getJulianCentury();
   1.402 +
   1.403 +  /**
   1.404 +   * Returns the current Greenwich sidereal time, measured in hours
   1.405 +   * @internal
   1.406 +   */
   1.407 +  double getGreenwichSidereal();
   1.408 +
   1.409 +private:
   1.410 +  double getSiderealOffset();
   1.411 +public:
   1.412 +  /**
   1.413 +   * Returns the current local sidereal time, measured in hours
   1.414 +   * @internal
   1.415 +   */
   1.416 +  double getLocalSidereal();
   1.417 +
   1.418 +  /**
   1.419 +   * Converts local sidereal time to Universal Time.
   1.420 +   *
   1.421 +   * @param lst   The Local Sidereal Time, in hours since sidereal midnight
   1.422 +   *              on this object's current date.
   1.423 +   *
   1.424 +   * @return      The corresponding Universal Time, in milliseconds since
   1.425 +   *              1 Jan 1970, GMT.
   1.426 +   */
   1.427 +  //private:
   1.428 +  double lstToUT(double lst);
   1.429 +
   1.430 +  /**
   1.431 +   *
   1.432 +   * Convert from ecliptic to equatorial coordinates.
   1.433 +   *
   1.434 +   * @param ecliptic     The ecliptic
   1.435 +   * @param result       Fillin result
   1.436 +   * @return reference to result
   1.437 +   */
   1.438 +  Equatorial& eclipticToEquatorial(Equatorial& result, const Ecliptic& ecliptic);
   1.439 +
   1.440 +  /**
   1.441 +   * Convert from ecliptic to equatorial coordinates.
   1.442 +   *
   1.443 +   * @param eclipLong     The ecliptic longitude
   1.444 +   * @param eclipLat      The ecliptic latitude
   1.445 +   *
   1.446 +   * @return              The corresponding point in equatorial coordinates.
   1.447 +   * @internal
   1.448 +   */
   1.449 +  Equatorial& eclipticToEquatorial(Equatorial& result, double eclipLong, double eclipLat);
   1.450 +
   1.451 +  /**
   1.452 +   * Convert from ecliptic longitude to equatorial coordinates.
   1.453 +   *
   1.454 +   * @param eclipLong     The ecliptic longitude
   1.455 +   *
   1.456 +   * @return              The corresponding point in equatorial coordinates.
   1.457 +   * @internal
   1.458 +   */
   1.459 +  Equatorial& eclipticToEquatorial(Equatorial& result, double eclipLong) ;
   1.460 +
   1.461 +  /**
   1.462 +   * @internal
   1.463 +   */
   1.464 +  Horizon& eclipticToHorizon(Horizon& result, double eclipLong) ;
   1.465 +
   1.466 +  //-------------------------------------------------------------------------
   1.467 +  // The Sun
   1.468 +  //-------------------------------------------------------------------------
   1.469 +
   1.470 +  /**
   1.471 +   * The longitude of the sun at the time specified by this object.
   1.472 +   * The longitude is measured in radians along the ecliptic
   1.473 +   * from the "first point of Aries," the point at which the ecliptic
   1.474 +   * crosses the earth's equatorial plane at the vernal equinox.
   1.475 +   * <p>
   1.476 +   * Currently, this method uses an approximation of the two-body Kepler's
   1.477 +   * equation for the earth and the sun.  It does not take into account the
   1.478 +   * perturbations caused by the other planets, the moon, etc.
   1.479 +   * @internal
   1.480 +   */
   1.481 +  double getSunLongitude();
   1.482 +
   1.483 +  /**
   1.484 +   * TODO Make this public when the entire class is package-private.
   1.485 +   */
   1.486 +  /*public*/ void getSunLongitude(double julianDay, double &longitude, double &meanAnomaly);
   1.487 +
   1.488 +  /**
   1.489 +   * The position of the sun at this object's current date and time,
   1.490 +   * in equatorial coordinates.
   1.491 +   * @param result fillin for the result
   1.492 +   * @internal
   1.493 +   */
   1.494 +  Equatorial& getSunPosition(Equatorial& result);
   1.495 +
   1.496 +public:
   1.497 +  /**
   1.498 +   * Constant representing the vernal equinox.
   1.499 +   * For use with {@link #getSunTime getSunTime}.
   1.500 +   * Note: In this case, "vernal" refers to the northern hemisphere's seasons.
   1.501 +   * @internal
   1.502 +   */
   1.503 +//  static double VERNAL_EQUINOX();
   1.504 +
   1.505 +  /**
   1.506 +   * Constant representing the summer solstice.
   1.507 +   * For use with {@link #getSunTime getSunTime}.
   1.508 +   * Note: In this case, "summer" refers to the northern hemisphere's seasons.
   1.509 +   * @internal
   1.510 +   */
   1.511 +  static double SUMMER_SOLSTICE();
   1.512 +
   1.513 +  /**
   1.514 +   * Constant representing the autumnal equinox.
   1.515 +   * For use with {@link #getSunTime getSunTime}.
   1.516 +   * Note: In this case, "autumn" refers to the northern hemisphere's seasons.
   1.517 +   * @internal
   1.518 +   */
   1.519 +//  static double AUTUMN_EQUINOX();
   1.520 +
   1.521 +  /**
   1.522 +   * Constant representing the winter solstice.
   1.523 +   * For use with {@link #getSunTime getSunTime}.
   1.524 +   * Note: In this case, "winter" refers to the northern hemisphere's seasons.
   1.525 +   * @internal
   1.526 +   */
   1.527 +  static double WINTER_SOLSTICE();
   1.528 +
   1.529 +  /**
   1.530 +   * Find the next time at which the sun's ecliptic longitude will have
   1.531 +   * the desired value.
   1.532 +   * @internal
   1.533 +   */
   1.534 +  UDate getSunTime(double desired, UBool next);
   1.535 +
   1.536 +  /**
   1.537 +   * Returns the time (GMT) of sunrise or sunset on the local date to which
   1.538 +   * this calendar is currently set.
   1.539 +   *
   1.540 +   * NOTE: This method only works well if this object is set to a
   1.541 +   * time near local noon.  Because of variations between the local
   1.542 +   * official time zone and the geographic longitude, the
   1.543 +   * computation can flop over into an adjacent day if this object
   1.544 +   * is set to a time near local midnight.
   1.545 +   *
   1.546 +   * @internal
   1.547 +   */
   1.548 +  UDate getSunRiseSet(UBool rise);
   1.549 +
   1.550 +  //-------------------------------------------------------------------------
   1.551 +  // The Moon
   1.552 +  //-------------------------------------------------------------------------
   1.553 +
   1.554 +  /**
   1.555 +   * The position of the moon at the time set on this
   1.556 +   * object, in equatorial coordinates.
   1.557 +   * @internal
   1.558 +   * @return const reference to internal field of calendar astronomer. Do not use outside of the lifetime of this astronomer.
   1.559 +   */
   1.560 +  const Equatorial& getMoonPosition();
   1.561 +
   1.562 +  /**
   1.563 +   * The "age" of the moon at the time specified in this object.
   1.564 +   * This is really the angle between the
   1.565 +   * current ecliptic longitudes of the sun and the moon,
   1.566 +   * measured in radians.
   1.567 +   *
   1.568 +   * @see #getMoonPhase
   1.569 +   * @internal
   1.570 +   */
   1.571 +  double getMoonAge();
   1.572 +
   1.573 +  /**
   1.574 +   * Calculate the phase of the moon at the time set in this object.
   1.575 +   * The returned phase is a <code>double</code> in the range
   1.576 +   * <code>0 <= phase < 1</code>, interpreted as follows:
   1.577 +   * <ul>
   1.578 +   * <li>0.00: New moon
   1.579 +   * <li>0.25: First quarter
   1.580 +   * <li>0.50: Full moon
   1.581 +   * <li>0.75: Last quarter
   1.582 +   * </ul>
   1.583 +   *
   1.584 +   * @see #getMoonAge
   1.585 +   * @internal
   1.586 +   */
   1.587 +  double getMoonPhase();
   1.588 +
   1.589 +  class U_I18N_API MoonAge : public UMemory {
   1.590 +  public:
   1.591 +    MoonAge(double l)
   1.592 +      :  value(l) { }
   1.593 +    void set(double l) { value = l; }
   1.594 +    double value;
   1.595 +  };
   1.596 +
   1.597 +  /**
   1.598 +   * Constant representing a new moon.
   1.599 +   * For use with {@link #getMoonTime getMoonTime}
   1.600 +   * @internal
   1.601 +   */
   1.602 +  static const MoonAge NEW_MOON();
   1.603 +
   1.604 +  /**
   1.605 +   * Constant representing the moon's first quarter.
   1.606 +   * For use with {@link #getMoonTime getMoonTime}
   1.607 +   * @internal
   1.608 +   */
   1.609 +//  static const MoonAge FIRST_QUARTER();
   1.610 +
   1.611 +  /**
   1.612 +   * Constant representing a full moon.
   1.613 +   * For use with {@link #getMoonTime getMoonTime}
   1.614 +   * @internal
   1.615 +   */
   1.616 +  static const MoonAge FULL_MOON();
   1.617 +
   1.618 +  /**
   1.619 +   * Constant representing the moon's last quarter.
   1.620 +   * For use with {@link #getMoonTime getMoonTime}
   1.621 +   * @internal
   1.622 +   */
   1.623 +//  static const MoonAge LAST_QUARTER();
   1.624 +
   1.625 +  /**
   1.626 +   * Find the next or previous time at which the Moon's ecliptic
   1.627 +   * longitude will have the desired value.
   1.628 +   * <p>
   1.629 +   * @param desired   The desired longitude.
   1.630 +   * @param next      <tt>true</tt> if the next occurrance of the phase
   1.631 +   *                  is desired, <tt>false</tt> for the previous occurrance.
   1.632 +   * @internal
   1.633 +   */
   1.634 +  UDate getMoonTime(double desired, UBool next);
   1.635 +  UDate getMoonTime(const MoonAge& desired, UBool next);
   1.636 +
   1.637 +  /**
   1.638 +   * Returns the time (GMT) of sunrise or sunset on the local date to which
   1.639 +   * this calendar is currently set.
   1.640 +   * @internal
   1.641 +   */
   1.642 +  UDate getMoonRiseSet(UBool rise);
   1.643 +
   1.644 +  //-------------------------------------------------------------------------
   1.645 +  // Interpolation methods for finding the time at which a given event occurs
   1.646 +  //-------------------------------------------------------------------------
   1.647 +
   1.648 +  // private
   1.649 +  class AngleFunc : public UMemory {
   1.650 +  public:
   1.651 +    virtual double eval(CalendarAstronomer&) = 0;
   1.652 +    virtual ~AngleFunc();
   1.653 +  };
   1.654 +  friend class AngleFunc;
   1.655 +
   1.656 +  UDate timeOfAngle(AngleFunc& func, double desired,
   1.657 +                    double periodDays, double epsilon, UBool next);
   1.658 +
   1.659 +  class CoordFunc : public UMemory {
   1.660 +  public:
   1.661 +    virtual void eval(Equatorial& result, CalendarAstronomer&) = 0;
   1.662 +    virtual ~CoordFunc();
   1.663 +  };
   1.664 +  friend class CoordFunc;
   1.665 +
   1.666 +  double riseOrSet(CoordFunc& func, UBool rise,
   1.667 +                   double diameter, double refraction,
   1.668 +                   double epsilon);
   1.669 +
   1.670 +  //-------------------------------------------------------------------------
   1.671 +  // Other utility methods
   1.672 +  //-------------------------------------------------------------------------
   1.673 +private:
   1.674 +
   1.675 +  /**
   1.676 +   * Return the obliquity of the ecliptic (the angle between the ecliptic
   1.677 +   * and the earth's equator) at the current time.  This varies due to
   1.678 +   * the precession of the earth's axis.
   1.679 +   *
   1.680 +   * @return  the obliquity of the ecliptic relative to the equator,
   1.681 +   *          measured in radians.
   1.682 +   */
   1.683 +  double eclipticObliquity();
   1.684 +
   1.685 +  //-------------------------------------------------------------------------
   1.686 +  // Private data
   1.687 +  //-------------------------------------------------------------------------
   1.688 +private:
   1.689 +  /**
   1.690 +   * Current time in milliseconds since 1/1/1970 AD
   1.691 +   * @see java.util.Date#getTime
   1.692 +   */
   1.693 +  UDate fTime;
   1.694 +
   1.695 +  /* These aren't used yet, but they'll be needed for sunset calculations
   1.696 +   * and equatorial to horizon coordinate conversions
   1.697 +   */
   1.698 +  double fLongitude;
   1.699 +  double fLatitude;
   1.700 +  double fGmtOffset;
   1.701 +
   1.702 +  //
   1.703 +  // The following fields are used to cache calculated results for improved
   1.704 +  // performance.  These values all depend on the current time setting
   1.705 +  // of this object, so the clearCache method is provided.
   1.706 +  //
   1.707 +
   1.708 +  double    julianDay;
   1.709 +  double    julianCentury;
   1.710 +  double    sunLongitude;
   1.711 +  double    meanAnomalySun;
   1.712 +  double    moonLongitude;
   1.713 +  double    moonEclipLong;
   1.714 +  double    meanAnomalyMoon;
   1.715 +  double    eclipObliquity;
   1.716 +  double    siderealT0;
   1.717 +  double    siderealTime;
   1.718 +
   1.719 +  void clearCache();
   1.720 +
   1.721 +  Equatorial  moonPosition;
   1.722 +  UBool       moonPositionSet;
   1.723 +
   1.724 +  /**
   1.725 +   * @internal
   1.726 +   */
   1.727 +//  UDate local(UDate localMillis);
   1.728 +};
   1.729 +
   1.730 +U_NAMESPACE_END
   1.731 +
   1.732 +struct UHashtable;
   1.733 +
   1.734 +U_NAMESPACE_BEGIN
   1.735 +
   1.736 +/**
   1.737 + * Cache of month -> julian day
   1.738 + * @internal
   1.739 + */
   1.740 +class CalendarCache : public UMemory {
   1.741 +public:
   1.742 +  static int32_t get(CalendarCache** cache, int32_t key, UErrorCode &status);
   1.743 +  static void put(CalendarCache** cache, int32_t key, int32_t value, UErrorCode &status);
   1.744 +  virtual ~CalendarCache();
   1.745 +private:
   1.746 +  CalendarCache(int32_t size, UErrorCode& status);
   1.747 +  static void createCache(CalendarCache** cache, UErrorCode& status);
   1.748 +  /**
   1.749 +   * not implemented
   1.750 +   */
   1.751 +  CalendarCache();
   1.752 +  UHashtable *fTable;
   1.753 +};
   1.754 +
   1.755 +U_NAMESPACE_END
   1.756 +
   1.757 +#endif
   1.758 +#endif

mercurial