libnova v 0.16.0
Loading...
Searching...
No Matches
utility.h
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_UTILITY_H
20#define _LN_UTILITY_H
21
22#include <libnova/ln_types.h>
23
24#ifdef __WIN32__
25#include <time.h>
26// cbrt replacement
27#define cbrt(x) pow(x,1.0/3.0)
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
42const char LIBNOVA_EXPORT *ln_get_version(void);
43
53double LIBNOVA_EXPORT ln_get_dec_location(char *s);
54
55
60const char LIBNOVA_EXPORT *ln_get_humanr_location(double location);
61
62/*
63* \fn double ln_get_rect_distance(struct ln_rect_posn *a, struct ln_rect_posn *b)
64* \ingroup misc
65*/
66double LIBNOVA_EXPORT ln_get_rect_distance(struct ln_rect_posn *a,
67 struct ln_rect_posn *b);
68
78double LIBNOVA_EXPORT ln_rad_to_deg(double radians);
79
84double LIBNOVA_EXPORT ln_deg_to_rad(double degrees);
85
90double LIBNOVA_EXPORT ln_hms_to_deg(struct ln_hms *hms);
91
96void LIBNOVA_EXPORT ln_deg_to_hms(double degrees, struct ln_hms *hms);
97
102double LIBNOVA_EXPORT ln_hms_to_rad(struct ln_hms *hms);
103
108void LIBNOVA_EXPORT ln_rad_to_hms(double radians, struct ln_hms *hms);
109
114double LIBNOVA_EXPORT ln_dms_to_deg(struct ln_dms *dms);
115
120void LIBNOVA_EXPORT ln_deg_to_dms(double degrees, struct ln_dms *dms);
121
126double LIBNOVA_EXPORT ln_dms_to_rad(struct ln_dms *dms);
127
132void LIBNOVA_EXPORT ln_rad_to_dms(double radians, struct ln_dms *dms);
133
138void LIBNOVA_EXPORT ln_hequ_to_equ(struct lnh_equ_posn *hpos,
139 struct ln_equ_posn *pos);
140
145void LIBNOVA_EXPORT ln_equ_to_hequ(struct ln_equ_posn *pos,
146 struct lnh_equ_posn *hpos);
147
152void LIBNOVA_EXPORT ln_hhrz_to_hrz(struct lnh_hrz_posn *hpos,
153 struct ln_hrz_posn *pos);
154
159void LIBNOVA_EXPORT ln_hrz_to_hhrz(struct ln_hrz_posn *pos,
160 struct lnh_hrz_posn *hpos);
161
166const char LIBNOVA_EXPORT * ln_hrz_to_nswe(struct ln_hrz_posn *pos);
167
172void LIBNOVA_EXPORT ln_hlnlat_to_lnlat(struct lnh_lnlat_posn *hpos,
173 struct ln_lnlat_posn *pos);
174
179void LIBNOVA_EXPORT ln_lnlat_to_hlnlat(struct ln_lnlat_posn *pos,
180 struct lnh_lnlat_posn *hpos);
181
186void LIBNOVA_EXPORT ln_add_secs_hms(struct ln_hms *hms, double seconds);
187
192void LIBNOVA_EXPORT ln_add_hms(struct ln_hms *source, struct ln_hms *dest);
193
198double LIBNOVA_EXPORT ln_range_degrees(double angle);
199
204double LIBNOVA_EXPORT ln_range_radians(double angle);
205double LIBNOVA_EXPORT ln_range_radians2(double angle);
206
207/*
208* \fn double ln_get_light_time(double dist)
209* \brief Convert units of AU into light days.
210* \ingroup conversion
211*/
212double LIBNOVA_EXPORT ln_get_light_time(double dist);
213
218double LIBNOVA_EXPORT ln_interpolate3(double n, double y1, double y2, double y3);
219
224double LIBNOVA_EXPORT ln_interpolate5(double n, double y1, double y2, double y3,
225 double y4, double y5);
226
231double LIBNOVA_EXPORT ln_find_max(double (*func) (double, double *),
232 double from, double to, double *arg);
233
238double LIBNOVA_EXPORT ln_find_zero(double (*func) (double, double *),
239 double from, double to, double *arg);
240
241#ifdef __WIN32__
242
243/* Catches calls to the POSIX gmtime_r and converts them to a related WIN32 version. */
244struct tm *gmtime_r (time_t *t, struct tm *gmt);
245
246#ifndef __MINGW__
247/* Catches calls to the POSIX gettimeofday and converts them to a related WIN32 version. */
248int gettimeofday(struct timeval *tp, struct timezone *tzp);
249#endif // !__MINGW__
250
251/* Catches calls to the POSIX strtok_r and converts them to a related WIN32 version. */
252char *strtok_r(char *str, const char *sep, char **last);
253
254#endif /* __WIN32__ */
255
256/* C89 substitutions for C99 functions. */
257#ifdef __C89_SUB__
258
259/* Simple cube root */
260double cbrt(double x);
261
262#endif /* __C89_SUB__ */
263
264#if defined(__WIN32__) || defined(sun) || defined(__C89_SUB__)
265
266/* Not a Number function generator */
267double nan(const char *code);
268
269#endif /* defined(__WIN32__) || defined(sun) || defined(__C89_SUB__) */
270
271#ifdef __cplusplus
272};
273#endif
274
275#endif
void LIBNOVA_EXPORT ln_deg_to_hms(double degrees, struct ln_hms *hms)
degrees to hours
Definition: utility.c:124
void LIBNOVA_EXPORT ln_deg_to_dms(double degrees, struct ln_dms *dms)
degrees to dms
Definition: utility.c:197
void LIBNOVA_EXPORT ln_add_secs_hms(struct ln_hms *hms, double seconds)
add seconds to hms
Definition: utility.c:283
void LIBNOVA_EXPORT ln_lnlat_to_hlnlat(struct ln_lnlat_posn *pos, struct lnh_lnlat_posn *hpos)
double long/lat position to human readable long/lat position
Definition: utility.c:398
double LIBNOVA_EXPORT ln_hms_to_rad(struct ln_hms *hms)
hours to radians.
Definition: utility.c:111
void LIBNOVA_EXPORT ln_hrz_to_hhrz(struct ln_hrz_posn *pos, struct lnh_hrz_posn *hpos)
double horizontal position to human readable horizontal position
Definition: utility.c:365
void LIBNOVA_EXPORT ln_hlnlat_to_lnlat(struct lnh_lnlat_posn *hpos, struct ln_lnlat_posn *pos)
human readable long/lat position to double long/lat position
Definition: utility.c:388
const char LIBNOVA_EXPORT * ln_hrz_to_nswe(struct ln_hrz_posn *pos)
returns direction of given azimuth - like N,S,W,E,NSW,...
Definition: utility.c:375
double LIBNOVA_EXPORT ln_dms_to_rad(struct ln_dms *dms)
dms to radians
Definition: utility.c:181
double LIBNOVA_EXPORT ln_rad_to_deg(double radians)
radians to degrees
Definition: utility.c:87
void LIBNOVA_EXPORT ln_hhrz_to_hrz(struct lnh_hrz_posn *hpos, struct ln_hrz_posn *pos)
human readable horizontal position to double horizontal position
Definition: utility.c:355
double LIBNOVA_EXPORT ln_range_radians(double angle)
puts a large angle in the correct range 0 - 2PI radians
Definition: utility.c:252
void LIBNOVA_EXPORT ln_hequ_to_equ(struct lnh_equ_posn *hpos, struct ln_equ_posn *pos)
human readable equatorial position to double equatorial position
Definition: utility.c:335
double LIBNOVA_EXPORT ln_hms_to_deg(struct ln_hms *hms)
hours to degrees
Definition: utility.c:99
void LIBNOVA_EXPORT ln_add_hms(struct ln_hms *source, struct ln_hms *dest)
add hms to hms
Definition: utility.c:300
double LIBNOVA_EXPORT ln_range_degrees(double angle)
puts a large angle in the correct range 0 - 360 degrees
Definition: utility.c:237
double LIBNOVA_EXPORT ln_dms_to_deg(struct ln_dms *dms)
dms to degrees
Definition: utility.c:165
double LIBNOVA_EXPORT ln_deg_to_rad(double degrees)
degrees to radians
Definition: utility.c:93
void LIBNOVA_EXPORT ln_equ_to_hequ(struct ln_equ_posn *pos, struct lnh_equ_posn *hpos)
human double equatorial position to human readable equatorial position
Definition: utility.c:345
void LIBNOVA_EXPORT ln_rad_to_dms(double radians, struct ln_dms *dms)
radians to dms
Definition: utility.c:228
double LIBNOVA_EXPORT ln_find_max(double(*func)(double, double *), double from, double to, double *arg)
Find local maximum of function f() at given interval by Golden Section method.
Definition: utility.c:720
double LIBNOVA_EXPORT ln_interpolate3(double n, double y1, double y2, double y3)
Calculate an intermediate value of the 3 arguments.
Definition: utility.c:622
double LIBNOVA_EXPORT ln_find_zero(double(*func)(double, double *), double from, double to, double *arg)
Find zero of function f() at given interval by Newton method.
Definition: utility.c:692
const char LIBNOVA_EXPORT * ln_get_humanr_location(double location)
Obtains a human readable location in the form: ddÂșmm'ss.ss"
Definition: utility.c:600
double LIBNOVA_EXPORT ln_get_dec_location(char *s)
Obtains Latitude, Longitude, RA or Declination from a string.
Definition: utility.c:515
double LIBNOVA_EXPORT ln_interpolate5(double n, double y1, double y2, double y3, double y4, double y5)
Calculate an intermediate value of the 5 arguments.
Definition: utility.c:650
const char LIBNOVA_EXPORT * ln_get_version(void)
Library Version Number.
Definition: utility.c:80
Definition: aberration.c:30
Degrees, minutes and seconds.
Definition: ln_types.h:114
Equatorial Coordinates.
Definition: ln_types.h:176
Hours, minutes and seconds.
Definition: ln_types.h:127
Horizontal Coordinates.
Definition: ln_types.h:189
Ecliptical (or celestial) Longitude and Latitude.
Definition: ln_types.h:204
Rectangular coordinates.
Definition: ln_types.h:239
Right Ascension and Declination.
Definition: ln_types.h:139
Azimuth and Altitude.
Definition: ln_types.h:150
Ecliptical (or celestial) Latitude and Longitude.
Definition: ln_types.h:162