libnova  v 0.15.0
utility.h
00001 /*
00002  *  This library is free software; you can redistribute it and/or
00003  *  modify it under the terms of the GNU Lesser General Public
00004  *  License as published by the Free Software Foundation; either
00005  *  version 2 of the License, or (at your option) any later version.
00006  *
00007  *  This library is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00010  *  Lesser General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00015  *  
00016  *  Copyright (C) 2000 - 2005 Liam Girdwood  
00017  */
00018 
00019 #ifndef _LN_UTILITY_H
00020 #define _LN_UTILITY_H
00021 
00022 #include <libnova/ln_types.h>
00023 
00024 #ifdef __WIN32__
00025 #include <time.h>
00026 // cbrt replacement
00027 #define cbrt(x)   pow (x,1.0/3.0)
00028 #endif
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 
00042 const char LIBNOVA_EXPORT *  ln_get_version (void);
00043 
00053 double LIBNOVA_EXPORT ln_get_dec_location(char *s);
00054 
00055 
00060 const char LIBNOVA_EXPORT * ln_get_humanr_location(double location);
00061 
00062 /*
00063 * \fn double ln_get_rect_distance (struct ln_rect_posn * a, struct ln_rect_posn * b)
00064 * \ingroup misc
00065 */
00066 double LIBNOVA_EXPORT ln_get_rect_distance (struct ln_rect_posn * a, struct ln_rect_posn * b);
00067 
00077 double LIBNOVA_EXPORT ln_rad_to_deg (double radians);
00078 
00083 double LIBNOVA_EXPORT ln_deg_to_rad (double degrees);
00084 
00089 double LIBNOVA_EXPORT ln_hms_to_deg (struct ln_hms * hms);
00090 
00095 void LIBNOVA_EXPORT ln_deg_to_hms (double degrees, struct ln_hms * hms);
00096 
00101 double LIBNOVA_EXPORT ln_hms_to_rad (struct ln_hms * hms);
00102 
00107 void LIBNOVA_EXPORT ln_rad_to_hms (double radians, struct ln_hms * hms);
00108 
00113 double LIBNOVA_EXPORT ln_dms_to_deg (struct ln_dms * dms);
00114 
00119 void LIBNOVA_EXPORT ln_deg_to_dms (double degrees, struct ln_dms * dms);
00120 
00125 double LIBNOVA_EXPORT ln_dms_to_rad (struct ln_dms * dms);
00126 
00131 void LIBNOVA_EXPORT ln_rad_to_dms (double radians, struct ln_dms * dms);
00132 
00137 void LIBNOVA_EXPORT ln_hequ_to_equ (struct lnh_equ_posn * hpos, struct ln_equ_posn * pos);
00138         
00143 void LIBNOVA_EXPORT ln_equ_to_hequ (struct ln_equ_posn * pos, struct lnh_equ_posn * hpos);
00144         
00149 void LIBNOVA_EXPORT ln_hhrz_to_hrz (struct lnh_hrz_posn * hpos, struct ln_hrz_posn * pos);
00150         
00155 void LIBNOVA_EXPORT ln_hrz_to_hhrz (struct ln_hrz_posn * pos, struct lnh_hrz_posn * hpos);
00156 
00161 const char LIBNOVA_EXPORT * ln_hrz_to_nswe (struct ln_hrz_posn * pos);
00162         
00167 void LIBNOVA_EXPORT ln_hlnlat_to_lnlat (struct lnh_lnlat_posn * hpos, struct ln_lnlat_posn * pos);
00168         
00173 void LIBNOVA_EXPORT ln_lnlat_to_hlnlat (struct ln_lnlat_posn * pos, struct lnh_lnlat_posn * hpos);
00174         
00179 void LIBNOVA_EXPORT ln_add_secs_hms (struct ln_hms * hms, double seconds);
00180 
00185 void LIBNOVA_EXPORT ln_add_hms (struct ln_hms * source, struct ln_hms * dest);
00186 
00191 double LIBNOVA_EXPORT ln_range_degrees (double angle);
00192 
00197 double LIBNOVA_EXPORT ln_range_radians (double angle);
00198 double LIBNOVA_EXPORT ln_range_radians2 (double angle);
00199 
00200 /*
00201 * \fn double ln_get_light_time (double dist)
00202 * \brief Convert units of AU into light days.
00203 * \ingroup conversion
00204 */
00205 double LIBNOVA_EXPORT ln_get_light_time (double dist);
00206 
00211 double LIBNOVA_EXPORT ln_interpolate3 (double n, double y1, double y2, double y3);
00212 
00217 double LIBNOVA_EXPORT ln_interpolate5 (double n, double y1, double y2, double y3, double y4, double y5);
00218 
00219 #ifdef __WIN32__
00220 
00221 /* Catches calls to the POSIX gmtime_r and converts them to a related WIN32 version. */
00222 struct tm *gmtime_r (time_t *t, struct tm *gmt);
00223 
00224 /* Catches calls to the POSIX gettimeofday and converts them to a related WIN32 version. */
00225 int gettimeofday(struct timeval *tp, struct timezone *tzp);
00226 
00227 /* Catches calls to the POSIX strtok_r and converts them to a related WIN32 version. */
00228 char *strtok_r(char *str, const char *sep, char **last);
00229 
00230 #endif /* __WIN32__ */
00231 
00232 /* C89 substitutions for C99 functions. */
00233 #ifdef __C89_SUB__
00234 
00235 /* Simple cube root */
00236 double cbrt (double x);
00237 
00238 #endif /* __C89_SUB__ */
00239 
00240 #if defined(__WIN32__) || defined(sun) || defined(__C89_SUB__)
00241 
00242 /* Not a Number function generator */
00243 double nan (const char *code);
00244 
00245 #endif /* defined(__WIN32__) || defined(sun) || defined(__C89_SUB__) */
00246 
00247 #ifdef __cplusplus
00248 };
00249 #endif
00250 
00251 #endif