1 /*
2  *  This library is free software; you can redistribute it and/or
3  *  modify it under the terms of the GNU Lesser General Public
4  *  License as published by the Free Software Foundation; either
5  *  version 2 of the License, or (at your option) any later version.
6  *
7  *  This library is distributed in the hope that it will be useful,
8  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  *  Lesser General Public License for more details.
11  *
12  *  You should have received a copy of the GNU General Public License
13  *  along with this program; if not, write to the Free Software
14  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  *  Copyright (C) 2000 - 2005 Liam Girdwood
17  */
18 
19 #ifndef _LN_TYPES_H
20 #define _LN_TYPES_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__)  || defined( __MWERKS__)
27 #  if defined( LIBNOVA_STATIC )
28 #    define LIBNOVA_EXPORT
29 #  elif defined( LIBNOVA_SHARED )
30 #    define LIBNOVA_EXPORT   __declspec(dllexport)
31 #  else
32 #    define LIBNOVA_EXPORT
33 #  endif
34 #else
35 #  define LIBNOVA_EXPORT
36 #endif
37 
38 /* define some useful constants if they are not already defined */
39 #if(!defined(M_PI_2) && (!defined(_MSC_VER) || !defined(_USE_MATH_DEFINES)))
40 #define M_PI_2          1.5707963267948966192313216916398
41 #define M_PI_4          0.78539816339744830961566084581988
42 #define M_PI            3.1415926535897932384626433832795
43 #endif
44 
45 /* sideral day length in seconds and days (for JD)*/
46 #define LN_SIDEREAL_DAY_SEC 86164.09
47 #define LN_SIDEREAL_DAY_DAY LN_SIDEREAL_DAY_SEC/86400
48 
49 /* 1.1.2000 Julian Day & others */
50 #define JD2000          2451545.0
51 #define JD2050          2469807.50
52 
53 #define B1900           2415020.3135
54 #define B1950           2433282.4235
55 
56 /*!
57 ** Date
58 * \struct ln_date
59 * \brief Human readable Date and time used by libnova
60 *
61 * This is the Human readable (easy printf) date format used
62 * by libnova. It's always in UTC. For local time, please use
63 * ln_zonedate.
64 */
65 
66 struct ln_date
67 {
68     int years; 		/*!< Years. All values are valid */
69     int months;		/*!< Months. Valid values : 1 (January) - 12 (December) */
70     int days; 		/*!< Days. Valid values 1 - 28,29,30,31 Depends on month.*/
71     int hours; 		/*!< Hours. Valid values 0 - 23. */
72     int minutes; 	/*!< Minutes. Valid values 0 - 59. */
73     double seconds;	/*!< Seconds. Valid values 0 - 59.99999.... */
74 };
75 
76 /*!
77 ** Zone date
78 * \struct ln_zonedate
79 * \brief Human readable Date and time with timezone information used
80 * by libnova
81 *
82 * This is the Human readable (easy printf) date with timezone format
83 * used by libnova.
84 */
85 
86 struct ln_zonedate
87 {
88     int years; 		/*!< Years. All values are valid */
89     int months;		/*!< Months. Valid values : 1 (January) - 12 (December) */
90     int days; 		/*!< Days. Valid values 1 - 28,29,30,31 Depends on month.*/
91     int hours; 		/*!< Hours. Valid values 0 - 23. */
92     int minutes; 	/*!< Minutes. Valid values 0 - 59. */
93     double seconds;	/*!< Seconds. Valid values 0 - 59.99999.... */
94     long gmtoff;        /*!< Timezone offset. Seconds east of UTC. Valid values 0..86400 */
95 };
96 
97 /*! \struct ln_dms
98 ** \brief Degrees, minutes and seconds.
99 *
100 * Human readable Angle in degrees, minutes and seconds
101 */
102 
103 struct ln_dms
104 {
105     unsigned short neg;         /*!< Non zero if negative */
106     unsigned short degrees;   	/*!< Degrees. Valid 0 - 360 */
107     unsigned short minutes;   	/*!< Minutes. Valid 0 - 59 */
108     double seconds;		/*!< Seconds. Valid 0 - 59.9999... */
109 };
110 
111 /*! \struct ln_hms
112 ** \brief Hours, minutes and seconds.
113 *
114 * Human readable Angle in hours, minutes and seconds
115 */
116 
117 struct ln_hms
118 {
119     unsigned short hours;		/*!< Hours. Valid 0 - 23 */
120     unsigned short minutes;		/*!< Minutes. Valid 0 - 59 */
121     double seconds;				/*!< Seconds. Valid 0 - 59.9999... */
122 };
123 
124 /*! \struct lnh_equ_posn
125 ** \brief Right Ascension and Declination.
126 *
127 * Human readable Equatorial Coordinates.
128 */
129 
130 struct lnh_equ_posn
131 {
132     struct ln_hms ra;	/*!< RA. Object right ascension.*/
133     struct ln_dms dec;	/*!< DEC. Object declination */
134 };
135 
136 /*! \struct lnh_hrz_posn
137 ** \brief Azimuth and Altitude.
138 *
139 * Human readable Horizontal Coordinates.
140 */
141 
142 struct lnh_hrz_posn
143 {
144     struct ln_dms az;	/*!< AZ. Object azimuth. */
145     struct ln_dms alt;	/*!< ALT. Object altitude. */
146 };
147 
148 
149 /*! \struct lnh_lnlat_posn
150 ** \brief Ecliptical (or celestial) Latitude and Longitude.
151 *
152 * Human readable Ecliptical (or celestial) Longitude and Latitude.
153 */
154 
155 struct lnh_lnlat_posn
156 {
157     struct ln_dms lng; /*!< longitude. Object longitude.*/
158     struct ln_dms lat; /*!< latitude. Object latitude */
159 };
160 
161 
162 /*! \struct ln_equ_posn
163 ** \brief Equatorial Coordinates.
164 *
165 * The Right Ascension and Declination of an object.
166 *
167 * Angles are expressed in degrees.
168 */
169 
170 struct ln_equ_posn
171 {
172     double ra;	/*!< RA. Object right ascension in degrees.*/
173     double dec;	/*!< DEC. Object declination */
174 };
175 
176 /*! \struct ln_hrz_posn
177 ** \brief Horizontal Coordinates.
178 *
179 * The Azimuth and Altitude of an object.
180 *
181 * Angles are expressed in degrees.
182 */
183 
184 struct ln_hrz_posn
185 {
186     double az;	/*!< AZ. Object azimuth. <p>
187 		  0 deg = South, 90 deg = West, 180 deg = Nord, 270 deg = East */
188     double alt;	/*!< ALT. Object altitude. <p> 0 deg = horizon, 90 deg = zenit, -90 deg = nadir */
189 };
190 
191 
192 /*! \struct ln_lnlat_posn
193 ** \brief Ecliptical (or celestial) Longitude and Latitude.
194 *
195 * The Ecliptical (or celestial) Latitude and Longitude of and object.
196 *
197 * Angles are expressed in degrees. East is positive, West negative.
198 */
199 
200 struct ln_lnlat_posn
201 {
202     double lng; /*!< longitude. Object longitude. */
203     double lat; /*!< latitude. Object latitude */
204 };
205 
206 
207 /*! \struct ln_helio_posn
208 * \brief Heliocentric position
209 *
210 * A heliocentric position is an objects position relative to the
211 * centre of the Sun.
212 *
213 * Angles are expressed in degrees.
214 * Radius vector is in AU.
215 */
216 struct ln_helio_posn
217 {
218 	double L;	/*!< Heliocentric longitude */
219 	double B;	/*!< Heliocentric latitude */
220 	double R;	/*!< Heliocentric radius vector */
221 };
222 
223 /*! \struct ln_rect_posn
224 * \brief Rectangular coordinates
225 *
226 * Rectangular Coordinates of a body. These coordinates can be either
227 * geocentric or heliocentric.
228 *
229 * A heliocentric position is an objects position relative to the
230 * centre of the Sun.
231 * A geocentric position is an objects position relative to the centre
232 * of the Earth.
233 *
234 * Position is in units of AU for planets and in units of km
235 * for the Moon.
236 */
237 struct ln_rect_posn
238 {
239 	double X;	/*!< Rectangular X coordinate */
240 	double Y;	/*!< Rectangular Y coordinate */
241 	double Z;	/*!< Rectangular Z coordinate */
242 };
243 
244 /*!
245 * \struct ln_gal_posn
246 * \brief Galactic coordinates
247 *
248 * The Galactic Latitude and Longitude of and object.
249 *
250 * Angles are expressed in degrees.
251 */
252 struct ln_gal_posn
253 {
254 	double l;	/*!< Galactic longitude (degrees) */
255 	double b;	/*!< Galactic latitude (degrees) */
256 };
257 
258 /*!
259 * \struct ln_ell_orbit
260 * \brief Elliptic Orbital elements
261 *
262 *  TODO.
263 * Angles are expressed in degrees.
264 */
265 struct ln_ell_orbit
266 {
267 	double a;	/*!< Semi major axis, in AU */
268 	double e;	/*!< Eccentricity */
269 	double i;	/*!< Inclination in degrees */
270 	double w;	/*!< Argument of perihelion in degrees */
271 	double omega;	/*!< Longitude of ascending node in degrees*/
272 	double n;	/*!< Mean motion, in degrees/day */
273 	double JD;	/*!< Time of last passage in Perihelion, in julian day*/
274 };
275 
276 /*!
277 * \struct ln_par_orbit
278 * \brief Parabolic Orbital elements
279 *
280 *  TODO.
281 * Angles are expressed in degrees.
282 */
283 struct ln_par_orbit
284 {
285 	double q;	/*!< Perihelion distance in AU */
286 	double i;	/*!< Inclination in degrees */
287 	double w;	/*!< Argument of perihelion in degrees */
288 	double omega;	/*!< Longitude of ascending node in degrees*/
289 	double JD;	/*!< Time of last passage in Perihelion, in julian day */
290 };
291 
292 /*!
293 * \struct ln_hyp_orbit
294 * \brief Hyperbolic Orbital elements
295 *
296 *  TODO.
297 * Angles are expressed in degrees.
298 */
299 struct ln_hyp_orbit
300 {
301 	double q;	/*!< Perihelion distance in AU */
302 	double e;	/*!< Eccentricity */
303 	double i;	/*!< Inclination in degrees */
304 	double w;	/*!< Argument of perihelion in degrees */
305 	double omega;	/*!< Longitude of ascending node in degrees*/
306 	double JD;	/*!< Time of last passage in Perihelion, in julian day*/
307 };
308 
309 /*!
310 * \struct ln_rst_time
311 * \brief Rise, Set and Transit times.
312 *
313 * Contains the Rise, Set and transit times for a body.
314 *
315 * Angles are expressed in degrees.
316 */
317 struct ln_rst_time
318 {
319 	double rise;		/*!< Rise time in JD */
320 	double set;			/*!< Set time in JD */
321 	double transit;		/*!< Transit time in JD */
322 };
323 
324 /*!
325 * \struct ln_nutation
326 * \brief Nutation in longitude, ecliptic and obliquity.
327 *
328 * Contains Nutation in longitude, obliquity and ecliptic obliquity.
329 *
330 * Angles are expressed in degrees.
331 */
332 struct ln_nutation
333 {
334 	double longitude;	/*!< Nutation in longitude, in degrees */
335 	double obliquity;	/*!< Nutation in obliquity, in degrees */
336 	double ecliptic;	/*!< Mean obliquity of the ecliptic, in degrees */
337 };
338 
339 /* Definitions of POSIX structures for Win32. */
340 #ifdef __WIN32__
341 
342 #include <time.h>
343 
344 struct timeval
345 {
346 	time_t  tv_sec;         /* count of seconds since Jan. 1, 1970 */
347 	long    tv_usec;        /* and microseconds */
348 };
349 
350 struct timezone
351 {
352 	int     tz_minuteswest; /* Minutes west of GMT */
353 	int     tz_dsttime;     /* DST correction offset */
354 };
355 
356 #endif /* __WIN32__ */
357 
358 #ifdef __cplusplus
359 };
360 #endif
361 
362 #endif
363 
364