X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..340931cb2e044a2141d11567dd0f782524e32994:/icuSources/i18n/astro.h diff --git a/icuSources/i18n/astro.h b/icuSources/i18n/astro.h index 8291d60e..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-2003, 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, @@ -497,7 +517,7 @@ public: * Note: In this case, "vernal" refers to the northern hemisphere's seasons. * @internal */ - static double VERNAL_EQUINOX(); +// static double VERNAL_EQUINOX(); /** * Constant representing the summer solstice. @@ -513,7 +533,7 @@ public: * Note: In this case, "autumn" refers to the northern hemisphere's seasons. * @internal */ - static double AUTUMN_EQUINOX(); +// static double AUTUMN_EQUINOX(); /** * Constant representing the winter solstice. @@ -603,7 +623,7 @@ public: * For use with {@link #getMoonTime getMoonTime} * @internal */ - static const MoonAge FIRST_QUARTER(); +// static const MoonAge FIRST_QUARTER(); /** * Constant representing a full moon. @@ -617,7 +637,20 @@ public: * For use with {@link #getMoonTime getMoonTime} * @internal */ - static const MoonAge LAST_QUARTER(); +// 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 @@ -643,18 +676,20 @@ public: //------------------------------------------------------------------------- // private - class U_I18N_API AngleFunc : public UMemory { + class AngleFunc : public UMemory { public: virtual double eval(CalendarAstronomer&) = 0; + virtual ~AngleFunc(); }; friend class AngleFunc; UDate timeOfAngle(AngleFunc& func, double desired, double periodDays, double epsilon, UBool next); - class U_I18N_API CoordFunc : public UMemory { + class CoordFunc : public UMemory { public: virtual void eval(Equatorial& result, CalendarAstronomer&) = 0; + virtual ~CoordFunc(); }; friend class CoordFunc; @@ -666,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 @@ -738,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(); @@ -757,7 +754,7 @@ private: /** * @internal */ - UDate local(UDate localMillis); +// UDate local(UDate localMillis); }; U_NAMESPACE_END @@ -770,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);