X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/73c04bcfe1096173b00431f0cdc742894b15eef0..HEAD:/icuSources/i18n/astro.h diff --git a/icuSources/i18n/astro.h b/icuSources/i18n/astro.h index 18e6aa55..77475be3 100644 --- a/icuSources/i18n/astro.h +++ b/icuSources/i18n/astro.h @@ -1,5 +1,7 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /************************************************************************ - * Copyright (C) 1996-2006, International Business Machines Corporation * + * Copyright (C) 1996-2008,2014 International Business Machines Corporation * * and others. All Rights Reserved. * ************************************************************************ * 2003-nov-07 srl Port from Java @@ -464,6 +466,24 @@ public: // The Sun //------------------------------------------------------------------------- + /** + * Returns sunLongitude which may be adjusted for correctness + * based on the time, using a table which only has data covering + * gregorian years 1900-2100. + *
+ * @param theSunLongitude the sunLongitude to be adjusted if necessary + * @param theTime the time for which the sunLongitude is to be adjusted + * @internal + */ + static double adjustSunLongitude(double &theSunLongitude, UDate theTime); + + /** + * The longitude of the sun at the time specified by theTime. + * This does not result in caching of any of the intermediate computations. + * @internal + */ + static double getSunLongitudeForTime(UDate theTime); + /** * The longitude of the sun at the time specified by this object. * The longitude is measured in radians along the ecliptic @@ -480,7 +500,7 @@ public: /** * TODO Make this public when the entire class is package-private. */ - /*public*/ void getSunLongitude(double julianDay, double &longitude, double &meanAnomaly); + /*public*/ static void getSunLongitude(double julianDay, double &longitude, double &meanAnomaly); /** * The position of the sun at this object's current date and time, @@ -521,7 +541,7 @@ public: * Note: In this case, "winter" refers to the northern hemisphere's seasons. * @internal */ -// static double WINTER_SOLSTICE(); + static double WINTER_SOLSTICE(); /** * Find the next time at which the sun's ecliptic longitude will have @@ -596,7 +616,7 @@ public: * For use with {@link #getMoonTime getMoonTime} * @internal */ -// static const MoonAge NEW_MOON(); + static const MoonAge NEW_MOON(); /** * Constant representing the moon's first quarter. @@ -619,6 +639,19 @@ public: */ // static const MoonAge LAST_QUARTER(); + /** + * Find the next or previous time of a new moon if date is in the + * range handled by this function (approx gregorian 1900-2100), + * else return 0. + *
+ * @param theTime the time relative to which the function should find + * the next or previous new moon + * @param next true if the next occurrance of the new moon + * is desired, false for the previous occurrance. + * @internal + */ + static UDate getNewMoonTimeInRange(UDate theTime, UBool next); + /** * Find the next or previous time at which the Moon's ecliptic * longitude will have the desired value. @@ -668,44 +701,6 @@ public: // Other utility methods //------------------------------------------------------------------------- private: - /*** - * Given 'value', add or subtract 'range' until 0 <= 'value' < range. - * The modulus operator. - */ - inline static double normalize(double value, double range) { - return value - range * Math::floorDivide(value, range); - } - - /** - * Normalize an angle so that it's in the range 0 - 2pi. - * For positive angles this is just (angle % 2pi), but the Java - * mod operator doesn't work that way for negative numbers.... - */ - inline static double norm2PI(double angle) { - return normalize(angle, CalendarAstronomer::PI * 2.0); - } - - /** - * Normalize an angle into the range -PI - PI - */ - inline static double normPI(double angle) { - return normalize(angle + PI, CalendarAstronomer::PI * 2.0) - PI; - } - - /** - * Find the "true anomaly" (longitude) of an object from - * its mean anomaly and the eccentricity of its orbit. This uses - * an iterative solution to Kepler's equation. - * - * @param meanAnomaly The object's longitude calculated as if it were in - * a regular, circular orbit, measured in radians - * from the point of perigee. - * - * @param eccentricity The eccentricity of the orbit - * - * @return The true anomaly (longitude) measured in radians - */ - double trueAnomaly(double meanAnomaly, double eccentricity); /** * Return the obliquity of the ecliptic (the angle between the ecliptic @@ -740,16 +735,16 @@ private: // of this object, so the clearCache method is provided. // - double julianDay ; - double julianCentury ; - double sunLongitude ; - double meanAnomalySun ; - double moonLongitude ; - double moonEclipLong ; - double meanAnomalyMoon ; - double eclipObliquity ; - double siderealT0 ; - double siderealTime ; + double julianDay; + double julianCentury; + double sunLongitude; + double meanAnomalySun; + double moonLongitude; + double moonEclipLong; + double meanAnomalyMoon; + double eclipObliquity; + double siderealT0; + double siderealTime; void clearCache(); @@ -772,7 +767,7 @@ U_NAMESPACE_BEGIN * Cache of month -> julian day * @internal */ -class U_I18N_API CalendarCache : public UMemory { +class CalendarCache : public UMemory { public: static int32_t get(CalendarCache** cache, int32_t key, UErrorCode &status); static void put(CalendarCache** cache, int32_t key, int32_t value, UErrorCode &status);