+// © 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
// 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.
+ * <p>
+ * @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
/**
* 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,
* 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.
* 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.
* For use with {@link #getMoonTime getMoonTime}
* @internal
*/
- static const MoonAge FIRST_QUARTER();
+// static const MoonAge FIRST_QUARTER();
/**
* Constant representing a full moon.
* 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.
+ * <p>
+ * @param theTime the time relative to which the function should find
+ * the next or previous new moon
+ * @param next <tt>true</tt> if the next occurrance of the new moon
+ * is desired, <tt>false</tt> for the previous occurrance.
+ * @internal
+ */
+ static UDate getNewMoonTimeInRange(UDate theTime, UBool next);
/**
* Find the next or previous time at which the Moon's ecliptic
//-------------------------------------------------------------------------
// 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;
// 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
// 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();
/**
* @internal
*/
- UDate local(UDate localMillis);
+// UDate local(UDate localMillis);
};
U_NAMESPACE_END
* 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);