Geo Stars Library  0.9.3
Geodetic and Astrometry library
geoStars.h File Reference
#include <time.h>
Include dependency graph for geoStars.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GEO_ELLIPSOID
 
struct  GEO_DATUM
 
struct  GEO_LOCATION
 
struct  WMM_DATA
 

Macros

#define GEOSTARSLIB_VERSION   0.9
 
#define DLL_API
 DLL calling convention. More...
 
#define DLL_CALLCONV
 DLL calling convention. More...
 
#define GEO_DATUM_DEFAULT   0
 Default datum (WGS84) More...
 
#define GEO_DATUM_AA   1
 Datum : Airy 1830. More...
 
#define GEO_DATUM_AN   2
 Datum : Australian National. More...
 
#define GEO_DATUM_BR   3
 Datum : Bessel 1841. More...
 
#define GEO_DATUM_BN   4
 Datum : Bessel 1841 (Namibia) More...
 
#define GEO_DATUM_CC   5
 Datum : Clarke 1866. More...
 
#define GEO_DATUM_CD   6
 Datum : Clarke 1880. More...
 
#define GEO_DATUM_EB   7
 Datum : Everest (Brunei, E. Malaysia (Sabah and Sarawak)) More...
 
#define GEO_DATUM_EA   8
 Datum : Everest 1830. More...
 
#define GEO_DATUM_EC   9
 Datum : Everest 1956 (India and Nepal) More...
 
#define GEO_DATUM_EF   10
 Datum : Everest (Pakistan) More...
 
#define GEO_DATUM_EE   11
 Datum : Everest 1948 (W. Malaysia and Singapore) More...
 
#define GEO_DATUM_ED   12
 Datum : Everest 1969 (W. Malaysia) More...
 
#define GEO_DATUM_RF   13
 Datum : Geodetic Reference System 1980 (GRS80) More...
 
#define GEO_DATUM_HE   14
 Datum : Helmert 1906. More...
 
#define GEO_DATUM_HO   15
 Datum : Hough 1960. More...
 
#define GEO_DATUM_ID   16
 Datum : Indonesian 1974. More...
 
#define GEO_DATUM_IN   17
 Datum : International 1924. More...
 
#define GEO_DATUM_KA   18
 Datum : Krassovsky 1940. More...
 
#define GEO_DATUM_AM   19
 Datum : Modified Airy. More...
 
#define GEO_DATUM_FA   20
 Datum : Modified Fischer 1960. More...
 
#define GEO_DATUM_SA   21
 Datum : South American 1969. More...
 
#define GEO_DATUM_WD   22
 Datum : WGS 1972. More...
 
#define GEO_DATUM_WE   23
 Datum : WGS 1984. More...
 
#define GEO_DATUM_83   24
 Datum : NAD 1983 (same as GRS80) More...
 
#define GEO_DATUM_MAX   GEO_DATUM_83
 
#define GEO_OK   0
 Geo Library return OK. More...
 
#define GEO_ERROR   1
 Geo Library return ERROR. More...
 
#define M_PI   3.14159265358979323846
 Value of $\pi$. More...
 
#define TWO_PI   (2.0*M_PI)
 
#define sqr(n)   (n*n)
 
#define cube(n)   (n*n*n)
 
#define DEG_TO_RAD   (M_PI/180.0)
 Degrees to Radians conversion factor. More...
 
#define RAD_TO_DEG   (180.0/M_PI)
 Radians to Degrees conversion factor. More...
 
#define MIN_TO_DEG   (1.0/60.0)
 Minutes to Degrees conversion factor. More...
 
#define DEG_TO_MIN   (60.0)
 Degrees to Minutes conversion factor. More...
 
#define SEC_TO_DEG   (1.0/3600.0)
 Seconds to Degrees conversion factor. More...
 
#define SIN_1   (sin(SEC_TO_DEG*DEG_TO_RAD))
 
#define CIRCLE   (360.0)
 
#define HALF_CIRCLE   (CIRCLE / 2.0)
 
#define DELTA_LAT   (0.000000001)
 Delta Lat for EFG2LLH routines. More...
 
#define SOLAR_RADIUS   0.2666
 
#define SOLAR_DIAMETER   (2.0 * SOLAR_SEMIDIAMETER)
 
#define GEO_B(a, f)   (a*(1.0-(1.0/f)))
 
#define GEO_FL(f)   (1.0/f)
 
#define GEO_E2(a, f)   (((a*a) - ((GEO_B(a,f))*(GEO_B(a,f))))/(a*a))
 
#define GEO_E2P(a, f)   (((a*a) - ((GEO_B(a,f))*(GEO_B(a,f))))/((GEO_B(a,f))*(GEO_B(a,f))))
 
#define GEO_WGS84_a   (6378137.0)
 
#define GEO_WGS84_b   GEO_B(GEO_WGS84_a,298.257223563)
 
#define GEO_WGS84_fl   GEO_FL(298.257223563)
 
#define GEO_WGS84_e2   GEO_E2(GEO_WGS84_a,298.257223563)
 
#define GEO_WGS84_ee2   GEO_E2P(GEO_WGS84_a,298.257223563)
 
#define GEO_LAT   0
 Latitude. More...
 
#define GEO_LON   1
 Longitude. More...
 
#define GEO_HGT   2
 Height ( METERS ) More...
 
#define GEO_X   0
 X or East coordinate of the local tangential plane ( METERS ) More...
 
#define GEO_Y   1
 Y or North coordinate of the local tangential plane ( METERS ) More...
 
#define GEO_Z   2
 Z or Up coordinate of the local tangential plane ( METERS ) More...
 
#define GEO_E   0
 E coordinate of Earth Fixed Geocentric coordinate ( METERS ) More...
 
#define GEO_F   1
 F coordinate of Earth Fixed Geocentric coordinate ( METERS ) More...
 
#define GEO_G   2
 G coordinate of Earth Fixed Geocentric coordinate ( METERS ) More...
 
#define GEO_RNG   0
 Slant range ( METERS ) More...
 
#define GEO_AZ   1
 Azimuth, clockwise from north. More...
 
#define GEO_EL   2
 Elevation, from horizon (0) up. More...
 
#define GEO_SZ_ELLIPSOID_NAME   82
 Max size of the Ellipsoid name field. More...
 
#define GEO_EFG2LLH_MAX_ITS   10
 Max iterations allowed in the efg2llh routines. More...
 
#define GEO_EFG2LLH_ACCURACY_METER   0.00001
 Use Meter Accuracy in Efg2Llh routines. More...
 
#define GEO_EFG2LLH_ACCURACY_CM   0.0000001
 Use Centimeter Accuracy in Efg2Llh routines. More...
 
#define GEO_EFG2LLH_ACCURACY_MM   0.00000001
 Use Millimeter Accuracy in Efg2Llh routines. More...
 
#define GEO_EFG2LLH_ACCURACY_MAX   0.0
 Use Maximum Accuracy in Efg2Llh routines. More...
 
#define GEO_EFG2LLH_ACCURACY   GEO_EFG2LLH_ACCURACY_MM
 Millimeter accuracy is default. More...
 
#define MAX(a, b)   ((a>b)?(a):(b))
 

Functions

void geoGetEllipsoid (double *a, double *b, double *e2, double *ee2, double *f, int datum)
 This routine computes essential datum values from basic parameters obtained from the ellips structure. More...
 
int geoInitDatum (GEO_DATUM *d, int datum)
 
int geoInitLocation (GEO_LOCATION *l, double lat, double lon, double hgt, int datum, char *name)
 This routine needs to be called when a site (or location) is initialized. Several of the routines use the information in the structure that this routine fills. More...
 
int geoInitLocation2 (GEO_LOCATION *l, double lat, double lon, double hgt, const GEO_DATUM *datum, const char *name)
 
void geoSetTimeZone (GEO_LOCATION *l, double tz, int dst)
 
int geoSunAzElNow (GEO_LOCATION *loc, double *az, double *el)
 this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location More...
 
int geoSunAzEltm (GEO_LOCATION *loc, double *az, double *el, struct tm *newtime)
 this routine ingests an ANSI C time structure and then gets the az and el of the sun at this location based on this time. More...
 
int geoSunAzElJD (GEO_LOCATION *loc, double *az, double *el, double tjd_now)
 This routine uses a previously determined Julian date and then gets the Az and El of the sun at this location based on the Julian date. More...
 
int geoGetSunError (void)
 
int geoGettm (int part)
 
double geoSunNowEl (double lat, double lon, double hgt)
 this routine uses the location and current time to get the elevation of the sun at this location More...
 
double geoSunNowAz (double lat, double lon, double hgt)
 this routine uses the location and current time to get the azimuth of the sun at this location More...
 
double geoVersion (void)
 This function returns the version of the GeoStarsLib. More...
 
int geoEfg2XyzDiff (GEO_LOCATION *src_desc, GEO_LOCATION *tgt_desc, double xyz_disp[])
 This function returns the XYZ offset of the target point with respect to the source point, given the Earth Fixed Geodetic coordinates of the points. The EFG coordinates for the source must appear in the GEO_LOCATION record, which must be built previous to the call to this procedure. More...
 
int geoEfg2XyzDiff_packed (GEO_LOCATION *src_desc, int count, double efg_xyz[])
 This function returns the XYZ offset of the target point with respect to the source point, given the Earth Fixed Geodetic coordinates of the points. The EFG coordinates for the source must appear in the GEO_LOCATION record, which must be built previous to the call to this procedure. More...
 
void geoRae2Efg (GEO_LOCATION *loc, double aer_in[], double efg_out[])
 Ingests Range, Azimuth, Elevation and site info and returns the EFG coordinates that the RAE points to. More...
 
void geoEfg2Llh (int datum, double efg[], double *lat, double *lon, double *hgt)
 This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
void geoEfg2Llh_packed (const GEO_DATUM *datum, int count, double efg_llh[])
 
double geoEfg2Lat (int datum, double e, double f, double g)
 
double geoEfg2Lon (int datum, double e, double f, double g)
 
double geoEfg2Hgt (int datum, double e, double f, double g)
 
void geoEfg2Llh_hm (int datum, double efg[], double *lat, double *lon, double *hgt)
 Hirvonen & Moritz Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_hm (int datum, double e, double f, double g)
 
double geoEfg2Lon_hm (int datum, double e, double f, double g)
 
double geoEfg2Hgt_hm (int datum, double e, double f, double g)
 
double geoEfg2Hgt_hm_its (int datum, double e, double f, double g)
 
void geoEfg2Llh_torge (int datum, double efg[], double *lat, double *lon, double *hgt)
 Torge Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_torge (int datum, double e, double f, double g)
 
double geoEfg2Lon_torge (int datum, double e, double f, double g)
 
double geoEfg2Hgt_torge (int datum, double e, double f, double g)
 
double geoEfg2Hgt_torge_its (int datum, double e, double f, double g)
 
void geoEfg2Llh_bowring (int datum, double efg[], double *lat, double *lon, double *hgt)
 Bowring Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_bowring (int datum, double e, double f, double g)
 
double geoEfg2Lon_bowring (int datum, double e, double f, double g)
 
double geoEfg2Hgt_bowring (int datum, double e, double f, double g)
 
double geoEfg2Hgt_bowring_its (int datum, double e, double f, double g)
 
void geoEfg2Llh_aa (int datum, double efg[], double *lat, double *lon, double *hgt)
 Astronomical Almanac 2002 Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_aa (int datum, double e, double f, double g)
 
double geoEfg2Lon_aa (int datum, double e, double f, double g)
 
double geoEfg2Hgt_aa (int datum, double e, double f, double g)
 
double geoEfg2Hgt_aa_its (int datum, double e, double f, double g)
 
void geoEfg2Llh_borkowski (int datum, double efg[], double *lat, double *lon, double *hgt)
 Borkowski Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_borkowski (int datum, double e, double f, double g)
 
double geoEfg2Lon_borkowski (int datum, double e, double f, double g)
 
double geoEfg2Hgt_borkowski (int datum, double e, double f, double g)
 
void geoEfg2Llh_vermeille (int datum, double efg[], double *lat, double *lon, double *hgt)
 Vermeille Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_vermeille (int datum, double e, double f, double g)
 
double geoEfg2Lon_vermeille (int datum, double e, double f, double g)
 
double geoEfg2Hgt_vermeille (int datum, double e, double f, double g)
 
void geoEfg2Llh_heikkinen (int datum, double efg[], double *lat, double *lon, double *hgt)
 heikkinen Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_heikkinen (int datum, double e, double f, double g)
 
double geoEfg2Lon_heikkinen (int datum, double e, double f, double g)
 
double geoEfg2Hgt_heikkinen (int datum, double e, double f, double g)
 
void geoEfg2Llh_toms (int datum, double efg[], double *lat, double *lon, double *hgt)
 
double geoEfg2Lat_toms (int datum, double e, double f, double g)
 
double geoEfg2Lon_toms (int datum, double e, double f, double g)
 
double geoEfg2Hgt_toms (int datum, double e, double f, double g)
 
int geoEfg2LlhGetIts (void)
 
int geoSetAccuracy (double acc)
 This routine will set the accuracy of the iterative Efg2Llh routines (geoEfg2Llh_hm, geoEfg2Llh_torge, geoEfg2Llh_bowring, geoEfg2Llh_aa) More...
 
void geoEfg2Llh_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
void geoEfg2Llh_fast_packed (const GEO_DATUM *datum, int count, double efg_llh[])
 
void geoEfg2Llh_fast_packed2 (const GEO_DATUM *datum, int count, double efg_in[], double llh_out[])
 
double geoEfg2Lat_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_hm_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Hirvonen & Moritz Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_hm_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_hm_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_hm_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_torge_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Torge Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_torge_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_torge_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_torge_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_bowring_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Bowring Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_bowring_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_bowring_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_bowring_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_aa_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Astronomical Almanac 2002 Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_aa_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_aa_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_aa_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_borkowski_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Borkowski Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_borkowski_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_borkowski_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_borkowski_fast (int datum, double e, double f, double g)
 
void geoEfg2Llh_vermeille_fast (int datum, double efg[], double *lat, double *lon, double *hgt)
 Vermeille Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$). More...
 
double geoEfg2Lat_vermeille_fast (int datum, double e, double f, double g)
 
double geoEfg2Lon_vermeille_fast (int datum, double e, double f, double g)
 
double geoEfg2Hgt_vermeille_fast (int datum, double e, double f, double g)
 
void geoLlh2Efg (double lat, double lon, double height, int datum, double *e, double *f, double *g)
 This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). More...
 
void geoLlh2Efg_packed (GEO_DATUM *datum, int count, double llh_efg[])
 This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). More...
 
double geoLlh2E (double lat, double lon, double height, int datum)
 This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the E component. More...
 
double geoLlh2F (double lat, double lon, double height, int datum)
 This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the F component. More...
 
double geoLlh2G (double lat, double lon, double height, int datum)
 This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the G component. More...
 
double geoLlh2DiffX (double lat1, double lon1, double hgt1, int datum1, double lat2, double lon2, double hgt2, int datum2)
 
double geoLlh2DiffY (double lat1, double lon1, double hgt1, int datum1, double lat2, double lon2, double hgt2, int datum2)
 
double geoLlh2DiffZ (double lat1, double lon1, double hgt1, int datum1, double lat2, double lon2, double hgt2, int datum2)
 
void geoXyz2Rae (double xyz_in[], double rae_out[])
 Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2Rae calculates the range, azimuth, and elevation to that point. More...
 
void geoXyz2Rae_packed (int count, double xyz_rae[])
 Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2Rae calculates the range, azimuth, and elevation to that point. More...
 
double geoXyz2R (double x, double y, double z)
 Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the range to that point. More...
 
double geoXyz2A (double x, double y, double z)
 Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the azimuth to that point. More...
 
double geoXyz2E (double x, double y, double z)
 Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the elevation angle to that point. More...
 
void geoXyz2Efg (GEO_LOCATION *loc, double xyz_in[], double efg_out[])
 Ingests X, Y, Z, and site info and returns the EFG coordinates. More...
 
void geoXyz2Efg_packed (GEO_LOCATION *loc, int size, double xyz_efg[])
 This routine takes site info and iterates over count vertices in the tightly packed array xyz_efg converting it from cartesian XYZ into geocentric EFG coordinates. More...
 
void geoRae2Xyz (double rae_in[], double xyz_out[])
 This routine converts from Range, Azimuth, and Elevation into Cartesian coordinates X,Y,Z. More...
 
void geoRae2Xyz_packed (int size, double rae_xyz[])
 This routine iterates over count vertices in the array rae_xyz converting it from Range, Azimuth, and Elevation into Cartesian coordinates X,Y,Z. More...
 
double geoRads2Decdms (double rads)
 Convert radians to decimal degrees, minutes, and seconds ("dddmmss.s"). More...
 
void geoRads2Dms (double rads, double *deg, double *min, double *sec, double *dir)
 Converts radians to degrees minutes seconds. More...
 
double geoRads2DD (double rads)
 Converts radians to Decimal Degrees. More...
 
double geoDecdms2Rads (double in)
 Convert decimal degrees, minutes, and seconds ("dmmss.s") to radians. More...
 
double geoDms2DD (double deg, double min, double sec, char *sign)
 Converts degrees minutes seconds to Decimal Degrees. More...
 
double geoDms2Rads (double deg, double min, double sec, char *sign)
 Converts degrees minutes seconds to radians. More...
 
void geoDD2Dms (double dd, double *deg, double *min, double *sec, double *dir)
 Converts Decimal Degrees to degrees minutes seconds. More...
 
double geoDD2Rads (double dd)
 Converts Decimal Degrees to radians. More...
 
double geoDD2Deg (double dd)
 
double geoDD2Min (double dd)
 
double geoDD2Sec (double dd)
 
int geomg1 (double alt, double glat, double glon, double time, double *dec, double *dip, double *ti, double *gv)
 
int geoMag (double alt, double glat, double glon, double time, double *dec, double *dip, double *ti, double *gv, double *adec, double *adip, double *ati, double *x, double *y, double *z, double *h, double *ax, double *ay, double *az, double *ah)
 This routine computes all of the relevant geomagnetic data. More...
 
int geoMagGetDec (double lat, double lon, double hgt, int month, int day, int year, double *dec)
 This routine computes magnetic declination. More...
 
double geoMagGetDecRet (double lat, double lon, double hgt, int month, int day, int year)
 This routine computes and returns magnetic declination for a specific date. More...
 
int geoMagFillDec (GEO_LOCATION *l, double *dec)
 
double geoMagGetDecNow (double lat, double lon, double hgt)
 This routine computes magnetic declination for now time. More...
 
int geoSun (GEO_LOCATION *loc, struct tm *newtime, double *az, double *el)
 
int geoSunM (GEO_LOCATION *loc, struct tm *newtime, double *az, double *el)
 
int geoSunAA (GEO_LOCATION *loc, struct tm *newtime, double *az, double *el)
 
int geoSunPosition (GEO_LOCATION *loc, double *az, double *el)
 this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location More...
 

Variables

double geoAccuracy
 
GEO_ELLIPSOID ellips []
 This structure array contains the all of the ellipsoids used in this library. More...
 
int geoSunError
 

Detailed Description

rief This file has all of the definitions for the Geo Library: geoEllips, geoAstro, geoPoint, and geoMag.

Definition in file geoStars.h.

Macro Definition Documentation

#define CIRCLE   (360.0)

Definition at line 600 of file geoStars.h.

Referenced by geomg1().

#define DEG_TO_MIN   (60.0)

Degrees to Minutes conversion factor.

Definition at line 597 of file geoStars.h.

Referenced by geoMag().

#define DEG_TO_RAD   (M_PI/180.0)

Degrees to Radians conversion factor.

Definition at line 594 of file geoStars.h.

Referenced by geoDD2Rads(), geoDecdms2Rads(), geoDms2Rads(), geoInitLocation(), geoMag(), geomg1(), geoSun(), geoSunAA(), and geoSunM().

#define DELTA_LAT   (0.000000001)

Delta Lat for EFG2LLH routines.

Definition at line 602 of file geoStars.h.

#define DLL_API

DLL calling convention.

Definition at line 529 of file geoStars.h.

#define DLL_CALLCONV

DLL calling convention.

Definition at line 530 of file geoStars.h.

#define GEO_AZ   1

Azimuth, clockwise from north.

Definition at line 665 of file geoStars.h.

Referenced by geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2A(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEO_B (   a,
 
)    (a*(1.0-(1.0/f)))

All geodetic datums and ellipsoids are defined by flattening $f$ and the major axis $a$. From these parameters, the other axis and eccentricity can be calculated. Minor Axis $b$ of the Earth is calculated from the Inverse Flattening $f^{-1}$ and the Major Axis $a$.

Where

\[b={a (1- \frac{1}{f^{-1}})}\]

Definition at line 640 of file geoStars.h.

Referenced by geoGetEllipsoid(), and geomg1().

#define GEO_DATUM_83   24

Datum : NAD 1983 (same as GRS80)

Definition at line 574 of file geoStars.h.

#define GEO_DATUM_AA   1

Datum : Airy 1830.

Definition at line 551 of file geoStars.h.

#define GEO_DATUM_AM   19

Datum : Modified Airy.

Definition at line 569 of file geoStars.h.

#define GEO_DATUM_AN   2

Datum : Australian National.

Definition at line 552 of file geoStars.h.

#define GEO_DATUM_BN   4

Datum : Bessel 1841 (Namibia)

Definition at line 554 of file geoStars.h.

#define GEO_DATUM_BR   3

Datum : Bessel 1841.

Definition at line 553 of file geoStars.h.

#define GEO_DATUM_CC   5

Datum : Clarke 1866.

Definition at line 555 of file geoStars.h.

#define GEO_DATUM_CD   6

Datum : Clarke 1880.

Definition at line 556 of file geoStars.h.

#define GEO_DATUM_DEFAULT   0

Default datum (WGS84)

Definition at line 550 of file geoStars.h.

Referenced by geoSunNowAz(), and geoSunNowEl().

#define GEO_DATUM_EA   8

Datum : Everest 1830.

Definition at line 558 of file geoStars.h.

#define GEO_DATUM_EB   7

Datum : Everest (Brunei, E. Malaysia (Sabah and Sarawak))

Definition at line 557 of file geoStars.h.

#define GEO_DATUM_EC   9

Datum : Everest 1956 (India and Nepal)

Definition at line 559 of file geoStars.h.

#define GEO_DATUM_ED   12

Datum : Everest 1969 (W. Malaysia)

Definition at line 562 of file geoStars.h.

#define GEO_DATUM_EE   11

Datum : Everest 1948 (W. Malaysia and Singapore)

Definition at line 561 of file geoStars.h.

#define GEO_DATUM_EF   10

Datum : Everest (Pakistan)

Definition at line 560 of file geoStars.h.

#define GEO_DATUM_FA   20

Datum : Modified Fischer 1960.

Definition at line 570 of file geoStars.h.

#define GEO_DATUM_HE   14

Datum : Helmert 1906.

Definition at line 564 of file geoStars.h.

#define GEO_DATUM_HO   15

Datum : Hough 1960.

Definition at line 565 of file geoStars.h.

#define GEO_DATUM_ID   16

Datum : Indonesian 1974.

Definition at line 566 of file geoStars.h.

#define GEO_DATUM_IN   17

Datum : International 1924.

Definition at line 567 of file geoStars.h.

#define GEO_DATUM_KA   18

Datum : Krassovsky 1940.

Definition at line 568 of file geoStars.h.

#define GEO_DATUM_MAX   GEO_DATUM_83

Definition at line 577 of file geoStars.h.

Referenced by geoInitLocation().

#define GEO_DATUM_RF   13

Datum : Geodetic Reference System 1980 (GRS80)

Definition at line 563 of file geoStars.h.

#define GEO_DATUM_SA   21

Datum : South American 1969.

Definition at line 571 of file geoStars.h.

#define GEO_DATUM_WD   22

Datum : WGS 1972.

Definition at line 572 of file geoStars.h.

#define GEO_DATUM_WE   23

Datum : WGS 1984.

Definition at line 573 of file geoStars.h.

Referenced by geomg1().

#define GEO_E   0

E coordinate of Earth Fixed Geocentric coordinate ( METERS )

Definition at line 661 of file geoStars.h.

Referenced by geoEfg2Hgt(), geoEfg2Hgt_aa(), geoEfg2Hgt_aa_fast(), geoEfg2Hgt_aa_its(), geoEfg2Hgt_borkowski(), geoEfg2Hgt_borkowski_fast(), geoEfg2Hgt_bowring(), geoEfg2Hgt_bowring_fast(), geoEfg2Hgt_bowring_its(), geoEfg2Hgt_fast(), geoEfg2Hgt_heikkinen(), geoEfg2Hgt_hm(), geoEfg2Hgt_hm_fast(), geoEfg2Hgt_hm_its(), geoEfg2Hgt_toms(), geoEfg2Hgt_torge(), geoEfg2Hgt_torge_fast(), geoEfg2Hgt_torge_its(), geoEfg2Hgt_vermeille(), geoEfg2Hgt_vermeille_fast(), geoEfg2Lat(), geoEfg2Lat_aa(), geoEfg2Lat_aa_fast(), geoEfg2Lat_borkowski(), geoEfg2Lat_borkowski_fast(), geoEfg2Lat_bowring(), geoEfg2Lat_bowring_fast(), geoEfg2Lat_fast(), geoEfg2Lat_heikkinen(), geoEfg2Lat_hm(), geoEfg2Lat_hm_fast(), geoEfg2Lat_torge(), geoEfg2Lat_torge_fast(), geoEfg2Lat_vermeille(), geoEfg2Lat_vermeille_fast(), geoEfg2Llh(), geoEfg2Llh_aa(), geoEfg2Llh_aa_fast(), geoEfg2Llh_borkowski(), geoEfg2Llh_borkowski_fast(), geoEfg2Llh_bowring(), geoEfg2Llh_bowring_fast(), geoEfg2Llh_fast(), geoEfg2Llh_heikkinen(), geoEfg2Llh_hm(), geoEfg2Llh_hm_fast(), geoEfg2Llh_toms(), geoEfg2Llh_torge(), geoEfg2Llh_torge_fast(), geoEfg2Llh_vermeille(), geoEfg2Llh_vermeille_fast(), geoEfg2Lon(), geoEfg2Lon_aa(), geoEfg2Lon_aa_fast(), geoEfg2Lon_borkowski(), geoEfg2Lon_borkowski_fast(), geoEfg2Lon_bowring(), geoEfg2Lon_bowring_fast(), geoEfg2Lon_fast(), geoEfg2Lon_heikkinen(), geoEfg2Lon_hm(), geoEfg2Lon_hm_fast(), geoEfg2Lon_toms(), geoEfg2Lon_torge(), geoEfg2Lon_torge_fast(), geoEfg2Lon_vermeille(), geoEfg2Lon_vermeille_fast(), geoEfg2XyzDiff_packed(), geoInitLocation(), geoLlh2Efg_packed(), geoRae2Efg(), geoXyz2Efg(), and geoXyz2Efg_packed().

#define GEO_E2 (   a,
 
)    (((a*a) - ((GEO_B(a,f))*(GEO_B(a,f))))/(a*a))

Eccentricity Squared $e^2$ is computed in the following manner:

\[e^2 = \frac{a^2 - b^2}{a^2}\]

Definition at line 642 of file geoStars.h.

Referenced by geoGetEllipsoid().

#define GEO_E2P (   a,
 
)    (((a*a) - ((GEO_B(a,f))*(GEO_B(a,f))))/((GEO_B(a,f))*(GEO_B(a,f))))

Eccentricity Squared Prime $e^2_p$ is computed in the following manner:

\[e^2_p = \frac{a^2 - b^2}{b^2}\]

Definition at line 643 of file geoStars.h.

Referenced by geoGetEllipsoid().

#define GEO_EFG2LLH_ACCURACY   GEO_EFG2LLH_ACCURACY_MM

Millimeter accuracy is default.

Definition at line 677 of file geoStars.h.

#define GEO_EFG2LLH_ACCURACY_CM   0.0000001

Use Centimeter Accuracy in Efg2Llh routines.

Definition at line 674 of file geoStars.h.

#define GEO_EFG2LLH_ACCURACY_MAX   0.0

Use Maximum Accuracy in Efg2Llh routines.

Definition at line 676 of file geoStars.h.

#define GEO_EFG2LLH_ACCURACY_METER   0.00001

Use Meter Accuracy in Efg2Llh routines.

Definition at line 673 of file geoStars.h.

#define GEO_EFG2LLH_ACCURACY_MM   0.00000001

Use Millimeter Accuracy in Efg2Llh routines.

Definition at line 675 of file geoStars.h.

#define GEO_EFG2LLH_MAX_ITS   10

Max iterations allowed in the efg2llh routines.

Definition at line 672 of file geoStars.h.

Referenced by geoEfg2Llh_aa(), geoEfg2Llh_bowring(), geoEfg2Llh_hm(), and geoEfg2Llh_torge().

#define GEO_EL   2

Elevation, from horizon (0) up.

Definition at line 666 of file geoStars.h.

Referenced by geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2E(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEO_ERROR   1

Geo Library return ERROR.

Definition at line 582 of file geoStars.h.

Referenced by geoInitLocation(), geoSetAccuracy(), and geoSunAzElJD().

#define GEO_F   1

F coordinate of Earth Fixed Geocentric coordinate ( METERS )

Definition at line 662 of file geoStars.h.

Referenced by geoEfg2Hgt(), geoEfg2Hgt_aa(), geoEfg2Hgt_aa_fast(), geoEfg2Hgt_aa_its(), geoEfg2Hgt_borkowski(), geoEfg2Hgt_borkowski_fast(), geoEfg2Hgt_bowring(), geoEfg2Hgt_bowring_fast(), geoEfg2Hgt_bowring_its(), geoEfg2Hgt_fast(), geoEfg2Hgt_heikkinen(), geoEfg2Hgt_hm(), geoEfg2Hgt_hm_fast(), geoEfg2Hgt_hm_its(), geoEfg2Hgt_toms(), geoEfg2Hgt_torge(), geoEfg2Hgt_torge_fast(), geoEfg2Hgt_torge_its(), geoEfg2Hgt_vermeille(), geoEfg2Hgt_vermeille_fast(), geoEfg2Lat(), geoEfg2Lat_aa(), geoEfg2Lat_aa_fast(), geoEfg2Lat_borkowski(), geoEfg2Lat_borkowski_fast(), geoEfg2Lat_bowring(), geoEfg2Lat_bowring_fast(), geoEfg2Lat_fast(), geoEfg2Lat_heikkinen(), geoEfg2Lat_hm(), geoEfg2Lat_hm_fast(), geoEfg2Lat_torge(), geoEfg2Lat_torge_fast(), geoEfg2Lat_vermeille(), geoEfg2Lat_vermeille_fast(), geoEfg2Llh(), geoEfg2Llh_aa(), geoEfg2Llh_aa_fast(), geoEfg2Llh_borkowski(), geoEfg2Llh_borkowski_fast(), geoEfg2Llh_bowring(), geoEfg2Llh_bowring_fast(), geoEfg2Llh_fast(), geoEfg2Llh_heikkinen(), geoEfg2Llh_hm(), geoEfg2Llh_hm_fast(), geoEfg2Llh_toms(), geoEfg2Llh_torge(), geoEfg2Llh_torge_fast(), geoEfg2Llh_vermeille(), geoEfg2Llh_vermeille_fast(), geoEfg2Lon(), geoEfg2Lon_aa(), geoEfg2Lon_aa_fast(), geoEfg2Lon_borkowski(), geoEfg2Lon_borkowski_fast(), geoEfg2Lon_bowring(), geoEfg2Lon_bowring_fast(), geoEfg2Lon_fast(), geoEfg2Lon_heikkinen(), geoEfg2Lon_hm(), geoEfg2Lon_hm_fast(), geoEfg2Lon_toms(), geoEfg2Lon_torge(), geoEfg2Lon_torge_fast(), geoEfg2Lon_vermeille(), geoEfg2Lon_vermeille_fast(), geoEfg2XyzDiff_packed(), geoInitLocation(), geoLlh2Efg_packed(), geoRae2Efg(), geoXyz2Efg(), and geoXyz2Efg_packed().

#define GEO_FL (   f)    (1.0/f)

Since the Geo Library ellips structure uses inverse flattening $f^{-1}$ then flattening can be calculated by

\[\frac{1}{f^{-1}}\]

Duh!

Definition at line 641 of file geoStars.h.

Referenced by geoGetEllipsoid().

#define GEO_G   2

G coordinate of Earth Fixed Geocentric coordinate ( METERS )

Definition at line 663 of file geoStars.h.

Referenced by geoEfg2Hgt(), geoEfg2Hgt_aa(), geoEfg2Hgt_aa_fast(), geoEfg2Hgt_aa_its(), geoEfg2Hgt_borkowski(), geoEfg2Hgt_borkowski_fast(), geoEfg2Hgt_bowring(), geoEfg2Hgt_bowring_fast(), geoEfg2Hgt_bowring_its(), geoEfg2Hgt_fast(), geoEfg2Hgt_heikkinen(), geoEfg2Hgt_hm(), geoEfg2Hgt_hm_fast(), geoEfg2Hgt_hm_its(), geoEfg2Hgt_toms(), geoEfg2Hgt_torge(), geoEfg2Hgt_torge_fast(), geoEfg2Hgt_torge_its(), geoEfg2Hgt_vermeille(), geoEfg2Hgt_vermeille_fast(), geoEfg2Lat(), geoEfg2Lat_aa(), geoEfg2Lat_aa_fast(), geoEfg2Lat_borkowski(), geoEfg2Lat_borkowski_fast(), geoEfg2Lat_bowring(), geoEfg2Lat_bowring_fast(), geoEfg2Lat_fast(), geoEfg2Lat_heikkinen(), geoEfg2Lat_hm(), geoEfg2Lat_hm_fast(), geoEfg2Lat_torge(), geoEfg2Lat_torge_fast(), geoEfg2Lat_vermeille(), geoEfg2Lat_vermeille_fast(), geoEfg2Llh(), geoEfg2Llh_aa(), geoEfg2Llh_aa_fast(), geoEfg2Llh_borkowski(), geoEfg2Llh_borkowski_fast(), geoEfg2Llh_bowring(), geoEfg2Llh_bowring_fast(), geoEfg2Llh_fast(), geoEfg2Llh_heikkinen(), geoEfg2Llh_hm(), geoEfg2Llh_hm_fast(), geoEfg2Llh_toms(), geoEfg2Llh_torge(), geoEfg2Llh_torge_fast(), geoEfg2Llh_vermeille(), geoEfg2Llh_vermeille_fast(), geoEfg2Lon(), geoEfg2Lon_aa(), geoEfg2Lon_aa_fast(), geoEfg2Lon_borkowski(), geoEfg2Lon_borkowski_fast(), geoEfg2Lon_bowring(), geoEfg2Lon_bowring_fast(), geoEfg2Lon_fast(), geoEfg2Lon_heikkinen(), geoEfg2Lon_hm(), geoEfg2Lon_hm_fast(), geoEfg2Lon_toms(), geoEfg2Lon_torge(), geoEfg2Lon_torge_fast(), geoEfg2Lon_vermeille(), geoEfg2Lon_vermeille_fast(), geoEfg2XyzDiff_packed(), geoInitLocation(), geoLlh2Efg_packed(), geoRae2Efg(), geoXyz2Efg(), and geoXyz2Efg_packed().

#define GEO_HGT   2

Height ( METERS )

Definition at line 657 of file geoStars.h.

Referenced by geoLlh2Efg_packed().

#define GEO_LAT   0

Latitude.

Definition at line 655 of file geoStars.h.

Referenced by geoLlh2Efg_packed().

#define GEO_LON   1

Longitude.

Definition at line 656 of file geoStars.h.

Referenced by geoLlh2Efg_packed().

#define GEO_OK   0
#define GEO_RNG   0

Slant range ( METERS )

Definition at line 664 of file geoStars.h.

Referenced by geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2R(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEO_SZ_ELLIPSOID_NAME   82

Max size of the Ellipsoid name field.

Definition at line 669 of file geoStars.h.

#define GEO_WGS84_b   GEO_B(GEO_WGS84_a,298.257223563)

Definition at line 647 of file geoStars.h.

Referenced by geoEfg2Llh_borkowski_fast(), geoEfg2Llh_bowring_fast(), and geoEfg2Llh_fast().

#define GEO_WGS84_ee2   GEO_E2P(GEO_WGS84_a,298.257223563)

Definition at line 650 of file geoStars.h.

Referenced by geoEfg2Llh_bowring_fast(), and geoEfg2Llh_fast().

#define GEO_WGS84_fl   GEO_FL(298.257223563)

Definition at line 648 of file geoStars.h.

#define GEO_X   0

X or East coordinate of the local tangential plane ( METERS )

Definition at line 658 of file geoStars.h.

Referenced by geoEfg2XyzDiff(), geoEfg2XyzDiff_packed(), geoLlh2DiffX(), geoRae2Efg(), geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2Efg(), geoXyz2Efg_packed(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEO_Y   1

Y or North coordinate of the local tangential plane ( METERS )

Definition at line 659 of file geoStars.h.

Referenced by geoEfg2XyzDiff(), geoEfg2XyzDiff_packed(), geoLlh2DiffY(), geoRae2Efg(), geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2Efg(), geoXyz2Efg_packed(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEO_Z   2

Z or Up coordinate of the local tangential plane ( METERS )

Definition at line 660 of file geoStars.h.

Referenced by geoEfg2XyzDiff(), geoEfg2XyzDiff_packed(), geoLlh2DiffZ(), geoRae2Efg(), geoRae2Xyz(), geoRae2Xyz_packed(), geoXyz2Efg(), geoXyz2Efg_packed(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define GEOSTARSLIB_VERSION   0.9

Definition at line 518 of file geoStars.h.

Referenced by geoVersion().

#define HALF_CIRCLE   (CIRCLE / 2.0)

Definition at line 601 of file geoStars.h.

Referenced by geomg1().

#define M_PI   3.14159265358979323846

Value of $\pi$.

Definition at line 585 of file geoStars.h.

Referenced by geoSunM(), geoXyz2Rae(), and geoXyz2Rae_packed().

#define MAX (   a,
 
)    ((a>b)?(a):(b))

Definition at line 791 of file geoStars.h.

#define MIN_TO_DEG   (1.0/60.0)

Minutes to Degrees conversion factor.

Definition at line 596 of file geoStars.h.

Referenced by geoDms2DD(), and geoDms2Rads().

#define SEC_TO_DEG   (1.0/3600.0)

Seconds to Degrees conversion factor.

Definition at line 598 of file geoStars.h.

Referenced by geoDms2DD(), and geoDms2Rads().

#define SIN_1   (sin(SEC_TO_DEG*DEG_TO_RAD))

Definition at line 599 of file geoStars.h.

#define SOLAR_DIAMETER   (2.0 * SOLAR_SEMIDIAMETER)

Definition at line 607 of file geoStars.h.

#define SOLAR_RADIUS   0.2666

Definition at line 606 of file geoStars.h.

#define TWO_PI   (2.0*M_PI)

Definition at line 588 of file geoStars.h.

Referenced by fractionalYearRad(), and geoSunM().

Function Documentation

double geoDD2Deg ( double  dd)

Definition at line 888 of file geoPoint.c.

References geoDD2Dms().

889 {
890  double deg, min, sec,dir;
891  geoDD2Dms(dd,&deg, &min, &sec,&dir);
892  return(deg*dir);
893 }

Here is the call graph for this function:

void geoDD2Dms ( double  dd,
double *  deg,
double *  min,
double *  sec,
double *  dir 
)

Converts Decimal Degrees to degrees minutes seconds.

Parameters
doubledecimal degrees
doubledeg, min, sec
chardir : -1.0 or 1.0
Returns
nothing

Definition at line 865 of file geoPoint.c.

Referenced by geoDD2Deg(), geoDD2Min(), and geoDD2Sec().

867 {
868  double temp;
869  double fraction;
870 
871  if (dd < 0.0)
872  *dir = -1.0;
873  else
874  *dir = 1.0;
875 
876  dd = fabs (dd);
877 
878  //temp = RAD_TO_DEG * rads;
879  fraction = modf(dd,deg);
880 
881  temp = fraction * 60.0;
882  fraction = modf(temp,min);
883 
884  *sec = fraction * 60.0;
885 }
double geoDD2Min ( double  dd)

Definition at line 894 of file geoPoint.c.

References geoDD2Dms().

895 {
896  double deg, min, sec,dir;
897  geoDD2Dms(dd,&deg, &min, &sec,&dir);
898  return(min);
899 }

Here is the call graph for this function:

double geoDD2Rads ( double  dd)

Converts Decimal Degrees to radians.

Parameters
doubledecimal degrees
Returns
radians

Definition at line 849 of file geoPoint.c.

References DEG_TO_RAD.

850 {
851  return(dd * DEG_TO_RAD);
852 }
double geoDD2Sec ( double  dd)

Definition at line 900 of file geoPoint.c.

References geoDD2Dms().

901 {
902  double deg, min, sec,dir;
903  geoDD2Dms(dd,&deg, &min, &sec,&dir);
904  return(sec);
905 }

Here is the call graph for this function:

double geoDecdms2Rads ( double  in)

Convert decimal degrees, minutes, and seconds ("dmmss.s") to radians.

Parameters
doublein; // decimal deg,min,sec
Returns
radians

Definition at line 756 of file geoPoint.c.

References DEG_TO_RAD.

757 {
758  double t1,m,d,s,sign;
759 
760  if (in < 0.0)
761  sign = -1.0;
762  else
763  sign = 1.0;
764 
765  s = modf(fabs(in)/100.0, &t1) * 100.0;
766  m = modf(t1/100.0, &d) * 100.0;
767 
768  /* Return radians to calling function. */
769  return( (d + (m/60.0) + (s/3600.0)) * sign * DEG_TO_RAD);
770 }
double geoDms2DD ( double  deg,
double  min,
double  sec,
char *  sign 
)

Converts degrees minutes seconds to Decimal Degrees.

Parameters
doubledeg, min, sec
charsign : N,E,S,W,-,+
Returns
decimal degrees

Definition at line 723 of file geoPoint.c.

References MIN_TO_DEG, and SEC_TO_DEG.

724 {
725  double direction;
726 
727  switch (toupper(*sign))
728  {
729  case '-':
730  case 'W': /* If coordinate is West or South, returned */
731  case 'S':
732  direction = -1.0; /* radian will have negative value. */
733  break;
734  case '+':
735  case 'E': /* If coordinate is East or North, returned */
736  case 'N':
737  direction = 1.0; /* radian will have positive value. */
738  break;
739  default:
740  direction = 1.0; /* If no compass direction entered, returned*/
741  } /* radian will be assumed positive. */
742 
743  /* Return radians to calling function. */
744  return( direction *
745  ( fabs(deg) + (min * MIN_TO_DEG) + (sec * SEC_TO_DEG)));
746 }
double geoDms2Rads ( double  deg,
double  min,
double  sec,
char *  sign 
)

Converts degrees minutes seconds to radians.

Parameters
doubledeg, min, sec
charsign : N,E,S,W,-,+
Returns
radians

Definition at line 692 of file geoPoint.c.

References DEG_TO_RAD, MIN_TO_DEG, and SEC_TO_DEG.

693 {
694  double direction;
695 
696  switch (toupper(*sign))
697  {
698  case '-':
699  case 'W': /* If coordinate is West or South, returned */
700  case 'S':
701  direction = -1.0; /* radian will have negative value. */
702  break;
703  case '+':
704  case 'E': /* If coordinate is East or North, returned */
705  case 'N':
706  direction = 1.0; /* radian will have positive value. */
707  break;
708  default:
709  direction = 1.0; /* If no compass direction entered, returned*/
710  } /* radian will be assumed positive. */
711 
712  /* Return radians to calling function. */
713  return( direction * DEG_TO_RAD *
714  ( fabs(deg) + (min * MIN_TO_DEG) + (sec * SEC_TO_DEG)));
715 }
double geoEfg2Hgt ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 125 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh().

126 {
127  double efg[3];
128  double lat, lon, hgt;
129  efg[GEO_E] = e;
130  efg[GEO_F] = f;
131  efg[GEO_G] = g;
132 
133  geoEfg2Llh (datum,efg,&lat,&lon,&hgt);
134  return(hgt);
135 }

Here is the call graph for this function:

double geoEfg2Hgt_aa ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 531 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_aa().

532 {
533  double efg[3];
534  double lat, lon, hgt;
535  efg[GEO_E] = e;
536  efg[GEO_F] = f;
537  efg[GEO_G] = g;
538 
539  geoEfg2Llh_aa (datum,efg,&lat,&lon,&hgt);
540  return(hgt);
541 }

Here is the call graph for this function:

double geoEfg2Hgt_aa_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 392 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_aa_fast().

393 {
394  double efg[3];
395  double lat, lon, hgt;
396  efg[GEO_E] = e;
397  efg[GEO_F] = f;
398  efg[GEO_G] = g;
399 
400  geoEfg2Llh_aa_fast (datum,efg,&lat,&lon,&hgt);
401  return(hgt);
402 }

Here is the call graph for this function:

double geoEfg2Hgt_aa_its ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 543 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_aa(), and geoEfg2LlhGetIts().

544 {
545  double efg[3];
546  double lat, lon, hgt;
547  efg[GEO_E] = e;
548  efg[GEO_F] = f;
549  efg[GEO_G] = g;
550 
551  geoEfg2Llh_aa (datum,efg,&lat,&lon,&hgt);
552  return((double)geoEfg2LlhGetIts());
553 }

Here is the call graph for this function:

double geoEfg2Hgt_borkowski ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 638 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_borkowski().

639 {
640  double efg[3];
641  double lat, lon, hgt;
642  efg[GEO_E] = e;
643  efg[GEO_F] = f;
644  efg[GEO_G] = g;
645 
646  geoEfg2Llh_borkowski (datum,efg,&lat,&lon,&hgt);
647  return(hgt);
648 }

Here is the call graph for this function:

double geoEfg2Hgt_borkowski_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 489 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_borkowski_fast().

490 {
491  double efg[3];
492  double lat, lon, hgt;
493  efg[GEO_E] = e;
494  efg[GEO_F] = f;
495  efg[GEO_G] = g;
496 
497  geoEfg2Llh_borkowski_fast (datum,efg,&lat,&lon,&hgt);
498  return(hgt);
499 }

Here is the call graph for this function:

double geoEfg2Hgt_bowring ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 429 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_bowring().

430 {
431  double efg[3];
432  double lat, lon, hgt;
433  efg[GEO_E] = e;
434  efg[GEO_F] = f;
435  efg[GEO_G] = g;
436 
437  geoEfg2Llh_bowring (datum,efg,&lat,&lon,&hgt);
438  return(hgt);
439 }

Here is the call graph for this function:

double geoEfg2Hgt_bowring_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 318 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_bowring_fast().

319 {
320  double efg[3];
321  double lat, lon, hgt;
322  efg[GEO_E] = e;
323  efg[GEO_F] = f;
324  efg[GEO_G] = g;
325 
326  geoEfg2Llh_bowring_fast (datum,efg,&lat,&lon,&hgt);
327  return(hgt);
328 }

Here is the call graph for this function:

double geoEfg2Hgt_bowring_its ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 441 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_bowring(), and geoEfg2LlhGetIts().

442 {
443  double efg[3];
444  double lat, lon, hgt;
445  efg[GEO_E] = e;
446  efg[GEO_F] = f;
447  efg[GEO_G] = g;
448 
449  geoEfg2Llh_bowring (datum,efg,&lat,&lon,&hgt);
450  return((double)geoEfg2LlhGetIts());
451 }

Here is the call graph for this function:

double geoEfg2Hgt_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 88 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_fast().

89 {
90  double efg[3];
91  double lat, lon, hgt;
92  efg[GEO_E] = e;
93  efg[GEO_F] = f;
94  efg[GEO_G] = g;
95 
96  geoEfg2Llh_fast (datum,efg,&lat,&lon,&hgt);
97  return(hgt);
98 }

Here is the call graph for this function:

double geoEfg2Hgt_heikkinen ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 831 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_heikkinen().

832 {
833  double efg[3];
834  double lat, lon, hgt;
835  efg[GEO_E] = e;
836  efg[GEO_F] = f;
837  efg[GEO_G] = g;
838 
839  geoEfg2Llh_heikkinen (datum,efg,&lat,&lon,&hgt);
840  return(hgt);
841 }

Here is the call graph for this function:

double geoEfg2Hgt_hm ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 213 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_hm().

214 {
215  double efg[3];
216  double lat, lon, hgt;
217  efg[GEO_E] = e;
218  efg[GEO_F] = f;
219  efg[GEO_G] = g;
220 
221  geoEfg2Llh_hm (datum,efg,&lat,&lon,&hgt);
222  return(hgt);
223 }

Here is the call graph for this function:

double geoEfg2Hgt_hm_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 160 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_hm_fast().

161 {
162  double efg[3];
163  double lat, lon, hgt;
164  efg[GEO_E] = e;
165  efg[GEO_F] = f;
166  efg[GEO_G] = g;
167 
168  geoEfg2Llh_hm_fast (datum,efg,&lat,&lon,&hgt);
169  return(hgt);
170 }

Here is the call graph for this function:

double geoEfg2Hgt_hm_its ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 225 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_hm(), and geoEfg2LlhGetIts().

226 {
227  double efg[3];
228  double lat, lon, hgt;
229  efg[GEO_E] = e;
230  efg[GEO_F] = f;
231  efg[GEO_G] = g;
232 
233  geoEfg2Llh_hm (datum,efg,&lat,&lon,&hgt);
234 
235  return((double)geoEfg2LlhGetIts());
236 }

Here is the call graph for this function:

double geoEfg2Hgt_toms ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 930 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_toms().

931 {
932  double efg[3];
933  double lat, lon, hgt;
934  efg[GEO_E] = e;
935  efg[GEO_F] = f;
936  efg[GEO_G] = g;
937 
938  geoEfg2Llh_toms (datum,efg,&lat,&lon,&hgt);
939  return(hgt);
940 }

Here is the call graph for this function:

double geoEfg2Hgt_torge ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 322 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_torge().

323 {
324  double efg[3];
325  double lat, lon, hgt;
326  efg[GEO_E] = e;
327  efg[GEO_F] = f;
328  efg[GEO_G] = g;
329 
330  geoEfg2Llh_torge (datum,efg,&lat,&lon,&hgt);
331  return(hgt);
332 }

Here is the call graph for this function:

double geoEfg2Hgt_torge_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 236 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_torge_fast().

237 {
238  double efg[3];
239  double lat, lon, hgt;
240  efg[GEO_E] = e;
241  efg[GEO_F] = f;
242  efg[GEO_G] = g;
243 
244  geoEfg2Llh_torge_fast (datum,efg,&lat,&lon,&hgt);
245  return(hgt);
246 }

Here is the call graph for this function:

double geoEfg2Hgt_torge_its ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 334 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_torge(), and geoEfg2LlhGetIts().

335 {
336  double efg[3];
337  double lat, lon, hgt;
338  efg[GEO_E] = e;
339  efg[GEO_F] = f;
340  efg[GEO_G] = g;
341 
342  geoEfg2Llh_torge (datum,efg,&lat,&lon,&hgt);
343 
344  return((double)geoEfg2LlhGetIts());
345 }

Here is the call graph for this function:

double geoEfg2Hgt_vermeille ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 730 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_vermeille().

731 {
732  double efg[3];
733  double lat, lon, hgt;
734  efg[GEO_E] = e;
735  efg[GEO_F] = f;
736  efg[GEO_G] = g;
737 
738  geoEfg2Llh_vermeille (datum,efg,&lat,&lon,&hgt);
739  return(hgt);
740 }

Here is the call graph for this function:

double geoEfg2Hgt_vermeille_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 576 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, and geoEfg2Llh_vermeille_fast().

577 {
578  double efg[3];
579  double lat, lon, hgt;
580  efg[GEO_E] = e;
581  efg[GEO_F] = f;
582  efg[GEO_G] = g;
583 
584  geoEfg2Llh_vermeille_fast (datum,efg,&lat,&lon,&hgt);
585  return(hgt);
586 }

Here is the call graph for this function:

double geoEfg2Lat ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 102 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh(), and RAD_TO_DEG.

103 {
104  double efg[3];
105  double lat, lon, hgt;
106  efg[GEO_E] = e;
107  efg[GEO_F] = f;
108  efg[GEO_G] = g;
109 
110  geoEfg2Llh (datum,efg,&lat,&lon,&hgt);
111  return(RAD_TO_DEG * lat);
112 }

Here is the call graph for this function:

double geoEfg2Lat_aa ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 508 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_aa(), and RAD_TO_DEG.

509 {
510  double efg[3];
511  double lat, lon, hgt;
512  efg[GEO_E] = e;
513  efg[GEO_F] = f;
514  efg[GEO_G] = g;
515 
516  geoEfg2Llh_aa (datum,efg,&lat,&lon,&hgt);
517  return(RAD_TO_DEG * lat);
518 }

Here is the call graph for this function:

double geoEfg2Lat_aa_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 369 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_aa_fast(), and RAD_TO_DEG.

370 {
371  double efg[3];
372  double lat, lon, hgt;
373  efg[GEO_E] = e;
374  efg[GEO_F] = f;
375  efg[GEO_G] = g;
376 
377  geoEfg2Llh_aa_fast (datum,efg,&lat,&lon,&hgt);
378  return(RAD_TO_DEG * lat);
379 }

Here is the call graph for this function:

double geoEfg2Lat_borkowski ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 615 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_borkowski(), and RAD_TO_DEG.

616 {
617  double efg[3];
618  double lat, lon, hgt;
619  efg[GEO_E] = e;
620  efg[GEO_F] = f;
621  efg[GEO_G] = g;
622 
623  geoEfg2Llh_borkowski (datum,efg,&lat,&lon,&hgt);
624  return(RAD_TO_DEG * lat);
625 }

Here is the call graph for this function:

double geoEfg2Lat_borkowski_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 466 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_borkowski_fast(), and RAD_TO_DEG.

467 {
468  double efg[3];
469  double lat, lon, hgt;
470  efg[GEO_E] = e;
471  efg[GEO_F] = f;
472  efg[GEO_G] = g;
473 
474  geoEfg2Llh_borkowski_fast (datum,efg,&lat,&lon,&hgt);
475  return(RAD_TO_DEG * lat);
476 }

Here is the call graph for this function:

double geoEfg2Lat_bowring ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 406 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_bowring(), and RAD_TO_DEG.

407 {
408  double efg[3];
409  double lat, lon, hgt;
410  efg[GEO_E] = e;
411  efg[GEO_F] = f;
412  efg[GEO_G] = g;
413 
414  geoEfg2Llh_bowring (datum,efg,&lat,&lon,&hgt);
415  return(RAD_TO_DEG * lat);
416 }

Here is the call graph for this function:

double geoEfg2Lat_bowring_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 295 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_bowring_fast(), and RAD_TO_DEG.

296 {
297  double efg[3];
298  double lat, lon, hgt;
299  efg[GEO_E] = e;
300  efg[GEO_F] = f;
301  efg[GEO_G] = g;
302 
303  geoEfg2Llh_bowring_fast (datum,efg,&lat,&lon,&hgt);
304  return(RAD_TO_DEG * lat);
305 }

Here is the call graph for this function:

double geoEfg2Lat_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 65 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_fast(), and RAD_TO_DEG.

66 {
67  double efg[3];
68  double lat, lon, hgt;
69  efg[GEO_E] = e;
70  efg[GEO_F] = f;
71  efg[GEO_G] = g;
72 
73  geoEfg2Llh_fast (datum,efg,&lat,&lon,&hgt);
74  return(RAD_TO_DEG * lat);
75 }

Here is the call graph for this function:

double geoEfg2Lat_heikkinen ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 808 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_heikkinen(), and RAD_TO_DEG.

809 {
810  double efg[3];
811  double lat, lon, hgt;
812  efg[GEO_E] = e;
813  efg[GEO_F] = f;
814  efg[GEO_G] = g;
815 
816  geoEfg2Llh_heikkinen (datum,efg,&lat,&lon,&hgt);
817  return(RAD_TO_DEG * lat);
818 }

Here is the call graph for this function:

double geoEfg2Lat_hm ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 190 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_hm(), and RAD_TO_DEG.

191 {
192  double efg[3];
193  double lat, lon, hgt;
194  efg[GEO_E] = e;
195  efg[GEO_F] = f;
196  efg[GEO_G] = g;
197 
198  geoEfg2Llh_hm (datum,efg,&lat,&lon,&hgt);
199  return(RAD_TO_DEG * lat);
200 }

Here is the call graph for this function:

double geoEfg2Lat_hm_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 137 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_hm_fast(), and RAD_TO_DEG.

138 {
139  double efg[3];
140  double lat, lon, hgt;
141  efg[GEO_E] = e;
142  efg[GEO_F] = f;
143  efg[GEO_G] = g;
144 
145  geoEfg2Llh_hm_fast (datum,efg,&lat,&lon,&hgt);
146  return(RAD_TO_DEG * lat);
147 }

Here is the call graph for this function:

double geoEfg2Lat_toms ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 907 of file geoEfg2Llh.c.

References geoEfg2Llh_toms(), and RAD_TO_DEG.

908 {
909  double lat, lon, hgt;
910  double efg[] = {e,f,g};
911 // efg[GEO_E] = e;
912 // efg[GEO_F] = f;
913 // efg[GEO_G] = g;
914 
915  geoEfg2Llh_toms (datum,efg,&lat,&lon,&hgt);
916  return(RAD_TO_DEG * lat);
917 }

Here is the call graph for this function:

double geoEfg2Lat_torge ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 299 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_torge(), and RAD_TO_DEG.

300 {
301  double efg[3];
302  double lat, lon, hgt;
303  efg[GEO_E] = e;
304  efg[GEO_F] = f;
305  efg[GEO_G] = g;
306 
307  geoEfg2Llh_torge (datum,efg,&lat,&lon,&hgt);
308  return(RAD_TO_DEG * lat);
309 }

Here is the call graph for this function:

double geoEfg2Lat_torge_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 213 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_torge_fast(), and RAD_TO_DEG.

214 {
215  double efg[3];
216  double lat, lon, hgt;
217  efg[GEO_E] = e;
218  efg[GEO_F] = f;
219  efg[GEO_G] = g;
220 
221  geoEfg2Llh_torge_fast (datum,efg,&lat,&lon,&hgt);
222  return(RAD_TO_DEG * lat);
223 }

Here is the call graph for this function:

double geoEfg2Lat_vermeille ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 707 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_vermeille(), and RAD_TO_DEG.

708 {
709  double efg[3];
710  double lat, lon, hgt;
711  efg[GEO_E] = e;
712  efg[GEO_F] = f;
713  efg[GEO_G] = g;
714 
715  geoEfg2Llh_vermeille (datum,efg,&lat,&lon,&hgt);
716  return(RAD_TO_DEG * lat);
717 }

Here is the call graph for this function:

double geoEfg2Lat_vermeille_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 553 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_vermeille_fast(), and RAD_TO_DEG.

554 {
555  double efg[3];
556  double lat, lon, hgt;
557  efg[GEO_E] = e;
558  efg[GEO_F] = f;
559  efg[GEO_G] = g;
560 
561  geoEfg2Llh_vermeille_fast (datum,efg,&lat,&lon,&hgt);
562  return(RAD_TO_DEG * lat);
563 }

Here is the call graph for this function:

void geoEfg2Llh ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This routine will be exact only for WGS84 coordinates. All other datums will be slightly off.

Definition at line 72 of file geoEfg2Llh.c.

References cube, GEO_E, GEO_F, GEO_G, geoGetEllipsoid(), its, p, and sqr.

Referenced by geoEfg2Hgt(), geoEfg2Lat(), and geoEfg2Lon().

74 {
75  double p, u, u_prime, a, flat, b, e2, ee2,sign = 1.0,cu_prime,su,cu,t1;
76 
77  /* Get the ellipsoid parameters */
78  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
79  its=0;
80 
81  // Computes EFG to lat, lon & height
82  p = sqrt(sqr(efg[GEO_E]) + sqr(efg[GEO_F]));
83  u = atan((efg[GEO_G]/p) * (a/b));
84  // u = atan2(efg[GEO_G] * a , p * b);
85  su = sin(u);
86  cu = cos(u);
87 
88  *lat = atan((efg[GEO_G] + ee2 * b * cube(su) ) /
89  ( p - e2 * a * cube(cu) ) );
90 
91  u_prime = atan((1.0 - flat) * tan(*lat));
92  cu_prime = p - a * cos(u_prime);
93  if(cu_prime < 0.0) sign= -1.0; // determine sign
94 
95  // *hgt = p / cos(*lat) - ( a / (sqrt(1.0 - e2 * pow(sin(*lat),2.0)))); //same results
96  t1 = efg[GEO_G] - b * sin(u_prime);
97  *hgt = sign * sqrt( sqr(cu_prime) + sqr(t1) );
98  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
99 
100 }

Here is the call graph for this function:

void geoEfg2Llh_aa ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Astronomical Almanac 2002 Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation from Astronomical Almanac 2002 K11-12

Definition at line 468 of file geoEfg2Llh.c.

References GEO_E, GEO_EFG2LLH_MAX_ITS, GEO_F, GEO_G, geoAccuracy, geoGetEllipsoid(), its, n(), p, and sqr.

Referenced by geoEfg2Hgt_aa(), geoEfg2Hgt_aa_its(), geoEfg2Lat_aa(), and geoEfg2Lon_aa().

470 {
471  double phi,p,n=1.0,phi1;
472  int i;
473 
474  double a, flat, b, e2, ee2;
475  double slat;
476 
477  /* Get the ellipsoid parameters */
478  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
479 
480  // Computes EFG to lat, lon & height
481  // from the Astronomical Almanac 2002 - K11-12
482  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
483  p = sqrt(sqr(efg[GEO_E]) + sqr(efg[GEO_F]));
484 
485  phi = atan(efg[GEO_G]/p); // first approximation
486  // phi = atan(efg[GEO_G]/((1.0-e2)*p)); // faster
487 
488  its=0;
489 
490  // compute until the error in phi is no more
491  for(i=0;i<GEO_EFG2LLH_MAX_ITS;i++)
492  {
493  its++;
494  phi1 = phi;
495  slat = sin(phi1);
496  // c = 1.0/sqrt(1.0 - e2 * sqr(slat));
497  // phi = atan((efg[GEO_G] + a * c * e2 * slat)/r);
498  n = a/sqrt(1.0 - e2 * sqr(slat));
499  phi = atan((efg[GEO_G] + n * e2 * slat)/p);
500  if( fabs(phi1-phi) <= geoAccuracy) break;
501  }
502  *lat = phi;
503  // *hgt = r / cos(phi) - a * c;
504  *hgt = p / cos(phi) - n;
505 
506 }

Here is the call graph for this function:

void geoEfg2Llh_aa_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Astronomical Almanac 2002 Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation from Astronomical Almanac 2002 K11-12

Definition at line 347 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_e2, n(), p, and sqr.

Referenced by geoEfg2Hgt_aa_fast(), geoEfg2Lat_aa_fast(), and geoEfg2Lon_aa_fast().

349 {
350  double phi,p,n;
351  double slat;
352 
353  // Computes EFG to lat, lon & height
354  // from the Astronomical Almanac 2002 - K11-12
355  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
356  p = sqrt(sqr(efg[GEO_E]) + sqr(efg[GEO_F]));
357 
358  // phi = atan(efg[GEO_G]/p); // first approximation
359  phi = atan(efg[GEO_G]/((1.0-GEO_WGS84_e2)*p)); // faster
360 
361  slat = sin(phi);
362  n = GEO_WGS84_a/sqrt(1.0 - GEO_WGS84_e2 * sqr(slat));
363  *lat = atan((efg[GEO_G] + n * GEO_WGS84_e2 * slat)/p);
364 
365  *hgt = p / cos(*lat) - n;
366 
367 }

Here is the call graph for this function:

void geoEfg2Llh_borkowski ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Borkowski Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is closed exact method from Bull. Geod., 63 (1989), pp. 50-56

Definition at line 571 of file geoEfg2Llh.c.

References cube, GEO_E, GEO_F, GEO_G, geoGetEllipsoid(), its, p, and sqr.

Referenced by geoEfg2Hgt_borkowski(), geoEfg2Lat_borkowski(), and geoEfg2Lon_borkowski().

573 {
574  double a, flat, b, e2, ee2;
575  double r,e,f,p,q,d,v,g,t,sign,bg,samb,sqrtd,sqre;
576 
577 
578  /* Get the ellipsoid parameters */
579  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
580  its=0;
581 
582  // Computes EFG to lat, lon & height
583  // from Bull. Geod., 63 (1989), pp. 50-56
584  // Accurate Algorithms to Transform Geocentric to Geodetic Coordinates
585  // By K.M. Borkowski
586 
587  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
588 
589  //use the sign for Z
590  if(efg[GEO_G] < 0.0) sign = -1.0;
591  else sign = 1.0;
592  b = fabs(b) * sign;
593  bg = b * efg[GEO_G]; //temp
594  samb = sqr(a)-sqr(b) ;//temp
595  r = efg[GEO_E] / cos(*lon);
596  e = (bg - samb) / (a*r);
597  sqre = sqr(e);
598  f = (bg + samb) / (a*r);
599  p = 4.0/3.0*(e*f+1.0);
600  q = 2.0 * (sqre-sqr(f));
601  d = cube(p) + sqr(q);
602  sqrtd = sqrt(d);
603  if(d < 0.0)
604  v = 2.0 * sqrt(-p) * cos(acos(q/pow(-p,3.0/2.0))/3.0);
605  else
606  v = pow((sqrtd - q),1.0/3.0) - pow((sqrtd + q),1.0/3.0);
607  g = (sqrt(sqre+v) + e ) / 2.0;
608  t = sqrt(sqr(g)+((f-v*g)/(2.0*g-e))) - g;
609  *lat = atan(a*(1.0-sqr(t))/(2.0*b*t));
610 
611  *hgt = (r - a*t) * cos(*lat) + (efg[GEO_G]-b)*sin(*lat);
612 
613 }

Here is the call graph for this function:

void geoEfg2Llh_borkowski_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Borkowski Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is closed exact method from Bull. Geod., 63 (1989), pp. 50-56

Definition at line 420 of file geoEfg2Llh_fast.c.

References cube, GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_b, p, and sqr.

Referenced by geoEfg2Hgt_borkowski_fast(), geoEfg2Lat_borkowski_fast(), and geoEfg2Lon_borkowski_fast().

422 {
423  double a,b,r,e,f,p,q,d,v,g,t,sign,bg,samb,sqrtd,sqre,ar;
424  //double e2;
425 
426  /* Get the ellipsoid parameters */
427  // geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
428  a=GEO_WGS84_a;
429  // b=GEO_WGS84_b;
430  // e2=GEO_WGS84_e2;
431 
432  // Computes EFG to lat, lon & height
433  // from Bull. Geod., 63 (1989), pp. 50-56
434  // Accurate Algorithms to Transform Geocentric to Geodetic Coordinates
435  // By K.M. Borkowski
436 
437  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
438 
439  //use the sign for Z
440  if(efg[GEO_G] < 0.0) sign = -1.0;
441  else sign = 1.0;
442  b = GEO_WGS84_b * sign;
443  bg = b * efg[GEO_G]; //temp
444  samb = sqr(a)-sqr(b) ;//temp
445  r = efg[GEO_E] / cos(*lon);
446  ar = a*r;
447  e = (bg - samb) / ar;
448  sqre = sqr(e);
449  f = (bg + samb) / ar;
450  p = 4.0/3.0*(e*f+1.0);
451  q = 2.0 * (sqre-sqr(f));
452  d = cube(p) + sqr(q);
453  sqrtd = sqrt(d);
454  if(d < 0.0)
455  v = 2.0 * sqrt(-p) * cos(acos(q/pow(-p,3.0/2.0))/3.0);
456  else
457  v = pow((sqrtd - q),1.0/3.0) - pow((sqrtd + q),1.0/3.0);
458  g = (sqrt(sqre+v) + e ) / 2.0;
459  t = sqrt(sqr(g)+((f-v*g)/(2.0*g-e))) - g;
460  *lat = atan(a*(1.0-sqr(t))/(2.0*b*t));
461 
462  *hgt = (r - a*t) * cos(*lat) + (efg[GEO_G]-b)*sin(*lat);
463 
464 }
void geoEfg2Llh_bowring ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Bowring Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 362 of file geoEfg2Llh.c.

References cube, GEO_E, GEO_EFG2LLH_MAX_ITS, GEO_F, GEO_G, geoAccuracy, geoGetEllipsoid(), its, n(), p, and sqr.

Referenced by geoEfg2Hgt_bowring(), geoEfg2Hgt_bowring_its(), geoEfg2Lat_bowring(), and geoEfg2Lon_bowring().

364 {
365  double a, flat, b, e2, ee2;
366  double tmp,n,b0,b1,p,slat,clat,ee2b,ae2,boa;
367  // int done=1;
368  int i;
369 
370  /* Get the ellipsoid parameters */
371  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
372  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
373  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
374  tmp = efg[GEO_G] / p;
375  its=0;
376 
377  // temps pulled out of the loop
378  ae2 = a * e2;
379  ee2b = ee2 * b;
380  boa = b/a;
381 
382  // Prepare the initial value of lat
383  b0 = atan((a/b)*tmp);
384 
385  // iterate until delta lat is tiny
386  for(i=0;i<GEO_EFG2LLH_MAX_ITS;i++)
387  {
388  its++;
389  b1=b0;
390  slat = sin(b1);
391  clat = cos(b1);
392  *lat = atan((efg[GEO_G]+ ee2b * cube(slat) ) /
393  (p - ae2 * cube(clat) ) );
394  b0 = atan((boa) * tan(*lat));
395  if(fabs(b0-b1) <= geoAccuracy) break;
396  // if(fabs(b1-b0)== 0.0) break;
397  // if(b1-b0== 0.0) break;
398  }
399  slat = sin(*lat);
400  n= a/sqrt(1.0-e2*sqr(slat));
401 
402  *hgt = (p / cos(*lat)) - n;
403 
404 }

Here is the call graph for this function:

void geoEfg2Llh_bowring_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Bowring Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 264 of file geoEfg2Llh_fast.c.

References cube, GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_b, GEO_WGS84_e2, GEO_WGS84_ee2, n(), p, and sqr.

Referenced by geoEfg2Hgt_bowring_fast(), geoEfg2Lat_bowring_fast(), and geoEfg2Lon_bowring_fast().

266 {
267  double tmp,n,b0,p,slat,clat,ee2b,ae2;
268  //double boa;
269 
270  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
271  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
272  tmp = efg[GEO_G] / p;
273 
274  // temps pulled out of the loop
275  ae2 = GEO_WGS84_a * GEO_WGS84_e2;
276  ee2b = GEO_WGS84_ee2 * GEO_WGS84_b;
277  //boa = GEO_WGS84_b/GEO_WGS84_a;
278 
279  // Prepare the initial value of lat
280  b0 = atan((GEO_WGS84_a/GEO_WGS84_b)*tmp);
281 
282  // iterate until delta lat is tiny
283  slat = sin(b0);
284  clat = cos(b0);
285  *lat = atan((efg[GEO_G]+ ee2b * cube(slat) ) /
286  (p - ae2 * cube(clat) ) );
287  // b0 = atan((boa) * tan(*lat));
288  slat = sin(*lat);
289  n= GEO_WGS84_a / sqrt(1.0-GEO_WGS84_e2*sqr(slat));
290 
291  *hgt = (p / cos(*lat)) - n;
292 
293 }

Here is the call graph for this function:

void geoEfg2Llh_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This routine will be exact only for WGS84 coordinates. All other datums will be slightly off.

Definition at line 40 of file geoEfg2Llh_fast.c.

References cube, GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_b, GEO_WGS84_e2, GEO_WGS84_ee2, p, and sqr.

Referenced by geoEfg2Hgt_fast(), geoEfg2Lat_fast(), and geoEfg2Lon_fast().

42 {
43  double p, u, su,cu,bee2,ae2,aob,slat;
44 
45  bee2 = GEO_WGS84_ee2 * GEO_WGS84_b;
46  ae2 = GEO_WGS84_e2 * GEO_WGS84_a;
47  aob = GEO_WGS84_a / GEO_WGS84_b;
48 
49  // Computes EFG to lat, lon & height
50  p = sqrt(sqr(efg[GEO_E]) + sqr(efg[GEO_F]));
51  u = atan((efg[GEO_G]/p) * aob);
52 
53  su = sin(u);
54  cu = cos(u);
55 
56  *lat = atan((efg[GEO_G] + bee2 * cube(su) ) /
57  ( p - ae2 * cube(cu) ) );
58  slat = sin(*lat);
59 
60  *hgt = p / cos(*lat) - ( GEO_WGS84_a / (sqrt(1.0 - GEO_WGS84_e2 * sqr(slat)))); //same results
61  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
62 
63 }
void geoEfg2Llh_fast_packed ( const GEO_DATUM datum,
int  count,
double  efg_llh[] 
)
void geoEfg2Llh_fast_packed2 ( const GEO_DATUM datum,
int  count,
double  efg_in[],
double  llh_out[] 
)
void geoEfg2Llh_heikkinen ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

heikkinen Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is closed exact method from ....

Definition at line 758 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoGetEllipsoid(), its, p, sp, and sqr.

Referenced by geoEfg2Hgt_heikkinen(), geoEfg2Lat_heikkinen(), and geoEfg2Lon_heikkinen().

760 {
761  double a, flat, b, e2, ee2;
762  double a2,b2,x2,y2,z2,d,d2,e4,m1e2,m1e2z2,
763  W,W2,F,G,p,q,q1,s,sp,W0,wew0,U,V,Z0;
764 
765 
766  /* Get the ellipsoid parameters */
767  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
768  its=0;
769 
770  // precompute variables
771  x2 = sqr(efg[GEO_E]);
772  y2 = sqr(efg[GEO_F]);
773  z2 = sqr(efg[GEO_G]);
774  a2 = sqr(a);
775  b2 = sqr(b);
776  e4 = sqr(e2);
777  m1e2 = 1.0 - e2;
778  m1e2z2 = m1e2*z2;
779 
780  // main algorithm
781  W = sqrt(x2+y2);
782  W2= W*W;
783 
784  F = 54.0*b2*z2;
785 
786  G = W2 + m1e2z2 - e2*(a2-b2);
787  d = e4*F*W2/(G*G*G);
788  d2=d*d;
789 
790  s = pow(1.0+d+sqrt(d2+2*d),1.0/3.0);
791  sp=s+1.0/s+1.0;
792  p = F/(3.0*sqr(sp)*G*G);
793  q = sqrt(1.0+2.0*e4*p);
794  q1 = q+1.0;
795 
796  W0= (-p*e2*W / q1) + sqrt(0.5*a2*(1.0+1.0/q)-(p*m1e2z2/(q*q1))-(p*W2/2.0));
797  wew0 = W-e2*W0;
798  U = sqrt(sqr(wew0)+z2);
799  V = sqrt(sqr(wew0)+m1e2z2);
800  Z0= b2*efg[GEO_G]/(a*V);
801  *hgt = U*(1.0-(b2/(a*V)));
802  *lat = atan2((efg[GEO_G]+ee2*Z0),W);
803  *lon = atan2(efg[GEO_F],efg[GEO_E]);
804 
805 
806 }

Here is the call graph for this function:

void geoEfg2Llh_hm ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Hirvonen & Moritz Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 153 of file geoEfg2Llh.c.

References GEO_E, GEO_EFG2LLH_MAX_ITS, GEO_F, GEO_G, geoAccuracy, geoGetEllipsoid(), its, n(), p, and sqr.

Referenced by geoEfg2Hgt_hm(), geoEfg2Hgt_hm_its(), geoEfg2Lat_hm(), and geoEfg2Lon_hm().

155 {
156  double a, flat, b, e2, ee2;
157  double lat1,tmp,n=0.0,delta,p,slat;
158  // int done=1;
159  int i;
160 
161  if(efg[GEO_G] == 0.0) efg[GEO_G] = 0.00000001; //cheat to avoid bad numbers
162 
163  /* Get the ellipsoid parameters */
164  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
165  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
166  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
167  its=0;
168 
169  // Prepare the initial value of lat
170  tmp = efg[GEO_G] / p;
171  lat1 = atan((1.0 / (1.0 - e2))*tmp);
172  *lat=lat1;
173 
174  // iterate until delta lat is tiny
175  for(i=0;i<GEO_EFG2LLH_MAX_ITS;i++)
176  {
177  its++;
178  slat = sin(lat1);
179  n= a/sqrt(1.0 - e2 * sqr(slat));
180  *lat=atan(tmp*(1.0 + (e2*n*slat)/efg[GEO_G]));
181  delta = *lat - lat1;
182  if(fabs(delta) <= geoAccuracy) break;
183  // if(fabs(delta) == 0.0) break;
184  lat1=*lat;
185  }
186  *hgt = (p / cos(*lat)) - n;
187 
188 }

Here is the call graph for this function:

void geoEfg2Llh_hm_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Hirvonen & Moritz Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 116 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_e2, n(), p, and sqr.

Referenced by geoEfg2Hgt_hm_fast(), geoEfg2Lat_hm_fast(), and geoEfg2Lon_hm_fast().

118 {
119  // double a, flat, b, e2, ee2;
120  double tmp,n,p,slat;
121 
122  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
123  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
124 
125  // Prepare the initial value of lat
126  tmp = efg[GEO_G] / p;
127  *lat = atan((1.0 / (1.0 - GEO_WGS84_e2))*tmp);
128 
129  slat = sin(*lat);
130  n= GEO_WGS84_a/sqrt(1.0 - GEO_WGS84_e2 * sqr(slat));
131  // *lat=atan(tmp*(1.0 + (e2*n*slat)/efg[GEO_G]));
132  // lat1=*lat;
133  *hgt = (p / cos(*lat)) - n;
134 
135 }

Here is the call graph for this function:

void geoEfg2Llh_packed ( const GEO_DATUM datum,
int  count,
double  efg_llh[] 
)
void geoEfg2Llh_toms ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Definition at line 860 of file geoEfg2Llh.c.

References aDc, cube, GEO_E, GEO_F, GEO_G, geoGetEllipsoid(), its, n(), and sqr.

Referenced by geoEfg2Hgt_toms(), geoEfg2Lat_toms(), and geoEfg2Lon_toms().

862 {
863  double a, flat, b, e2, ee2;
864  double x2,y2,W,W2,t0,s0,sbo,cbo,t1,wae,s1,sin1,cos1,n;
865 
866 
867  /* Get the ellipsoid parameters */
868  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
869  its=0;
870 
871  // precompute variables
872  x2 = sqr(efg[GEO_E]);
873  y2 = sqr(efg[GEO_F]);
874  // z2 = sqr(efg[GEO_G]);
875 
876  // main algorithm
877  W = sqrt(x2+y2);
878  W2= W*W;
879 
880  t0 = efg[GEO_G] * aDc;
881  s0 = sqrt(sqr(t0)+W2);
882  sbo= t0/s0;
883  cbo= W/s0;
884 
885  t1= efg[GEO_G] + b * ee2 * cube(sbo);
886  wae = W - a * e2 * cube(cbo);
887  s1 = sqrt(sqr(t1) + sqr(wae));
888  sin1 = t1/s1;
889  cos1 = wae/s1;
890  n = a/sqrt(1.0-e2*sqr(sin1));
891  if(sin1 >= 0.3826834323650897717284599840304)
892  {
893  sin1 = sqrt(sqr(sin1));
894  *hgt = efg[GEO_G]/sin1 + n*(e2-1.0);
895  }
896  else
897  {
898  *hgt = W/cos1 - n;
899  }
900 
901  *lat = atan2(sin1,cos1);
902  *lon = atan2(efg[GEO_F],efg[GEO_E]);
903 
904 
905 }

Here is the call graph for this function:

void geoEfg2Llh_torge ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Torge Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 253 of file geoEfg2Llh.c.

References GEO_E, GEO_EFG2LLH_MAX_ITS, GEO_F, GEO_G, geoAccuracy, geoGetEllipsoid(), its, n(), p, and sqr.

Referenced by geoEfg2Hgt_torge(), geoEfg2Hgt_torge_its(), geoEfg2Lat_torge(), and geoEfg2Lon_torge().

255 {
256  double a, flat, b, e2, ee2;
257  double lat1,hgt1,tmp,n=0.0,deltal,deltah,p,slat;
258  //,clat;
259  // int done=1;
260  int i;
261 
262  /* Get the ellipsoid parameters */
263  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
264  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
265  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
266  its=0;
267 
268  // Prepare the initial value of lat
269  tmp = efg[GEO_G] / p;
270  // lat1 = atan(tmp/(1.0 - e2)); //assume hgt = 0 to start
271  lat1 = atan(tmp); //assume hgt = 0 to start
272  *lat=lat1;
273  *hgt=0.0;
274 
275 
276  // iterate until delta lat is tiny
277  for(i=0;i<GEO_EFG2LLH_MAX_ITS;i++)
278  {
279  its++;
280  lat1=*lat;
281  hgt1 = *hgt;
282 
283  slat = sin(lat1);
284  //clat = cos(lat1);
285 
286  // radius of curvature estimate
287  n= a/sqrt(1.0 - e2 * sqr(slat));
288 
289  // Next: estimates of lat/hgt
290  *lat=atan2(tmp , (1.0 - (e2 * ( n / (n + *hgt)) ) ) );
291  *hgt = (p / cos(*lat)) - n;
292  deltal = *lat - lat1;
293  deltah = *hgt - hgt1;
294  if((fabs(deltah) <= .00001) && (fabs(deltal) <= geoAccuracy)) break;
295  }
296 
297 }

Here is the call graph for this function:

void geoEfg2Llh_torge_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Torge Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is a successive approximation

Definition at line 188 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_e2, n(), p, and sqr.

Referenced by geoEfg2Hgt_torge_fast(), geoEfg2Lat_torge_fast(), and geoEfg2Lon_torge_fast().

190 {
191  double tmp,n,p,slat;
192 
193  p = sqrt(sqr(efg[GEO_E])+ sqr(efg[GEO_F]));
194  *lon = atan2(efg[GEO_F],efg[GEO_E]); // atan(f/e)
195 
196  // Prepare the initial value of lat
197  tmp = efg[GEO_G] / p;
198  *lat = atan(tmp/(1.0 - GEO_WGS84_e2)); //assume hgt = 0 to start
199 
200 
201  slat = sin(*lat);
202  //clat = cos(*lat);
203 
204  // radius of curvature estimate
205  n= GEO_WGS84_a/sqrt(1.0 - GEO_WGS84_e2 * sqr(slat));
206 
207  // Next estimates of lat/hgt
208  *hgt = (p / cos(*lat)) - n;
209  *lat=atan(tmp / (1.0 - (GEO_WGS84_e2 * ( n / (n + *hgt)) ) ) );
210 
211 }

Here is the call graph for this function:

void geoEfg2Llh_vermeille ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Vermeille Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is closed exact method from ....

Definition at line 666 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoGetEllipsoid(), its, k, p, and sqr.

Referenced by geoEfg2Hgt_vermeille(), geoEfg2Lat_vermeille(), and geoEfg2Lon_vermeille().

668 {
669  double a, flat, b, e2, ee2;
670  double a2,x2,y2,z2,d2,e4,p,q,r,s,t,u,v,w,k,d,sqrtx2py2,sqrtd2pz2;
671 
672 
673  /* Get the ellipsoid parameters */
674  geoGetEllipsoid (&a, &b, &e2, &ee2, &flat, datum);
675  its=0;
676 
677  // precompute variables
678  x2 = sqr(efg[GEO_E]);
679  y2 = sqr(efg[GEO_F]);
680  z2 = sqr(efg[GEO_G]);
681  a2 = sqr(a);
682  e4 = sqr(e2);
683  sqrtx2py2 = sqrt(x2+y2);
684 
685  // main algorithm
686  p = (x2 + y2)/ a2;
687  q = ((1.0-e2)/ a2)*z2;
688  r = (p+q-e4)/6.0;
689  s = e4 * (p*q)/(4.0*pow(r,3.0));
690  t = pow(1.0+s+sqrt(s*(2.0+s)),1.0/3.0);
691  u = r*(1.0+t+(1.0/t));
692  v = sqrt(sqr(u)+e4*q);
693  w = e2*(u+v-q)/(2.0*v);
694  k = sqrt(u+v+sqr(w)) - w;
695  d = k*sqrtx2py2/(k+e2);
696  d2 = sqr(d);
697  sqrtd2pz2 = sqrt(d2+z2);
698 
699  *lon = 2 * atan(efg[GEO_F]/(efg[GEO_E] + sqrtx2py2));
700 
701  *lat = 2 * atan(efg[GEO_G]/(d + sqrtd2pz2));
702 
703  *hgt = ((k + e2 - 1.0) / k) * sqrtd2pz2;
704 
705 }

Here is the call graph for this function:

void geoEfg2Llh_vermeille_fast ( int  datum,
double  efg[],
double *  lat,
double *  lon,
double *  hgt 
)

Vermeille Method - This routine will convert earth centered Cartesian coordinates (E,F,G), into geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$).

Parameters
intdatum
doubleefg[] : EFG(xyz) in METERS
double*lat : Latitude in RADIANS
double*lon : Longitude in RADIANS
double*hgt : Height in METERS
Returns
nothing
Note
This method is closed exact method from ....

Definition at line 517 of file geoEfg2Llh_fast.c.

References cube, GEO_E, GEO_F, GEO_G, GEO_WGS84_a, GEO_WGS84_e2, k, p, and sqr.

Referenced by geoEfg2Hgt_vermeille_fast(), geoEfg2Lat_vermeille_fast(), and geoEfg2Lon_vermeille_fast().

519 {
520  double fr,a2,x2,y2,z2,d2,e4,p,q,r,s,t,u,v,w,k,d,sqrtx2py2,sqrtd2pz2;
521 
522 
523 
524  // precompute variables
525  x2 = sqr(efg[GEO_E]);
526  y2 = sqr(efg[GEO_F]);
527  z2 = sqr(efg[GEO_G]);
528  a2 = sqr(GEO_WGS84_a);
529  e4 = sqr(GEO_WGS84_e2);
530  sqrtx2py2 = sqrt(x2+y2);
531  fr = (1.0-GEO_WGS84_e2)/(sqr(GEO_WGS84_a));
532 
533  // main algorithm
534  p = (x2 + y2)/ a2;
535  q = fr*z2;
536  r = (p+q-e4)/6.0;
537  s = e4 * (p*q)/(4.0*cube(r));
538  t = pow(1.0+s+sqrt(s*(2.0+s)),1.0/3.0);
539  u = r*(1.0+t+(1.0/t));
540  v = sqrt(sqr(u)+e4*q);
541  w = GEO_WGS84_e2*(u+v-q)/(2.0*v);
542  k = sqrt(u+v+sqr(w)) - w;
543  d = k*sqrtx2py2/(k+GEO_WGS84_e2);
544  d2 = sqr(d);
545  sqrtd2pz2 = sqrt(d2+z2);
546 
547  *lon = 2.0 * atan(efg[GEO_F]/(efg[GEO_E] + sqrtx2py2));
548  *lat = 2.0 * atan(efg[GEO_G]/(d + sqrtd2pz2));
549  *hgt = ((k + GEO_WGS84_e2 - 1.0) / k) * sqrtd2pz2;
550 
551 }
int geoEfg2LlhGetIts ( void  )

Definition at line 25 of file geoEfg2Llh.c.

References its.

Referenced by geoEfg2Hgt_aa_its(), geoEfg2Hgt_bowring_its(), geoEfg2Hgt_hm_its(), and geoEfg2Hgt_torge_its().

26 {
27  return(its);
28 }
double geoEfg2Lon ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 114 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh(), and RAD_TO_DEG.

115 {
116  double efg[3];
117  double lat, lon, hgt;
118  efg[GEO_E] = e;
119  efg[GEO_F] = f;
120  efg[GEO_G] = g;
121 
122  geoEfg2Llh (datum,efg,&lat,&lon,&hgt);
123  return(RAD_TO_DEG * lon);
124 }

Here is the call graph for this function:

double geoEfg2Lon_aa ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 520 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_aa(), and RAD_TO_DEG.

521 {
522  double efg[3];
523  double lat, lon, hgt;
524  efg[GEO_E] = e;
525  efg[GEO_F] = f;
526  efg[GEO_G] = g;
527 
528  geoEfg2Llh_aa (datum,efg,&lat,&lon,&hgt);
529  return(RAD_TO_DEG * lon);
530 }

Here is the call graph for this function:

double geoEfg2Lon_aa_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 381 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_aa_fast(), and RAD_TO_DEG.

382 {
383  double efg[3];
384  double lat, lon, hgt;
385  efg[GEO_E] = e;
386  efg[GEO_F] = f;
387  efg[GEO_G] = g;
388 
389  geoEfg2Llh_aa_fast (datum,efg,&lat,&lon,&hgt);
390  return(RAD_TO_DEG * lon);
391 }

Here is the call graph for this function:

double geoEfg2Lon_borkowski ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 627 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_borkowski(), and RAD_TO_DEG.

628 {
629  double efg[3];
630  double lat, lon, hgt;
631  efg[GEO_E] = e;
632  efg[GEO_F] = f;
633  efg[GEO_G] = g;
634 
635  geoEfg2Llh_borkowski (datum,efg,&lat,&lon,&hgt);
636  return(RAD_TO_DEG * lon);
637 }

Here is the call graph for this function:

double geoEfg2Lon_borkowski_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 478 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_borkowski_fast(), and RAD_TO_DEG.

479 {
480  double efg[3];
481  double lat, lon, hgt;
482  efg[GEO_E] = e;
483  efg[GEO_F] = f;
484  efg[GEO_G] = g;
485 
486  geoEfg2Llh_borkowski_fast (datum,efg,&lat,&lon,&hgt);
487  return(RAD_TO_DEG * lon);
488 }

Here is the call graph for this function:

double geoEfg2Lon_bowring ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 418 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_bowring(), and RAD_TO_DEG.

419 {
420  double efg[3];
421  double lat, lon, hgt;
422  efg[GEO_E] = e;
423  efg[GEO_F] = f;
424  efg[GEO_G] = g;
425 
426  geoEfg2Llh_bowring (datum,efg,&lat,&lon,&hgt);
427  return(RAD_TO_DEG * lon);
428 }

Here is the call graph for this function:

double geoEfg2Lon_bowring_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 307 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_bowring_fast(), and RAD_TO_DEG.

308 {
309  double efg[3];
310  double lat, lon, hgt;
311  efg[GEO_E] = e;
312  efg[GEO_F] = f;
313  efg[GEO_G] = g;
314 
315  geoEfg2Llh_bowring_fast (datum,efg,&lat,&lon,&hgt);
316  return(RAD_TO_DEG * lon);
317 }

Here is the call graph for this function:

double geoEfg2Lon_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 77 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_fast(), and RAD_TO_DEG.

78 {
79  double efg[3];
80  double lat, lon, hgt;
81  efg[GEO_E] = e;
82  efg[GEO_F] = f;
83  efg[GEO_G] = g;
84 
85  geoEfg2Llh_fast (datum,efg,&lat,&lon,&hgt);
86  return(RAD_TO_DEG * lon);
87 }

Here is the call graph for this function:

double geoEfg2Lon_heikkinen ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 820 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_heikkinen(), and RAD_TO_DEG.

821 {
822  double efg[3];
823  double lat, lon, hgt;
824  efg[GEO_E] = e;
825  efg[GEO_F] = f;
826  efg[GEO_G] = g;
827 
828  geoEfg2Llh_heikkinen (datum,efg,&lat,&lon,&hgt);
829  return(RAD_TO_DEG * lon);
830 }

Here is the call graph for this function:

double geoEfg2Lon_hm ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 202 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_hm(), and RAD_TO_DEG.

203 {
204  double efg[3];
205  double lat, lon, hgt;
206  efg[GEO_E] = e;
207  efg[GEO_F] = f;
208  efg[GEO_G] = g;
209 
210  geoEfg2Llh_hm (datum,efg,&lat,&lon,&hgt);
211  return(RAD_TO_DEG * lon);
212 }

Here is the call graph for this function:

double geoEfg2Lon_hm_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 149 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_hm_fast(), and RAD_TO_DEG.

150 {
151  double efg[3];
152  double lat, lon, hgt;
153  efg[GEO_E] = e;
154  efg[GEO_F] = f;
155  efg[GEO_G] = g;
156 
157  geoEfg2Llh_hm_fast (datum,efg,&lat,&lon,&hgt);
158  return(RAD_TO_DEG * lon);
159 }

Here is the call graph for this function:

double geoEfg2Lon_toms ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 919 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_toms(), and RAD_TO_DEG.

920 {
921  double efg[3];
922  double lat, lon, hgt;
923  efg[GEO_E] = e;
924  efg[GEO_F] = f;
925  efg[GEO_G] = g;
926 
927  geoEfg2Llh_toms (datum,efg,&lat,&lon,&hgt);
928  return(RAD_TO_DEG * lon);
929 }

Here is the call graph for this function:

double geoEfg2Lon_torge ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 311 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_torge(), and RAD_TO_DEG.

312 {
313  double efg[3];
314  double lat, lon, hgt;
315  efg[GEO_E] = e;
316  efg[GEO_F] = f;
317  efg[GEO_G] = g;
318 
319  geoEfg2Llh_torge (datum,efg,&lat,&lon,&hgt);
320  return(RAD_TO_DEG * lon);
321 }

Here is the call graph for this function:

double geoEfg2Lon_torge_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 225 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_torge_fast(), and RAD_TO_DEG.

226 {
227  double efg[3];
228  double lat, lon, hgt;
229  efg[GEO_E] = e;
230  efg[GEO_F] = f;
231  efg[GEO_G] = g;
232 
233  geoEfg2Llh_torge_fast (datum,efg,&lat,&lon,&hgt);
234  return(RAD_TO_DEG * lon);
235 }

Here is the call graph for this function:

double geoEfg2Lon_vermeille ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 719 of file geoEfg2Llh.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_vermeille(), and RAD_TO_DEG.

720 {
721  double efg[3];
722  double lat, lon, hgt;
723  efg[GEO_E] = e;
724  efg[GEO_F] = f;
725  efg[GEO_G] = g;
726 
727  geoEfg2Llh_vermeille (datum,efg,&lat,&lon,&hgt);
728  return(RAD_TO_DEG * lon);
729 }

Here is the call graph for this function:

double geoEfg2Lon_vermeille_fast ( int  datum,
double  e,
double  f,
double  g 
)

Definition at line 565 of file geoEfg2Llh_fast.c.

References GEO_E, GEO_F, GEO_G, geoEfg2Llh_vermeille_fast(), and RAD_TO_DEG.

566 {
567  double efg[3];
568  double lat, lon, hgt;
569  efg[GEO_E] = e;
570  efg[GEO_F] = f;
571  efg[GEO_G] = g;
572 
573  geoEfg2Llh_vermeille_fast (datum,efg,&lat,&lon,&hgt);
574  return(RAD_TO_DEG * lon);
575 }

Here is the call graph for this function:

int geoEfg2XyzDiff ( GEO_LOCATION src_desc,
GEO_LOCATION tgt_desc,
double  xyz_disp[] 
)

This function returns the XYZ offset of the target point with respect to the source point, given the Earth Fixed Geodetic coordinates of the points. The EFG coordinates for the source must appear in the GEO_LOCATION record, which must be built previous to the call to this procedure.

Parameters
GEO_LOCATION*src_desc
GEO_LOCATION*tgt_desc
doublexyz_disp[]
Return values
GEO_OKon success
GEO_ERRORon error
Note
This routine will allow you input site coordinates from two different datums. It is up to the caller to make sure the datums are the same (if it matters).

Definition at line 50 of file geoPoint.c.

References GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::e, GEO_LOCATION::f, GEO_LOCATION::g, GEO_OK, GEO_X, GEO_Y, GEO_Z, GEO_LOCATION::slat, and GEO_LOCATION::slon.

Referenced by geoLlh2DiffX(), geoLlh2DiffY(), and geoLlh2DiffZ().

53 {
54  double delta_e, delta_f, delta_g, intermed_val;
55 
56  // if(src_desc->datum != tgt_desc->datum) return(GEO_ERROR);
57 
58  delta_e = tgt_desc->e - src_desc->e;
59  delta_f = tgt_desc->f - src_desc->f;
60  delta_g = tgt_desc->g - src_desc->g;
61 
62  intermed_val = (-src_desc->clon * delta_e) -
63  ( src_desc->slon * delta_f);
64 
65  xyz_disp[GEO_X] =
66  (-src_desc->slon * delta_e) +
67  ( src_desc->clon * delta_f);
68  xyz_disp[GEO_Y] =
69  (src_desc->slat * intermed_val) +
70  (src_desc->clat * delta_g);
71  xyz_disp[GEO_Z] =
72  (-src_desc->clat * intermed_val) +
73  ( src_desc->slat * delta_g);
74 
75  return(GEO_OK);
76 
77 } /* End procedure site_xyz_diff */
int geoEfg2XyzDiff_packed ( GEO_LOCATION src_desc,
int  count,
double  efg_xyz[] 
)

This function returns the XYZ offset of the target point with respect to the source point, given the Earth Fixed Geodetic coordinates of the points. The EFG coordinates for the source must appear in the GEO_LOCATION record, which must be built previous to the call to this procedure.

Parameters
GEO_LOCATION*src_desc
GEO_LOCATION*tgt_desc
doublexyz_disp[]
Return values
GEO_OKon success
GEO_ERRORon error
Note
This routine will allow you input site coordinates from two different datums. It is up to the caller to make sure the datums are the same (if it matters).

Definition at line 96 of file geoPoint.c.

References GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::e, GEO_LOCATION::f, GEO_LOCATION::g, GEO_E, GEO_F, GEO_G, GEO_OK, GEO_X, GEO_Y, GEO_Z, GEO_LOCATION::slat, and GEO_LOCATION::slon.

97 {
98  double delta_e, delta_f, delta_g, intermed_val;
99 
100  double* vector;
101 
102  // calculate end
103  double* vend = efg_xyz + (3 * count);
104 
105  /* Convert all the sets. */
106  for (vector = efg_xyz; vector < vend; vector += 3)
107  {
108  delta_e = vector[GEO_E] - src_desc->e;
109  delta_f = vector[GEO_F] - src_desc->f;
110  delta_g = vector[GEO_G] - src_desc->g;
111 
112  intermed_val = (-src_desc->clon * delta_e) -
113  ( src_desc->slon * delta_f);
114 
115  vector[GEO_X] =
116  (-src_desc->slon * delta_e) +
117  ( src_desc->clon * delta_f);
118  vector[GEO_Y] =
119  (src_desc->slat * intermed_val) +
120  (src_desc->clat * delta_g);
121  vector[GEO_Z] =
122  (-src_desc->clat * intermed_val) +
123  ( src_desc->slat * delta_g);
124  }
125 
126  return(GEO_OK);
127 
128 } /* End procedure efg_xyz_diff */
void geoGetEllipsoid ( double *  a,
double *  b,
double *  e2,
double *  ee2,
double *  f,
int  datum 
)

This routine computes essential datum values from basic parameters obtained from the ellips structure.

Parameters
double*a : Major axis ( Meters )
double*b : Minor axis ( Meters )
double*e2 : Eccentricity
double*ee2 : Eccentricity prime
double*f : Flattening
intdatum : Datum to use
Returns
nothing

Definition at line 189 of file geoEllips.c.

References GEO_ELLIPSOID::a, GEO_B, GEO_E2, GEO_E2P, and GEO_FL.

Referenced by geoEfg2Llh(), geoEfg2Llh_aa(), geoEfg2Llh_borkowski(), geoEfg2Llh_bowring(), geoEfg2Llh_heikkinen(), geoEfg2Llh_hm(), geoEfg2Llh_toms(), geoEfg2Llh_torge(), geoEfg2Llh_vermeille(), geoInitLocation(), and geoLlh2Efg().

190 {
191  /* - Major Axis. */
192  *a = ellips[datum].a;
193 
194  /* - Earth Flattening. */
195  *f = GEO_FL(ellips[datum].f1);
196 
197  /* - Minor axis value. */
198  *b = GEO_B(ellips[datum].a, (ellips[datum].f1));
199 
200  /* - Eccentricity squared. */
201  *e2 = GEO_E2(ellips[datum].a, (ellips[datum].f1));
202 
203  /* - Eccentricity squared prime. */
204  *ee2 = GEO_E2P(ellips[datum].a, (ellips[datum].f1));
205 
206 
207 #ifdef GEO_DEBUG
208  printf("DEBUG: a=%f, b=%f, f=%f, e2=%f, e2p=%f \n",*a, *b, *f, *e2, *ee2);
209 #endif
210 }
int geoGetSunError ( void  )

Definition at line 198 of file geoAstro.c.

References geoSunError.

199 {
200  return(geoSunError);
201 }
int geoGettm ( int  part)

Definition at line 116 of file geoAstro.c.

References tError.

117 {
118  switch(part)
119  {
120  case 1: return(tError.tm_year);
121  case 2: return(tError.tm_mon);
122  case 3: return(tError.tm_mday);
123  }
124  return(-999);
125 }
int geoInitDatum ( GEO_DATUM d,
int  datum 
)
int geoInitLocation ( GEO_LOCATION l,
double  lat,
double  lon,
double  hgt,
int  datum,
char *  name 
)

This routine needs to be called when a site (or location) is initialized. Several of the routines use the information in the structure that this routine fills.

Parameters
GEO_LOCATION*l
doublelat
doublelon
doublehgt
intdatum
char*name //Name of the site location
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 96 of file geoEllips.c.

References GEO_DATUM::a, GEO_DATUM::b, GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::clonclat, GEO_LOCATION::clonslat, GEO_LOCATION::datum, GEO_DATUM::datum_num, DEG_TO_RAD, GEO_LOCATION::e, GEO_DATUM::e2, GEO_DATUM::ee2, GEO_LOCATION::efg, GEO_LOCATION::f, GEO_DATUM::flat, GEO_LOCATION::g, GEO_DATUM_MAX, GEO_E, GEO_ERROR, GEO_F, GEO_G, GEO_OK, geoGetEllipsoid(), geoMagFillDec(), GEO_LOCATION::hgt, GEO_LOCATION::lat, GEO_LOCATION::lon, GEO_DATUM::m1e2, GEO_LOCATION::name, GEO_LOCATION::rlat, GEO_LOCATION::rlon, GEO_LOCATION::slat, GEO_LOCATION::slon, GEO_LOCATION::slonclat, GEO_LOCATION::slonslat, GEO_LOCATION::timezone, and GEO_LOCATION::tlat.

Referenced by geoLlh2DiffX(), geoLlh2DiffY(), geoLlh2DiffZ(), geoLlh2E(), geoLlh2F(), geoLlh2G(), geoSunNowAz(), and geoSunNowEl().

97 {
98  double N,a,e2,ee2, b, flat,Nh;
99  double dec;
100  // struct tm *newtime;
101  // time_t aclock;
102 
103 
104  /* Validate and get datum values */
105  if(datum > GEO_DATUM_MAX) return(GEO_ERROR);
106  geoGetEllipsoid(&a,&b,&e2,&ee2,&flat,datum); /* Calls to read in "to" ellipsoid data */
107 
108  /* Initialize ellipsoid values in the location descriptor */
109  l->datum.a = a;
110  l->datum.b = b;
111  l->datum.e2 = e2;
112  l->datum.flat = flat ;
113  l->datum.ee2 = ee2;
114  l->datum.m1e2 = 1.0 - e2;
115 
116 
117  /* Initialize lat/lon values */
118  if(lon>180.0)lon=lon-360.0; // normalize to -180 to +180
119  l->lat = lat;
120  l->lon = lon;
121  l->hgt = hgt;
122 
123  l->rlat = lat * DEG_TO_RAD; /* make radians */
124  l->rlon = lon * DEG_TO_RAD;
125 
126  /* Precompute sin/cos values */
127 #ifdef HAVE_SINCOS
128  sincos(l->rlat,&l->slat,&l->clat);
129  sincos(l->rlon,&l->slon,&l->clon);
130 #else
131  l->slat = sin(l->rlat);
132  l->slon = sin(l->rlon);
133  l->clat = cos(l->rlat);
134  l->clon = cos(l->rlon);
135 #endif
136  l->tlat = tan(l->rlat);
137  l->clonclat = l->clon * l->clat;
138  l->slonslat = l->slon * l->slat;
139  l->clonslat = l->clon * l->slat;
140  l->slonclat = l->slon * l->clat;
141 
142  /* Compute geocentric coordinates */
143 
144  /* Compute the radius of curvature */
145  N = a / (sqrt(1.0 - e2 * pow(l->slat,2.0)));
146 
147  /* Compute the EFG(XYZ) coordinates (earth centered) */
148  Nh = N + hgt;
149  l->e = Nh * l->clonclat; //l->clat * l->clon;
150  l->f = Nh * l->slonclat; //l->clat * l->slon;
151  l->g = (N * (l->datum.m1e2) + hgt) * l->slat;
152  l->efg[GEO_E] = l->e;
153  l->efg[GEO_F] = l->f;
154  l->efg[GEO_G] = l->g;
155 
156  /* Compute the Magnetic Declination */
157  geoMagFillDec(l,&dec);
158 
159  /* Time Zone */
160  l->timezone = 0.0; //use geoSetTimeZone to set this value
161 
162  /* Save datum and site info */
163  l->datum.datum_num = datum;
164  strcpy(l->name, name);
165 
166  return(GEO_OK);
167 }

Here is the call graph for this function:

int geoInitLocation2 ( GEO_LOCATION l,
double  lat,
double  lon,
double  hgt,
const GEO_DATUM datum,
const char *  name 
)
double geoLlh2DiffX ( double  lat1,
double  lon1,
double  hgt1,
int  datum1,
double  lat2,
double  lon2,
double  hgt2,
int  datum2 
)

Definition at line 130 of file geoPoint.c.

References GEO_X, geoEfg2XyzDiff(), and geoInitLocation().

131 {
132  double xyz[3];
133  GEO_LOCATION site1, site2;
134 
135  geoInitLocation(&site1, lat1, lon1, hgt1, datum1, "site1");
136  geoInitLocation(&site2, lat2, lon2, hgt2, datum2, "site2");
137  geoEfg2XyzDiff(&site1, &site2,xyz);
138  return(xyz[GEO_X]);
139 
140 }

Here is the call graph for this function:

double geoLlh2DiffY ( double  lat1,
double  lon1,
double  hgt1,
int  datum1,
double  lat2,
double  lon2,
double  hgt2,
int  datum2 
)

Definition at line 142 of file geoPoint.c.

References GEO_Y, geoEfg2XyzDiff(), and geoInitLocation().

143 {
144  double xyz[3];
145  GEO_LOCATION site1, site2;
146 
147  geoInitLocation(&site1, lat1, lon1, hgt1, datum1, "site1");
148  geoInitLocation(&site2, lat2, lon2, hgt2, datum2, "site2");
149  geoEfg2XyzDiff(&site1, &site2,xyz);
150  return(xyz[GEO_Y]);
151 
152 }

Here is the call graph for this function:

double geoLlh2DiffZ ( double  lat1,
double  lon1,
double  hgt1,
int  datum1,
double  lat2,
double  lon2,
double  hgt2,
int  datum2 
)

Definition at line 153 of file geoPoint.c.

References GEO_Z, geoEfg2XyzDiff(), and geoInitLocation().

154 {
155  double xyz[3];
156  GEO_LOCATION site1, site2;
157 
158  geoInitLocation(&site1, lat1, lon1, hgt1, datum1, "site1");
159  geoInitLocation(&site2, lat2, lon2, hgt2, datum2, "site2");
160  geoEfg2XyzDiff(&site1, &site2,xyz);
161  return(xyz[GEO_Z]);
162 
163 }

Here is the call graph for this function:

double geoLlh2E ( double  lat,
double  lon,
double  hgt,
int  datum 
)

This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the E component.

Parameters
doublelat : Latitude in RADIANS
doublelon : Longitude in RADIANS
doubleheight : Height in METERS
intdatum1
Returns
double *e : E(x) in METERS

Definition at line 262 of file geoPoint.c.

References GEO_LOCATION::e, and geoInitLocation().

264 {
265  GEO_LOCATION site;
266 
267  geoInitLocation(&site, lat, lon, hgt, datum, "site");
268  return(site.e);
269 }

Here is the call graph for this function:

void geoLlh2Efg ( double  lat,
double  lon,
double  height,
int  datum,
double *  e,
double *  f,
double *  g 
)

This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G).

Parameters
doublelat : Latitude in RADIANS
doublelon : Longitude in RADIANS
doubleheight : Height in METERS
intdatum1
double*e : E(x) in METERS
double*f : F(y) in METERS
double*g : G(z) in METERS
Returns
nothing

Definition at line 181 of file geoPoint.c.

References geoGetEllipsoid().

184 {
185  double N,a,e2,ee2, b, flat;
186  double slat, clat;
187 
188  clat = cos(lat);
189  slat = sin(lat);
190 
191  /* Get the ellipsoid parameters */
192  geoGetEllipsoid(&a,&b,&e2,&ee2,&flat,datum);
193 
194  /* Compute the radius of curvature */
195  N = a / (sqrt(1.0 - e2 * pow(slat,2.0)));
196 
197  /* Compute the EFG(XYZ) coordinates (earth centered) */
198  *e = (N + height) * clat * cos(lon);
199  *f = (N + height) * clat * sin(lon);
200  *g = (N * (1.0 - e2) + height) * sin(lat);
201 }

Here is the call graph for this function:

void geoLlh2Efg_packed ( GEO_DATUM datum,
int  count,
double  llh_efg[] 
)

This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G).

Parameters
GEO_DATUM*datum Datum of the lat/lon/height
intcount Number of vertices
doublellh_efg[] Pointer to the first coordinate of the first vertex of the array.
Returns
nothing

Definition at line 214 of file geoPoint.c.

References GEO_DATUM::a, GEO_DATUM::e2, GEO_E, GEO_F, GEO_G, GEO_HGT, GEO_LAT, and GEO_LON.

215 {
216  double N, slat, clat, slon, clon;
217 
218  double* vector;
219 
220  // calculate end
221  double* vend = llh_efg + (3 * count);
222 
223  /* Convert all the sets. */
224  for (vector = llh_efg; vector < vend; vector += 3)
225  {
226 #ifdef HAVE_SINCOS
227  sincos(vector[GEO_LAT], &slat, &clat);
228  sincos(vector[GEO_LON], &slon, &clon);
229 
230 #else
231  slat = sin(vector[GEO_LAT]);
232  clat = cos(vector[GEO_LAT]);
233  slon = sin(vector[GEO_LON]);
234  clon = cos(vector[GEO_LON]);
235 #endif
236 
237  /* Compute the radius of curvature */
238  N = datum->a / (sqrt(1.0 - datum->e2 * slat * slat));
239 
240  /* Compute the EFG(XYZ) coordinates (earth centered) */
241  vector[GEO_E] = (N + vector[GEO_HGT]) * clat * clon;
242  vector[GEO_F] = (N + vector[GEO_HGT]) * clat * slon;
243  vector[GEO_G] = (N * (1.0 - datum->e2) + vector[GEO_HGT]) * slat;
244  }
245 }
double geoLlh2F ( double  lat,
double  lon,
double  hgt,
int  datum 
)

This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the F component.

Parameters
doublelat : Latitude in RADIANS
doublelon : Longitude in RADIANS
doubleheight : Height in METERS
intdatum1
Returns
double *f : F(x) in METERS

Definition at line 286 of file geoPoint.c.

References GEO_LOCATION::f, and geoInitLocation().

288 {
289  GEO_LOCATION site;
290 
291  geoInitLocation(&site, lat, lon, hgt, datum, "site");
292  return(site.f);
293 }

Here is the call graph for this function:

double geoLlh2G ( double  lat,
double  lon,
double  hgt,
int  datum 
)

This routine will convert geodetic coordinates (latitude $\phi$, longitude $\lambda$, and ellipsoid height $h$) into earth centered Cartesian coordinates (E,F,G). This returns the G component.

Parameters
doublelat : Latitude in RADIANS
doublelon : Longitude in RADIANS
doubleheight : Height in METERS
intdatum1
Returns
double *g : G(x) in METERS

Definition at line 310 of file geoPoint.c.

References GEO_LOCATION::g, and geoInitLocation().

312 {
313  GEO_LOCATION site;
314 
315  geoInitLocation(&site, lat, lon, hgt, datum, "site");
316  return(site.g);
317 }

Here is the call graph for this function:

int geoMag ( double  alt,
double  glat,
double  glon,
double  time,
double *  dec,
double *  dip,
double *  ti,
double *  gv,
double *  adec,
double *  adip,
double *  ati,
double *  x,
double *  y,
double *  z,
double *  h,
double *  ax,
double *  ay,
double *  az,
double *  ah 
)

This routine computes all of the relevant geomagnetic data.

Parameters
doublealt : in: altitude in meters
doubleglat : in: latitude in decimal degrees
doubleglon : in: longitude in decimal degrees
doubletime : in: time in decimal years
double*dec :out: declination in degrees
double*dip :out: dip in degrees
double*ti :out: total intensity in nT
double*gv :out: geomagnetic grid variation
double*adec :out: Annual declination in degrees
double*adip :out: Annual dip in degrees
double*ati :out: Annual total intensity in nT
double*x :out: X Component of the magnetic field
double*y :out: Y Component of the magnetic field
double*z :out: Z Component of the magnetic field
double*h :out: h Component of the magnetic field
double*ax :out: Annual X Component of the magnetic field
double*ay :out: Annual Y Component of the magnetic field
double*az :out: Annual Z Component of the magnetic field
double*ah :out: Annual H Component of the magnetic field
Return values
GEO_OKon success
GEO_ERRORon error

{

Definition at line 523 of file geoMag.c.

References DEG_TO_MIN, DEG_TO_RAD, GEO_OK, geoMagInit(), and geomg1().

528 {
529  double time1;
530  double dec2, dip2, ti2, rdec, rdip, rdec2, rdip2;
531  double x2,y2,z2,h2;
532  double c_rdip,c_rdip2;
533  // double rTd=0.017453292;
534 
535  geoMagInit();
536 
537  geomg1(alt,glat,glon,time,dec,dip,ti,gv);
538  time1 = time + 1.0; // add a year to time
539  geomg1(alt,glat,glon,time1,&dec2,&dip2,&ti2,gv);
540 
541 
542 
543  /*COMPUTE X, Y, Z, AND H COMPONENTS OF THE MAGNETIC FIELD*/
544  rdec = *dec * DEG_TO_RAD;
545  rdip = *dip * DEG_TO_RAD;
546  rdec2 = dec2 * DEG_TO_RAD;
547  rdip2 = dip2 * DEG_TO_RAD;
548  c_rdip = cos(rdip);
549  c_rdip2 = cos(rdip2);
550  /*
551  *x= *ti * (cos(rdec) * cos(rdip));
552  *y= *ti * (cos(rdip) * sin(rdec));
553  *z= *ti * (sin(rdip));
554  *h= *ti * (cos(rdip));
555 
556  x2=ti2*(cos(rdec2) * cos(rdip2));
557  y2=ti2*(cos(rdip2) * sin(rdec2));
558  z2=ti2*(sin(rdip2));
559  h2=ti2*(cos(rdip2));
560 */
561  *x= *ti * (cos(rdec) * c_rdip);
562  *y= *ti * (c_rdip * sin(rdec));
563  *z= *ti * (sin(rdip));
564  *h= *ti * (c_rdip);
565 
566  x2=ti2*(cos(rdec2) * c_rdip2);
567  y2=ti2*(c_rdip2 * sin(rdec2));
568  z2=ti2*(sin(rdip2));
569  h2=ti2*(c_rdip2);
570 
571 
572  /* COMPUTE ANNUAL CHANGE FOR TOTAL INTENSITY */
573  *ati = ti2 - *ti;
574 
575  /* COMPUTE ANNUAL CHANGE FOR DIP & DEC (in minutes) */
576  *adip = (dip2 - *dip) * DEG_TO_MIN;
577  *adec = (dec2 - *dec) * DEG_TO_MIN;
578 
579 
580  /* COMPUTE ANNUAL CHANGE FOR X, Y, Z, AND H */
581  *ax = x2 - *x;
582  *ay = y2 - *y;
583  *az = z2 - *z;
584  *ah = h2 - *h;
585 
586  return(GEO_OK);
587 }

Here is the call graph for this function:

int geoMagFillDec ( GEO_LOCATION l,
double *  dec 
)

Definition at line 903 of file geoMag.c.

References GEO_LOCATION::Declination, GEO_OK, geoMagGetDec(), GEO_LOCATION::hgt, GEO_LOCATION::lat, and GEO_LOCATION::lon.

Referenced by geoInitLocation().

904 {
905  struct tm *newtime;
906  time_t aclock;
907 
908  /* Compute the Magnetic Declination */
909  time( &aclock ); /* Get time in seconds */
910  newtime = localtime( &aclock ); /* Convert time to struct tm form */
911 
912  if(newtime->tm_year < 200 ) newtime->tm_year += 1900;
913 
914  // printf("%d / %d / %d \n",newtime->tm_mon+1, newtime->tm_mday, newtime->tm_year);
915  geoMagGetDec(l->lat,l->lon,l->hgt,
916  newtime->tm_mon+1, newtime->tm_mday, newtime->tm_year, dec);
917  l->Declination = *dec;
918 
919  return (GEO_OK);
920 }

Here is the call graph for this function:

int geoMagGetDec ( double  lat,
double  lon,
double  hgt,
int  month,
int  day,
int  year,
double *  dec 
)

This routine computes magnetic declination.

Parameters
doublelat : in: latitude in decimal degrees
doublelon : in: longitude in decimal degrees
doublehgt : in: altitude in meters
intmonth : in: Month of the year
intday : in: Day of the month
intyear : in: Year
doubledec :out: declination in degrees

Definition at line 825 of file geoMag.c.

References GEO_OK, geoMagInit(), geomg1(), and jday().

Referenced by geoMagFillDec(), and geoMagGetDecNow().

827 {
828  /* Days in each month 1-12 */
829  int jday[] = {0,0,31,59,90,120,151,180,211,242,272,303,333 };
830  double time,dip,ti,gv;
831 
832  /* Determin decimal years from date */
833  time = ((jday[month]+day) / 365.0) + year;
834 
835  /* Determin declination */
836  geoMagInit();
837  geomg1(hgt,lat,lon,time,dec,&dip,&ti,&gv);
838 
839  return (GEO_OK);
840 
841 }

Here is the call graph for this function:

double geoMagGetDecNow ( double  lat,
double  lon,
double  hgt 
)

This routine computes magnetic declination for now time.

Parameters
doublelat : in: latitude in decimal degrees
doublelon : in: longitude in decimal degrees
doublehgt : in: altitude in meters
Return values
doubledec :out: declination in degrees

Definition at line 882 of file geoMag.c.

References geoMagGetDec().

883 {
884  struct tm *newtime;
885  time_t aclock;
886  double dec;
887 
888  /* Compute the Magnetic Declination */
889  time( &aclock ); /* Get time in seconds */
890  newtime = localtime( &aclock ); /* Convert time to struct tm form */
891 
892  if(newtime->tm_year < 200 ) newtime->tm_year += 1900;
893 
894  // printf("%d / %d / %d \n",newtime->tm_mon+1, newtime->tm_mday, newtime->tm_year);
895  geoMagGetDec(lat,lon,hgt,
896  newtime->tm_mon+1, newtime->tm_mday, newtime->tm_year, &dec);
897 
898  return (dec);
899 
900 }

Here is the call graph for this function:

double geoMagGetDecRet ( double  lat,
double  lon,
double  hgt,
int  month,
int  day,
int  year 
)

This routine computes and returns magnetic declination for a specific date.

Parameters
doublelat : in: latitude in decimal degrees
doublelon : in: longitude in decimal degrees
doublehgt : in: altitude in meters
intmonth : in: Month of the year
intday : in: Day of the month
intyear : in: Year
Return values
doubledec :out: declination in degrees

Definition at line 855 of file geoMag.c.

References geoMagInit(), geomg1(), and jday().

857 {
858  /* Days in each month 1-12 */
859  double dec;
860  int jday[] = {0,0,31,59,90,120,151,180,211,242,272,303,333 };
861  double time,dip,ti,gv;
862 
863  /* Determin decimal years from date */
864  time = ((jday[month]+day) / 365.0) + year;
865 
866  /* Determin declination */
867  geoMagInit();
868  geomg1(hgt,lat,lon,time,&dec,&dip,&ti,&gv);
869 
870  return (dec);
871 
872 }

Here is the call graph for this function:

int geomg1 ( double  alt,
double  glat,
double  glon,
double  time,
double *  dec,
double *  dip,
double *  ti,
double *  gv 
)

This is documentation that came with the WMM. It is included here for completeness.

//       MAXDEG - MAXIMUM DEGREE OF SPHERICAL HARMONIC MODEL    (INPUT)
//       TIME   - COMPUTATION TIME (YRS)                        (INPUT)
//                (EG. 1 JULY 1995 = 1995.500)
//       ALT    - GEODETIC ALTITUDE (M)                        (INPUT)
//       GLAT   - GEODETIC LATITUDE (DEG.)                      (INPUT)
//       GLON   - GEODETIC LONGITUDE (DEG.)                     (INPUT)
//       EPOCH  - BASE TIME OF GEOMAGNETIC MODEL (YRS)
//       P(N,M) - ASSOCIATED LEGENDRE POLYNOMIALS (UNNORMALIZED)
//       DEC    - GEOMAGNETIC DECLINATION (DEG.)                (OUTPUT)
//                  EAST=POSITIVE ANGLES
//                  WEST=NEGATIVE ANGLES
//       DIP    - GEOMAGNETIC INCLINATION (DEG.)                (OUTPUT)
//                  DOWN=POSITIVE ANGLES
//                    UP=NEGATIVE ANGLES
//       TI     - GEOMAGNETIC TOTAL INTENSITY (NT)              (OUTPUT)
//       GV     - GEOMAGNETIC GRID VARIATION (DEG.)             (OUTPUT)
//                REFERENCED TO GRID NORTH
//                GRID NORTH REFERENCED TO 0 MERIDIAN
//                OF A POLAR STEREOGRAPHIC PROJECTION
//                (ARCTIC/ANTARCTIC ONLY)
//       A      - SEMIMAJOR AXIS OF WGS-84 ELLIPSOID (KM)
//       B      - SEMIMINOR AXIS OF WGS-84 ELLIPSOID (KM)
//       RE     - MEAN RADIUS OF IAU-66 ELLIPSOID (KM)
//       a2,             // a * a
//       b2,             // b * b
//       c2,             // a2 - b2
//       a4,             // a2 * a2
//       b4,             // b2 * b2
//       c4,             // a4 - b4
//       ct,             //C       CT     - COSINE OF (SPHERICAL COORD. LATITUDE)
//       st,             //C       ST     - SINE OF (SPHERICAL COORD. LATITUDE)
//       r2,
//       r,              //C       R      - SPHERICAL COORDINATE RADIAL POSITION (KM)
//       ca,             //C       CA     - COSINE OF SPHERICAL TO GEODETIC VECTOR ROTATION ANGLE
//       sa,             //C       SA     - SINE OF SPHERICAL TO GEODETIC VECTOR ROTATION ANGLE
//       br,             //C       BR     - RADIAL COMPONENT OF GEOMAGNETIC FIELD (NT)
//       bt,             //C       BT     - THETA COMPONENT OF GEOMAGNETIC FIELD (NT)
//       bp,             //C       BP     - PHI COMPONENT OF GEOMAGNETIC FIELD (NT)
//       bx,             //C       BX     - NORTH GEOMAGNETIC COMPONENT (NT)
//       by,             //C       BY     - EAST GEOMAGNETIC COMPONENT (NT)
//       bz,             //C       BZ     - VERTICALLY DOWN GEOMAGNETIC COMPONENT (NT)
//       bh;             //C       BH     - HORIZONTAL GEOMAGNETIC COMPONENT (NT)

Definition at line 595 of file geoMag.c.

References GEO_ELLIPSOID::a, c, cd, CIRCLE, cp, DEG_TO_RAD, dp, ellips, epoch, fm, fn, GEO_B, GEO_DATUM_WE, GEO_OK, HALF_CIRCLE, k, maxord, n(), p, pp, RAD_TO_DEG, sp, and tc.

Referenced by geoMag(), geoMagGetDec(), and geoMagGetDecRet().

597 {
598 
599  /*!
600 This is documentation that came with the WMM. It is included here for completeness.
601 \verbatim
602 // MAXDEG - MAXIMUM DEGREE OF SPHERICAL HARMONIC MODEL (INPUT)
603 // TIME - COMPUTATION TIME (YRS) (INPUT)
604 // (EG. 1 JULY 1995 = 1995.500)
605 // ALT - GEODETIC ALTITUDE (M) (INPUT)
606 // GLAT - GEODETIC LATITUDE (DEG.) (INPUT)
607 // GLON - GEODETIC LONGITUDE (DEG.) (INPUT)
608 // EPOCH - BASE TIME OF GEOMAGNETIC MODEL (YRS)
609 // P(N,M) - ASSOCIATED LEGENDRE POLYNOMIALS (UNNORMALIZED)
610 // DEC - GEOMAGNETIC DECLINATION (DEG.) (OUTPUT)
611 // EAST=POSITIVE ANGLES
612 // WEST=NEGATIVE ANGLES
613 // DIP - GEOMAGNETIC INCLINATION (DEG.) (OUTPUT)
614 // DOWN=POSITIVE ANGLES
615 // UP=NEGATIVE ANGLES
616 // TI - GEOMAGNETIC TOTAL INTENSITY (NT) (OUTPUT)
617 // GV - GEOMAGNETIC GRID VARIATION (DEG.) (OUTPUT)
618 // REFERENCED TO GRID NORTH
619 // GRID NORTH REFERENCED TO 0 MERIDIAN
620 // OF A POLAR STEREOGRAPHIC PROJECTION
621 // (ARCTIC/ANTARCTIC ONLY)
622 // A - SEMIMAJOR AXIS OF WGS-84 ELLIPSOID (KM)
623 // B - SEMIMINOR AXIS OF WGS-84 ELLIPSOID (KM)
624 // RE - MEAN RADIUS OF IAU-66 ELLIPSOID (KM)
625 // a2, // a * a
626 // b2, // b * b
627 // c2, // a2 - b2
628 // a4, // a2 * a2
629 // b4, // b2 * b2
630 // c4, // a4 - b4
631 // ct, //C CT - COSINE OF (SPHERICAL COORD. LATITUDE)
632 // st, //C ST - SINE OF (SPHERICAL COORD. LATITUDE)
633 // r2,
634 // r, //C R - SPHERICAL COORDINATE RADIAL POSITION (KM)
635 // ca, //C CA - COSINE OF SPHERICAL TO GEODETIC VECTOR ROTATION ANGLE
636 // sa, //C SA - SINE OF SPHERICAL TO GEODETIC VECTOR ROTATION ANGLE
637 // br, //C BR - RADIAL COMPONENT OF GEOMAGNETIC FIELD (NT)
638 // bt, //C BT - THETA COMPONENT OF GEOMAGNETIC FIELD (NT)
639 // bp, //C BP - PHI COMPONENT OF GEOMAGNETIC FIELD (NT)
640 // bx, //C BX - NORTH GEOMAGNETIC COMPONENT (NT)
641 // by, //C BY - EAST GEOMAGNETIC COMPONENT (NT)
642 // bz, //C BZ - VERTICALLY DOWN GEOMAGNETIC COMPONENT (NT)
643 // bh; //C BH - HORIZONTAL GEOMAGNETIC COMPONENT (NT)
644 \endverbatim
645 */
646 
647  int m,n;
648  double temp1, temp2,d,ar,aor,dt,bpp,
649  par, parp,r,r2,sa,ca,st,ct,br,bt,bp,bx,by,bz,bh;
650 
651  double rlon,rlat,
652  srlon, srlat, crlon, crlat,
653  srlat2, crlat2,
654  a, // A - SEMIMAJOR AXIS OF WGS-84 ELLIPSOID (KM)
655  b, // B - SEMIMINOR AXIS OF WGS-84 ELLIPSOID (KM)
656  re, // RE - MEAN RADIUS OF IAU-66 ELLIPSOID (KM)
657  a2, // a * a
658  b2, // b * b
659  c2, // a2 - b2
660  a4, // a2 * a2
661  b4, // b2 * b2
662  c4, // a4 - b4
663 
664  q, q1, q2;
665 
666  a = ellips[GEO_DATUM_WE].a; //6378137.0;
667  b = GEO_B(ellips[GEO_DATUM_WE].a, (ellips[GEO_DATUM_WE].f1)); //6356752.3142; //wgs-84
668  re = 6371200.0;
669  a2 = a*a;
670  b2 = b*b;
671  c2 = a2-b2;
672  a4 = a2*a2;
673  b4 = b2*b2;
674  c4 = a4 - b4;
675 
676 
677  dt = time - epoch;
678  // if (dt < 0.0 || dt > 5.0)
679  // printf("\n WARNING geoMag - TIME EXTENDS BEYOND MODEL 5-YEAR LIFE SPAN (dt=%f, time=%f)\n",dt,time);
680 
681  rlon = glon*DEG_TO_RAD;
682  rlat = glat*DEG_TO_RAD;
683  srlon = sin(rlon);
684  srlat = sin(rlat);
685  crlon = cos(rlon);
686  crlat = cos(rlat);
687  srlat2 = srlat*srlat;
688  crlat2 = crlat*crlat;
689  sp[1] = srlon;
690  cp[1] = crlon;
691 
692  /* CONVERT FROM GEODETIC COORDS. TO SPHERICAL COORDS. */
693 
694  q = sqrt(a2-c2*srlat2);
695  q1 = alt*q;
696  q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));
697  ct = srlat/sqrt(q2*crlat2+srlat2);
698  st = sqrt(1.0-(ct*ct));
699  r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q);
700  r = sqrt(r2);
701  d = sqrt(a2*crlat2+b2*srlat2);
702  ca = (alt+d)/r;
703  sa = c2*crlat*srlat/(r*d);
704 
705  for (m=2; m<=maxord; m++)
706  {
707  sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];
708  cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];
709  }
710 
711  aor = re/r;
712  ar = aor*aor;
713  br = bt = bp = bpp = 0.0;
714  for (n=1; n<=maxord; n++)
715  {
716  ar = ar*aor;
717  for (m=0;m<=n;m++)
718  {
719  /*
720  COMPUTE UNNORMALIZED ASSOCIATED LEGENDRE POLYNOMIALS
721  AND DERIVATIVES VIA RECURSION RELATIONS
722  */
723  if (n == m)
724  {
725  p[m][n] = st * p[m-1][n-1];
726  dp[m][n] = st * dp[m-1][n-1] + ct * p[m-1][n-1];
727  goto S50;
728  }
729  if (n == 1 && m == 0)
730  {
731  p[m][n] = ct * p[m][n-1];
732  dp[m][n] = ct * dp[m][n-1] - st * p[m][n-1];
733  goto S50;
734  }
735  if (n > 1 && n != m)
736  {
737  if (m > n-2) p[m][n-2] = 0.0;
738  if (m > n-2) dp[m][n-2] = 0.0;
739  p[m][n] = ct * p[m][n-1] - k[m][n] * p[m][n-2];
740  dp[m][n] = ct * dp[m][n-1] - st * p[m][n-1] - k[m][n] * dp[m][n-2];
741  }
742 S50:
743  // TIME ADJUST THE GAUSS COEFFICIENTS
744  tc[m][n] = c[m][n]+dt*cd[m][n];
745  if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];
746 
747  // ACCUMULATE TERMS OF THE SPHERICAL HARMONIC EXPANSIONS
748  par = ar * p[m][n];
749  if (m == 0)
750  {
751  temp1 = tc[m][n]*cp[m];
752  temp2 = tc[m][n]*sp[m];
753  }
754  else
755  {
756  temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];
757  temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];
758  }
759  bt = bt-ar*temp1*dp[m][n];
760  bp += (fm[m]*temp2*par);
761  br += (fn[n]*temp1*par);
762 
763  // SPECIAL CASE: NORTH/SOUTH GEOGRAPHIC POLES
764  if (st == 0.0 && m == 1)
765  {
766  if (n == 1) pp[n] = pp[n-1];
767  else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];
768  parp = ar*pp[n];
769  bpp += (fm[m]*temp2*parp);
770  }
771  }
772  }
773  if (st == 0.0) bp = bpp;
774  else bp /= st;
775  /*
776  ROTATE MAGNETIC VECTOR COMPONENTS FROM SPHERICAL TO
777  GEODETIC COORDINATES
778 */
779  bx = -bt*ca-br*sa;
780  by = bp;
781  bz = bt*sa-br*ca;
782  /*
783 ** COMPUTE DECLINATION (DEC), INCLINATION (DIP) AND
784 ** TOTAL INTENSITY (TI)
785 */
786  bh = sqrt((bx*bx)+(by*by));
787  *ti = sqrt((bh*bh)+(bz*bz));
788  *dec = atan2(by,bx)*RAD_TO_DEG;
789  *dip = atan2(bz,bh)*RAD_TO_DEG;
790 
791  /*
792 ** COMPUTE MAGNETIC GRID VARIATION IF THE CURRENT
793 ** GEODETIC POSITION IS IN THE ARCTIC OR ANTARCTIC
794 ** (I.E. GLAT > +55 DEGREES OR GLAT < -55 DEGREES)
795 **
796 ** OTHERWISE, SET MAGNETIC GRID VARIATION TO -999.0
797 */
798  *gv = -999.0;
799  if (fabs(glat) >= 55.)
800  {
801  if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;
802  if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);
803  if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;
804  if (glat < 0.0 && glon < 0.0) *gv = *dec-fabs(glon);
805  if (*gv > +HALF_CIRCLE) *gv -= CIRCLE;
806  if (*gv < -HALF_CIRCLE) *gv += CIRCLE;
807  }
808 
809  return (GEO_OK);
810 
811 }

Here is the call graph for this function:

double geoRads2DD ( double  rads)

Converts radians to Decimal Degrees.

Parameters
doubleradians
Returns
double decimal degrees

Definition at line 836 of file geoPoint.c.

References RAD_TO_DEG.

837 {
838  return(rads * RAD_TO_DEG);
839 }
double geoRads2Decdms ( double  rads)

Convert radians to decimal degrees, minutes, and seconds ("dddmmss.s").

Parameters
doublerads
Returns
double Decimal Deg/min/sec

Definition at line 810 of file geoPoint.c.

References RAD_TO_DEG.

811 {
812  double d,m,s,sign;
813  double frac;
814 
815  if (rads < 0.0)
816  sign = -1.0;
817  else
818  sign = 1.0;
819 
820  frac = modf(fabs(rads * RAD_TO_DEG),&d);
821  frac = modf(frac * 60.0,&m);
822  s = frac * 60.0;
823 
824  /* Return dddmmss.s to calling function. */
825  return(((d*10000.0)+(m*100)+s)*sign);
826 }
void geoRads2Dms ( double  rads,
double *  deg,
double *  min,
double *  sec,
double *  dir 
)

Converts radians to degrees minutes seconds.

Parameters
doublerads
doubledeg, min, sec
chardir : -1.0 or 1.0
Returns
nothing

Definition at line 782 of file geoPoint.c.

References RAD_TO_DEG.

784 {
785  double temp;
786  double fraction;
787 
788  if (rads < 0.0)
789  *dir = -1.0;
790  else
791  *dir = 1.0;
792 
793  rads = fabs (rads);
794 
795  temp = RAD_TO_DEG * rads;
796  fraction = modf(temp,deg);
797 
798  temp = fraction * 60.0;
799  fraction = modf(temp,min);
800 
801  *sec = fraction * 60.0;
802 }
void geoRae2Efg ( GEO_LOCATION loc,
double  aer_in[],
double  efg_out[] 
)

Ingests Range, Azimuth, Elevation and site info and returns the EFG coordinates that the RAE points to.

Parameters
GEO_LOCATION*loc
doubleaer_in[]
doubleefg_out[]
Returns
nothing

Definition at line 654 of file geoPoint.c.

References GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::e, GEO_LOCATION::f, GEO_LOCATION::g, GEO_E, GEO_F, GEO_G, GEO_X, GEO_Y, GEO_Z, geoRae2Xyz(), GEO_LOCATION::slat, and GEO_LOCATION::slon.

657 {
658  double c1, c2, c3;
659  double xyz_val[3];
660 
661  /* Convert the RAE value to XYZ: */
662  geoRae2Xyz(aer_in, xyz_val);
663 
664  /* Do the matrix multiplication: */
665 
666  c1 = -loc->slon * xyz_val[GEO_X] +
667  -loc->clon * loc->slat * xyz_val[GEO_Y] +
668  loc->clon * loc->clat * xyz_val[GEO_Z];
669 
670  c2 = loc->clon * xyz_val[GEO_X] +
671  -loc->slon * loc->slat * xyz_val[GEO_Y] +
672  loc->slon * loc->clat * xyz_val[GEO_Z];
673 
674  c3 = loc->clat * xyz_val[GEO_Y] +
675  loc->slat * xyz_val[GEO_Z];
676 
677  /* Add resultant matrix to local EFG to get remote EFG: */
678  efg_out[GEO_E] = c1 + loc->e;
679  efg_out[GEO_F] = c2 + loc->f;
680  efg_out[GEO_G] = c3 + loc->g;
681 
682 } /* End procedure aer_to_efg */

Here is the call graph for this function:

void geoRae2Xyz ( double  rae_in[],
double  xyz_out[] 
)

This routine converts from Range, Azimuth, and Elevation into Cartesian coordinates X,Y,Z.

Parameters
doublerae_in[]
doublexyz_out[]
Returns
nothing

Definition at line 501 of file geoPoint.c.

References GEO_AZ, GEO_EL, GEO_RNG, GEO_X, GEO_Y, and GEO_Z.

Referenced by geoRae2Efg().

503 {
504  double r_cos_e;
505 
506  r_cos_e = rae_in[GEO_RNG] * cos(rae_in[GEO_EL]);
507 
508  xyz_out[GEO_X] = sin(rae_in[GEO_AZ]) * r_cos_e;
509  xyz_out[GEO_Y] = cos(rae_in[GEO_AZ]) * r_cos_e;
510  xyz_out[GEO_Z] = rae_in[GEO_RNG] * sin(rae_in[GEO_EL]);
511 }
void geoRae2Xyz_packed ( int  count,
double  rae_xyz[] 
)

This routine iterates over count vertices in the array rae_xyz converting it from Range, Azimuth, and Elevation into Cartesian coordinates X,Y,Z.

Parameters
countNumber of vertices
rae_xyz[]Pointer to the first coordinate of the first vertex of the array.
Returns
nothing

Definition at line 522 of file geoPoint.c.

References GEO_AZ, GEO_EL, GEO_RNG, GEO_X, GEO_Y, and GEO_Z.

524 {
525  double r_cos_e;
526  double r_sin_e;
527 #ifdef HAVE_SINCOS
528  double sin_a;
529 #endif
530  double cos_a;
531  double* vector;
532 
533  // calculate end
534  double* vend = rae_xyz + (3 * count);
535 
536  /* Convert all the sets. */
537  for (vector = rae_xyz; vector < vend; vector += 3)
538  {
539 #ifdef HAVE_SINCOS
540  sincos(vector[GEO_EL], &r_sin_e, &r_cos_e);
541  sincos(vector[GEO_AZ], &sin_a, &cos_a);
542  r_cos_e *= vector[GEO_RNG];
543  r_sin_e *= vector[GEO_RNG];
544 
545  vector[GEO_X] = sin_a * r_cos_e;
546  vector[GEO_Y] = cos_a * r_cos_e;
547  vector[GEO_Z] = r_sin_e;
548 #else
549  r_cos_e = vector[GEO_RNG] * cos(vector[GEO_EL]);
550  r_sin_e *= vector[GEO_RNG] * sin(vector[GEO_EL]);
551  cos_a = cos(vector[GEO_AZ]);
552 
553  vector[GEO_X] = sin(vector[GEO_AZ]) * r_cos_e;
554  vector[GEO_Y] = cos_a * r_cos_e;
555  vector[GEO_Z] = vector[GEO_RNG] ;
556 #endif
557  }
558 }
int geoSetAccuracy ( double  acc)

This routine will set the accuracy of the iterative Efg2Llh routines (geoEfg2Llh_hm, geoEfg2Llh_torge, geoEfg2Llh_bowring, geoEfg2Llh_aa)

Parameters
doubleacc : Accuracy in degrees
Return values
GEO_OKon success
GEO_ERRORon error

Several definitions may be used with this function: GEO_EFG2LLH_ACCURACY_METER = 0.00001 degrees GEO_EFG2LLH_ACCURACY_CM = 0.0000001 degrees GEO_EFG2LLH_ACCURACY_MM = 0.00000001 degrees

Definition at line 45 of file geoEfg2Llh.c.

References GEO_ERROR, GEO_OK, and geoAccuracy.

46 {
47  if (acc <= 1.0) // make sure the accuracy is sane
48  {
49  geoAccuracy = acc;
50  return(GEO_OK);
51  }
52  return(GEO_ERROR);
53 }
void geoSetTimeZone ( GEO_LOCATION l,
double  tz,
int  dst 
)

Definition at line 169 of file geoEllips.c.

References GEO_LOCATION::dst, and GEO_LOCATION::timezone.

170 {
171  l->timezone = tz;
172  l->dst = dst;
173 }
int geoSun ( GEO_LOCATION loc,
struct tm *  newtime,
double *  az,
double *  el 
)

Definition at line 98 of file geoSun.c.

References GEO_LOCATION::clat, DEG_TO_RAD, fractionalYearRad(), GEO_OK, GEO_LOCATION::lon, RAD_TO_DEG, GEO_LOCATION::slat, and GEO_LOCATION::timezone.

Referenced by geoSunPosition().

99 {
100  double y,eqtime,decl,time_offset, tst,ha,theta,phi,sdecl;
101 
102 
103  // This Sun position algorithm is from :
104  // http://www.esrl.noaa.gov/gmd/grad/solcalc/solareqns.PDF
105 
106 
107  // First, the fractional year y is calculated, in radians.
108  y = fractionalYearRad(newtime->tm_mon, newtime->tm_mday, newtime->tm_hour);
109 
110  // From y, we can estimate the equation of time (in minutes) and the
111  // solar declination angle (in radians).
112  eqtime = 229.18 * (0.000075 +
113  (0.001868 * cos(y))-
114  (0.032077 * sin(y))-
115  (0.014615 * cos(2.0 * y)) -
116  (0.040849 * sin(2.0 * y)) );
117 
118 
119  decl = 0.006918 -
120  (0.399912* cos(y)) +
121  (0.070257* sin(y)) -
122  (0.006758* cos(2.0 * y)) +
123  (0.000907* sin(2.0 * y)) -
124  (0.002697* cos(3.0 * y)) +
125  (0.00148 * sin(3.0 * y));
126  sdecl = sin(decl);
127 
128  // Next, the true solar time is calculated in the following two equations.
129  // First the time offset is found, in minutes, and then the true solar time, in minutes.
130  time_offset = eqtime - (4.0 * loc->lon) + (60.0 * loc->timezone);
131 
132  // where eqtime is in minutes, longitude is in degrees, timezone is in hours
133  // from UTC (Mountain Standard Time = +7 hours).
134  tst = (newtime->tm_hour * 60.0) + newtime->tm_min + (newtime->tm_sec / 60.0) + time_offset;
135  // where hr is the hour (0 - 23), mn is the minute (0 - 60), sc is the second (0 - 60).
136 
137  // The solar hour angle, in degrees, is:
138  ha = (tst / 4.0) - 180.0;
139 
140  //The solar zenith angle (phi) can then be found from the following equation:
141  phi = acos( (loc->slat * sdecl) + (loc->clat * cos(decl) * cos(ha*DEG_TO_RAD)));
142 
143  // And the solar azimuth (theta), clockwise from north) is:
144  // cos(180-theta) = (loc->slat * cos(phi) - sin(decl)) / (loc->clat * sin(phi))
145  theta = acos(((loc->slat * cos(phi)) - sdecl) / (loc->clat * sin(phi)));
146 
147  *el = 90.0 - (phi*RAD_TO_DEG);
148  *az = theta * RAD_TO_DEG;
149 
150  printf("\nY=%f Eqtime=%f decl=%f\n tOff=%f tst=%f ha=%f tz=%f \n",y,eqtime,decl,time_offset,tst,ha,loc->timezone );
151  printf("Phi=%f, theta=%f\n", phi, theta);
152 
153  return (GEO_OK );
154 }

Here is the call graph for this function:

int geoSunAA ( GEO_LOCATION loc,
struct tm *  newtime,
double *  az,
double *  el 
)

Definition at line 482 of file geoSun.c.

References c, DEG_TO_RAD, JD(), obliquity(), RAD_TO_DEG, and GEO_LOCATION::timezone.

483 {
484  double jd,l0, t,t2,t3,m,m_r, e,c,r,
485  trueLon,trueLon_r,trueLon2k,trueAnom,trueAnom_r,
486  partDay,appLon,appLon_r,oe,oec,oe_r,oec_r,om,om_r,ra,dec;
487  int year;
488 
489  year = newtime->tm_year+1900;
490  partDay = (newtime->tm_hour + (newtime->tm_min/60.0) + (newtime->tm_sec / 3600.0) - loc->timezone)/24.0;
491 
492  // j2000 date
493  jd = JD(year,newtime->tm_mon,newtime->tm_mday);
494  printf("\nJD=%10.5f ",jd+partDay);
495 
496  // j2000 date in centuries
497  t=(jd+partDay- 2451545.0)/36525.0;
498  t2 = t*t;
499  t3= t2*t;
500  printf("T=%2.10f\n",t);
501 
502  // Geometric mean longitude referred to the mean equinox of the date
503  l0 = 280.46645 + (36000.76983 * t) + (0.0003032 * t2);
504  if(l0 < 0.0) l0 = fmod(l0,360.0) + 360.0;
505 
506  // mean anomoly of the Sun
507  m = 357.52910 + (35999.05030 * t) - (0.0001559 * t2) - (0.00000048 * t3);
508  // if(m < 0.0) m = fmod(m,360.0) + 360.0;
509  m_r = m * DEG_TO_RAD;
510 
511  // eccentricity of the Earth's orbit
512  e = 0.016708617 - (0.000042037 * t) - (0.0000001236 * t2);
513 
514  // Sun's equation of center
515  c = (1.914600 - (0.004817 * t) - (0.000014 * t2)) * sin(m_r) +
516  (0.019993 - (0.000101 * t)) * sin(m_r+m_r) +
517  (0.000290 * sin(m_r+m_r+m_r));
518 
519  // Sun true longitude & anomoly
520  trueLon = l0 + c;
521  trueLon_r = trueLon * DEG_TO_RAD;
522  trueAnom = m + c;
523  trueAnom_r= trueAnom * DEG_TO_RAD;
524  trueLon2k = trueLon - (0.01397 * (year - 2000));
525  printf("\nl0= %f m=%f e=%f c=%f trueLon=%f trueAnom=%f\n",l0,m,e,c,trueLon,trueAnom);
526 
527  // radius vector
528  r = (1.000001018 * (1.0-(e*e)))/(1.0 + e *cos(trueAnom_r));
529 
530  // apparent longitude
531  om = 125.04 - 1934.136 * t;
532  om_r = om * DEG_TO_RAD;
533  appLon = trueLon - 0.00569 - (0.00478 * sin(om_r));
534  appLon_r= appLon * DEG_TO_RAD;
535 
536  // obliquity of ecliptic
537  // and corrected value (oec)
538  oe = obliquity(t);
539  oec = oe + 0.00256 * cos(DEG_TO_RAD*(125.04-1934.1136*t)); // corrected
540  oe_r = oe * DEG_TO_RAD;
541  oec_r= oec * DEG_TO_RAD;
542  printf("\nom=%f appLon=%f oe=%f oec=%f r=%f\n",om,appLon,oe,oec,r);
543 
544  ra = atan2(cos(oec_r)*sin(appLon_r), cos(appLon_r))*RAD_TO_DEG;
545  // if(ra < 0.0) ra = fmod(ra,360.0); // + 360.0;
546 
547  dec = asin(sin(oec_r)*sin(appLon_r))*RAD_TO_DEG;
548  printf("\nra=%f, dec=%f\n",ra, dec);
549 
550  //
551  return 1;
552 }

Here is the call graph for this function:

int geoSunAzElJD ( GEO_LOCATION loc,
double *  az,
double *  el,
double  tjd_now 
)

This routine uses a previously determined Julian date and then gets the Az and El of the sun at this location based on the Julian date.

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 147 of file geoAstro.c.

References BODY_SUN, GEO_ERROR, GEO_OK, geoSunError, GEO_LOCATION::hgt, GEO_LOCATION::lat, GEO_LOCATION::lon, MAJOR_PLANET, and REDUCED_ACC.

Referenced by geoSunAzEltm().

148 {
149  on_surface geo_loc;
150  cat_entry dummy_star;
151  object sun;
152  double deltat = 60.0; // 'deltat' is the difference in time scales, TT - UT1.
153  double ra, dec, dis;
154  double rar,decr;
155  // int error;
156 
157  /* Convert geo library info into Novas info */
158  // geo_loc.latitude = loc->lat;
159  // geo_loc.longitude = loc->lon;
160  // geo_loc.height = loc->hgt;
161  // geo_loc.temperature = 30.0; // degrees celcius
162  // geo_loc.pressure = 1000.0; // pressure in millibars
163  make_on_surface(loc->lat, loc->lon, loc->hgt, 30.0, 1000.0, &geo_loc);
164 
165 
166  /* Set the planetary bodies to be worked with */
167  /*geoSunError = set_body (MAJOR_PLANET,BODY_EARTH,"Earth", &earth);
168  if(geoSunError)
169  {
170  // printf ("Error %d from set_body.\n", geoSunError);
171  return(GEO_ERROR);
172  }
173 */
174 
175  geoSunError = make_object (MAJOR_PLANET,BODY_SUN,"Sun",&dummy_star, &sun);
176  if(geoSunError)
177  {
178  //printf ("Error %d from make_object.\n", geoSunError);
179  return(GEO_ERROR);
180  }
181 
182  /* Compute the Sun's position */
183  // geoSunError = topo_planet (tjd_now,&sun,&earth,deltat,&geo_loc, &ra,&dec,&dis);
184  geoSunError = topo_planet (tjd_now,&sun,deltat,&geo_loc, REDUCED_ACC, &ra,&dec,&dis);
185  if(geoSunError)
186  {
187  // printf ("Error %d from topo_planet.\n", geoSunError);
188  return(GEO_ERROR);
189  }
190 
191  /* Convert to Azimuth and Elevation */
192  equ2hor(tjd_now,deltat,REDUCED_ACC,0,0,&geo_loc,ra,dec,0,el,az,&rar,&decr);
193  *el = 90.0 - *el; // correct elevation from zenith
194 
195  return(GEO_OK);
196 }
int geoSunAzElNow ( GEO_LOCATION loc,
double *  az,
double *  el 
)

this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 31 of file geoAstro.c.

References geoSunAzEltm().

Referenced by geoSunNowAz(), and geoSunNowEl().

32 {
33  struct tm *newtime;
34  long ltime=0L;
35 
36  /* Obtain coordinated universal time: */
37  time( &ltime );
38  newtime = gmtime( &ltime );
39 
40  return ( geoSunAzEltm(loc, az, el, newtime) );
41 }

Here is the call graph for this function:

int geoSunAzEltm ( GEO_LOCATION loc,
double *  az,
double *  el,
struct tm *  newtime 
)

this routine ingests an ANSI C time structure and then gets the az and el of the sun at this location based on this time.

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 98 of file geoAstro.c.

References geoSunAzElJD(), and tError.

Referenced by geoSunAzElNow().

99 {
100  /* Obtain coordinated universal time: */
101  double tjd_now;
102 
103  tError.tm_year=newtime->tm_year;
104  tError.tm_mon=newtime->tm_mon;
105  tError.tm_mday=newtime->tm_mday;
106 
107  tjd_now = julian_date((short)(newtime->tm_year+1900),
108  (short)(newtime->tm_mon+1),
109  (short)newtime->tm_mday,
110  newtime->tm_hour + (newtime->tm_min/60.0)+(newtime->tm_sec/3600.0));
111 
112  return ( geoSunAzElJD(loc, az, el,tjd_now) );
113 }

Here is the call graph for this function:

int geoSunM ( GEO_LOCATION loc,
struct tm *  newtime,
double *  az,
double *  el 
)

Definition at line 158 of file geoSun.c.

References GEO_LOCATION::clat, DEG_TO_RAD, GEO_LOCATION::dst, GEO_OK, JD(), jday(), GEO_LOCATION::lon, M_PI, RAD_TO_DEG, GEO_LOCATION::slat, GEO_LOCATION::timezone, and TWO_PI.

159 {
160 /*
161 From
162 ftp://climate1.gsfc.nasa.gov/wiscombe/Solar_Rad/SunAngles/sunae.f
163 
164 
165 c Calculates the local solar azimuth and elevation angles, and
166 c the distance to and angle subtended by the Sun, at a specific
167 c location and time using approximate formulas in The Astronomical
168 c Almanac. Accuracy of angles is 0.01 deg or better (the angular
169 c width of the Sun is about 0.5 deg, so 0.01 deg is more than
170 c sufficient for most applications).
171 
172 c Unlike many GCM (and other) sun angle routines, this
173 c one gives slightly different sun angles depending on
174 c the year. The difference is usually down in the 4th
175 c significant digit but can slowly creep up to the 3rd
176 c significant digit after several decades to a century.
177 
178 c A refraction correction appropriate for the "US Standard
179 c Atmosphere" is added, so that the returned sun position is
180 c the APPARENT one. The correction is below 0.1 deg for solar
181 c elevations above 9 deg. To remove it, comment out the code
182 c block where variable REFRAC is set, and replace it with
183 c REFRAC = 0.0.
184 
185 c References:
186 
187 c Michalsky, J., 1988: The Astronomical Almanac's algorithm for
188 c approximate solar position (1950-2050), Solar Energy 40,
189 c 227-235 (but the version of this program in the Appendix
190 c contains errors and should not be used)
191 
192 c The Astronomical Almanac, U.S. Gov't Printing Office, Washington,
193 c D.C. (published every year): the formulas used from the 1995
194 c version are as follows:
195 c p. A12: approximation to sunrise/set times
196 c p. B61: solar elevation ("altitude") and azimuth
197 c p. B62: refraction correction
198 c p. C24: mean longitude, mean anomaly, ecliptic longitude,
199 c obliquity of ecliptic, right ascension, declination,
200 c Earth-Sun distance, angular diameter of Sun
201 c p. L2: Greenwich mean sidereal time (ignoring T^2, T^3 terms)
202 
203 
204 c Authors: Dr. Joe Michalsky (joe@asrc.albany.edu)
205 c Dr. Lee Harrison (lee@asrc.albany.edu)
206 c Atmospheric Sciences Research Center
207 c State University of New York
208 c Albany, New York
209 
210 c Modified by: Dr. Warren Wiscombe (wiscombe@climate.gsfc.nasa.gov)
211 c NASA Goddard Space Flight Center
212 c Code 913
213 c Greenbelt, MD 20771
214 
215 
216 c WARNING: Do not use this routine outside the year range
217 c 1950-2050. The approximations become increasingly
218 c worse, and the calculation of Julian date becomes
219 c more involved.
220 
221 
222  SUBROUTINE SUNAE( YEAR, DAY, HOUR, LAT, LONG,
223  & AZ, EL, SOLDIA, SOLDST )
224 
225 
226  c Input:
227  c YEAR year (INTEGER; range 1950 to 2050)
228  c DAY day of year at LAT-LONG location (INTEGER; range 1-366)
229  c HOUR hour of DAY [GMT or UT] (REAL; range -13.0 to 36.0)
230  c = (local hour) + (time zone number)
231  c + (Daylight Savings Time correction; -1 or 0)
232  C where (local hour) range is 0 to 24,
233  c (time zone number) range is -12 to +12, and
234  c (Daylight Time correction) is -1 if on Daylight Time
235  c (summer half of year), 0 otherwise;
236  c Example: 8:30 am Eastern Daylight Time would be
237  c
238  c HOUR = 8.5 + 5 - 1 = 12.5
239  c LAT latitude [degrees]
240  c (REAL; range -90.0 to 90.0; north is positive)
241  c LONG longitude [degrees]
242  c (REAL; range -180.0 to 180.0; east is positive)
243  c Output:
244  c AZ solar azimuth angle (measured east from north,
245  c 0 to 360 degs)
246  c EL solar elevation angle [-90 to 90 degs];
247  c solar zenith angle = 90 - EL
248  c SOLDIA solar diameter [degs]
249  c SOLDST distance to sun [Astronomical Units, AU]
250  c (1 AU = mean Earth-sun distance = 1.49597871E+11 m
251  c in IAU 1976 System of Astronomical Constants)
252  c Local Variables:
253  c DEC Declination (radians)
254  c ECLONG Ecliptic longitude (radians)
255  c GMST Greenwich mean sidereal time (hours)
256  c HA Hour angle (radians, -pi to pi)
257  c JD Modified Julian date (number of days, including
258  c fractions thereof, from Julian year J2000.0);
259  c actual Julian date is JD + 2451545.0
260  c LMST Local mean sidereal time (radians)
261  c MNANOM Mean anomaly (radians, normalized to 0 to 2*pi)
262  c MNLONG Mean longitude of Sun, corrected for aberration
263  c (deg; normalized to 0-360)
264  c OBLQEC Obliquity of the ecliptic (radians)
265  c RA Right ascension (radians)
266  c REFRAC Refraction correction for US Standard Atmosphere (degs)
267  c --------------------------------------------------------------------
268  */
269 
270  //c .. Scalar Arguments ..
271 
272  int YEAR, DAY;
273  double AZ, EL, AZr, ELr, HOUR, SOLDIA, SOLDST;
274  //c ..
275  //c .. Local Scalars ..
276 
277  int DELTA, LEAP;
278  double DEC, DEN, ECLONG, GMST, HA, JD, LMST,
279  MNANOM, MNLONG, NUM, OBLQEC, RA,
280  REFRAC=0.0, TIME;
281  //c ..
282 
283 /*
284  if( YEAR < 1950 .OR. YEAR.GT.2050 )
285  & STOP 'SUNAE--bad input variable YEAR'
286  if( DAY < 1 .OR. DAY.GT.366 )
287  & STOP 'SUNAE--bad input variable DAY'
288  if( HOUR < -13.0 .OR. HOUR.GT.36.0 )
289  & STOP 'SUNAE--bad input variable HOUR'
290  if( LAT < -90.0 .OR. LAT.GT.90.0 )
291  & STOP 'SUNAE--bad input variable LAT'
292  if( LONG < -180.0 .OR. LONG.GT.180.0 )
293  & STOP 'SUNAE--bad input variable LONG'
294 
295  if(PASS1) THEN
296  PI = 2.*A sin( 1.0 )
297  TWOPI = 2.*PI
298  RPD = PI / 180.
299  PASS1 = .False.
300  ENDIF
301  */
302  YEAR = newtime->tm_year+1900;
303  DAY = jday(newtime->tm_mon, newtime->tm_mday);
304  HOUR = newtime->tm_hour + (newtime->tm_min/60.0) + (newtime->tm_sec/3600.0) + loc->timezone - loc->dst;
305 
306  printf("Hour=%f\n",HOUR);
307 
308  // ** current Julian date (actually add 2,400,000
309  // ** for true JD); LEAP = leap days since 1949;
310  // ** 32916.5 is midnite 0 jan 1949 minus 2.4e6
311  DELTA = YEAR - 1949;
312  LEAP = DELTA / 4;
313  JD = 32916.5 + ((DELTA * 365.0) + LEAP + DAY) + HOUR / 24.0 +1;
314 
315  // ** last yr of century not leap yr unless divisible
316  // ** by 400 (not executed for the allowed YEAR range,
317  // ** but left in so our successors can adapt this for
318  // ** the following 100 years)
319 
320  if( ( ( YEAR % 100 ) == 0) && (( YEAR % 400 ) != 0) ) JD = JD - 1.0;
321 
322  // ** ecliptic coordinates
323  // ** 51545.0 + 2.4e6 = noon 1 jan 2000
324  TIME = JD - 51545.0;
325 
326  printf("JD=%f TIME=%f\n",JD,TIME);
327 
328  // ** force mean longitude between 0 and 360 degs
329  MNLONG = 280.460 + 0.9856474 * TIME;
330  MNLONG = fmod( MNLONG, 360.0 );
331  if( MNLONG < 0.0 ) MNLONG = MNLONG + 360.0;
332 
333  // ** mean anomaly in radians between 0 and 2*pi
334  MNANOM = 357.528 + 0.9856003 * TIME;
335  MNANOM = fmod( MNANOM, 360.0 );
336  if( MNANOM < 0.0) MNANOM = MNANOM + 360.0;
337  printf("Mean Long=%f Mean Anom=%f\n",MNLONG,MNANOM);
338 
339  MNANOM = MNANOM * DEG_TO_RAD; //radians
340 
341  // ** ecliptic longitude and obliquity
342  // ** of ecliptic in radians
343  ECLONG = MNLONG + 1.915 * sin( MNANOM ) + 0.020 * sin( 2.0 * MNANOM );
344  ECLONG = fmod( ECLONG, 360.0 );
345  if( ECLONG < 0.0 ) ECLONG = ECLONG + 360.0;
346 
347  OBLQEC = 23.439 - 0.0000004 * TIME;
348  ECLONG = ECLONG * DEG_TO_RAD;
349  OBLQEC = OBLQEC * DEG_TO_RAD;
350  printf("Ecc Long=%f Obliq=%f\n",ECLONG*RAD_TO_DEG,OBLQEC*RAD_TO_DEG);
351 
352  // ** right ascension
353  NUM = cos( OBLQEC )* sin( ECLONG );
354  DEN = cos( ECLONG );
355  RA = atan2( NUM , DEN );
356  printf("RA-raw = %f num=%f, den=%f\n",RA*RAD_TO_DEG,NUM,DEN);
357 
358 
359  // ** Force right ascension between 0 and 2*pi
360  if( DEN < 0.0 ) RA = RA + M_PI;
361  else if( NUM < 0.0 ) RA = RA + TWO_PI;
362 
363  printf("RA = %f ",RA*RAD_TO_DEG);
364 
365  // ** declination
366  DEC = asin( sin(OBLQEC) * sin(ECLONG) );
367 
368  printf("DEC = %f \n",DEC*RAD_TO_DEG);
369 
370  // ** Greenwich mean sidereal time in hours
371  GMST = 6.697375 + 0.0657098242*TIME + HOUR;
372 
373  // ** Hour not changed to sidereal time since
374  // ** 'time' includes the fractional day
375  GMST = fmod( GMST, 24.0 );
376  if( GMST < 0.0 ) GMST = GMST + 24.0;
377 
378  // ** local mean sidereal time in radians
379  LMST = GMST + loc->lon / 15.0;
380  LMST = fmod( LMST, 24.0 );
381  if( LMST < 0.0 ) LMST = LMST + 24.0;
382 
383  LMST = LMST*15.0 * DEG_TO_RAD;
384 
385  // ** hour angle in radians between -pi and pi
386  HA = LMST - RA;
387 
388  if( HA < -M_PI ) HA = HA + TWO_PI;
389  if( HA > M_PI ) HA = HA - TWO_PI;
390 
391  printf("HA=%f deg\n",HA*RAD_TO_DEG);
392  //HA = -7.99 * DEG_TO_RAD;
393 
394 
395  // ** solar azimuth and elevation (radians)
396  ELr = asin( sin( DEC )* loc->slat +
397  cos( DEC )* loc->clat * cos( HA ) );
398 
399  // AZr = asin( -cos( DEC )* sin( HA ) / cos( ELr ) );
400  AZr = atan( sin( HA ) / ((cos( HA ) * loc->slat) - (tan(DEC) * loc->clat)) );
401  printf("raw az=%f DECL = %f\n",AZr*RAD_TO_DEG, DEC*RAD_TO_DEG);
402 
403  // ** Put azimuth between 0 and 2*pi radians
404  if( sin( DEC ) - sin( ELr ) * loc->slat >= 0.0 )
405  {
406 
407  if( sin(AZr) < 0.0) AZr = AZr + TWO_PI;
408  else AZr = M_PI - AZr;
409 
410  }
411 
412  // ** Convert elevation and azimuth to degrees
413  EL = ELr * RAD_TO_DEG;
414  AZ = AZr * RAD_TO_DEG;
415 
416  // ======== Refraction correction for U.S. Standard Atmos. ==========
417  // (assumes elevation in degs) (3.51823=1013.25 mb/288 K)
418  if( EL >= 19.225 ) REFRAC = 0.00452 * 3.51823 / tan( ELr );
419  else
420  {
421  if( (EL > -0.766) && (EL < 19.225) )
422  REFRAC = 3.51823 * ( 0.1594 + EL*(0.0196 + 0.00002*EL) ) /
423  ( 1.0 + EL * (0.505 + 0.0845 * EL) );
424  else if( EL <= -0.766 ) REFRAC = 0.0;
425  }
426  printf("Refrac = %f deg\n",REFRAC);
427  EL = EL + REFRAC;
428 
429  // ===================================================================
430  // ** distance to sun in A.U. & diameter in degs
431 
432  SOLDST = 1.00014 - 0.01671 * cos(MNANOM) - 0.00014 * cos( 2.0 *MNANOM );
433  SOLDIA = 0.5332 / SOLDST;
434 
435  if( EL < -90.0 || EL > 90.0 ) printf("SUNAE--output argument EL out of range(%f)\n",EL);
436  if( AZ < 0.0 || AZ > 360.0 ) printf("SUNAE--output argument AZ out of range(%f)\n",AZ);
437 
438  *az = AZ;
439  *el = EL;
440 
441  return(GEO_OK);
442 }

Here is the call graph for this function:

double geoSunNowAz ( double  lat,
double  lon,
double  hgt 
)

this routine uses the location and current time to get the azimuth of the sun at this location

Parameters
doublelat : Latitude in degrees
doublelon : Longitude in degrees
doublehgt : Height in meters
Return values
double: Azimuth in decimal degrees

Definition at line 75 of file geoAstro.c.

References GEO_DATUM_DEFAULT, geoInitLocation(), and geoSunAzElNow().

76 {
77  GEO_LOCATION loc;
78  double az,el;
79 
80  geoInitLocation(&loc, lat, lon, hgt, GEO_DATUM_DEFAULT, "now");
81  geoSunAzElNow(&loc, &az, &el);
82  return(az);
83 }

Here is the call graph for this function:

double geoSunNowEl ( double  lat,
double  lon,
double  hgt 
)

this routine uses the location and current time to get the elevation of the sun at this location

Parameters
doublelat : Latitude in degrees
doublelon : Longitude in degrees
doublehgt : Height in meters
Return values
double: Elevation in decimal degrees

Definition at line 54 of file geoAstro.c.

References GEO_DATUM_DEFAULT, geoInitLocation(), and geoSunAzElNow().

55 {
56  GEO_LOCATION loc;
57  double az,el;
58 
59  geoInitLocation(&loc, lat, lon, hgt, GEO_DATUM_DEFAULT, "now");
60  geoSunAzElNow(&loc, &az, &el);
61  return(el);
62 }

Here is the call graph for this function:

int geoSunPosition ( GEO_LOCATION loc,
double *  az,
double *  el 
)

this routine uses ANSI C time routines to obtain the current time and then get the az and el of the sun at this location

Parameters
GEO_LOCATION*loc : Location structure
double*az : Azimuth in decimal degrees
double*el : Elevation in decimal degrees
Return values
GEO_OKon success
GEO_ERRORon error

Definition at line 84 of file geoSun.c.

References GEO_OK, and geoSun().

85 {
86  struct tm *newtime;
87  long ltime=0L;
88 
89 
90  /* Obtain time: */
91  time( &ltime );
92  newtime = gmtime( &ltime );
93 
94  geoSun(loc,newtime,az,el);
95  return (GEO_OK );
96 }

Here is the call graph for this function:

double geoVersion ( void  )

This function returns the version of the GeoStarsLib.

Return values
GEOSTARSLIB_VERSIONas a double

Definition at line 25 of file geoPoint.c.

References GEOSTARSLIB_VERSION.

26 {
27  return(GEOSTARSLIB_VERSION);
28 }
double geoXyz2A ( double  x,
double  y,
double  z 
)

Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the azimuth to that point.

Notes:

  • X is understood to be the east-west displacement of the point, with east being the positive direction.
  • Y is the north-south displacement, with north being positive.
  • Z is the vertical displacement of the point.
  • Azimuth is in decimal degrees
Parameters
doublexyz_in[]
Returns
double azimuth

Definition at line 455 of file geoPoint.c.

References GEO_AZ, geoXyz2Rae(), and RAD_TO_DEG.

456 {
457  double rae[3],xyz[3];
458  xyz[0]=x;
459  xyz[1]=y;
460  xyz[2]=z;
461  geoXyz2Rae(xyz,rae);
462  return(rae[GEO_AZ]*RAD_TO_DEG);
463 }

Here is the call graph for this function:

double geoXyz2E ( double  x,
double  y,
double  z 
)

Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the elevation angle to that point.

Notes:

  • X is understood to be the east-west displacement of the point, with east being the positive direction.
  • Y is the north-south displacement, with north being positive.
  • Z is the vertical displacement of the point.
  • Elevation is in decimal degrees
Parameters
doublexyz_in[]
Returns
double elevation

Definition at line 482 of file geoPoint.c.

References GEO_EL, geoXyz2Rae(), and RAD_TO_DEG.

483 {
484  double rae[3],xyz[3];
485  xyz[0]=x;
486  xyz[1]=y;
487  xyz[2]=z;
488  geoXyz2Rae(xyz,rae);
489  return(rae[GEO_EL]*RAD_TO_DEG);
490 }

Here is the call graph for this function:

void geoXyz2Efg ( GEO_LOCATION loc,
double  xyz_in[],
double  efg_out[] 
)

Ingests X, Y, Z, and site info and returns the EFG coordinates.

Parameters
GEO_LOCATION*loc
doublexyz_in[]
doubleefg_out[]
Returns
nothing

Definition at line 570 of file geoPoint.c.

References GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::e, GEO_LOCATION::f, GEO_LOCATION::g, GEO_E, GEO_F, GEO_G, GEO_X, GEO_Y, GEO_Z, GEO_LOCATION::slat, and GEO_LOCATION::slon.

573 {
574  double c1, c2, c3;
575 
576  /* Do the matrix multiplication: */
577 
578  c1 = -loc->slon * xyz_in[GEO_X] +
579  -loc->clon * loc->slat * xyz_in[GEO_Y] +
580  loc->clon * loc->clat * xyz_in[GEO_Z];
581 
582  c2 = loc->clon * xyz_in[GEO_X] +
583  -loc->slon * loc->slat * xyz_in[GEO_Y] +
584  loc->slon * loc->clat * xyz_in[GEO_Z];
585 
586  c3 = loc->clat * xyz_in[GEO_Y] +
587  loc->slat * xyz_in[GEO_Z];
588 
589  /* Add resultant matrix to local EFG to get remote EFG: */
590  efg_out[GEO_E] = c1 + loc->e;
591  efg_out[GEO_F] = c2 + loc->f;
592  efg_out[GEO_G] = c3 + loc->g;
593 
594 } /* End procedure aer_to_efg */
void geoXyz2Efg_packed ( GEO_LOCATION loc,
int  count,
double  xyz_efg[] 
)

This routine takes site info and iterates over count vertices in the tightly packed array xyz_efg converting it from cartesian XYZ into geocentric EFG coordinates.

Parameters
locThe location that the XYZ grid is based around
countThe number of vertices in the array
xyz_efg[]Pointer to the first vertex of the array
Returns
nothing

Definition at line 606 of file geoPoint.c.

References GEO_LOCATION::clat, GEO_LOCATION::clon, GEO_LOCATION::e, GEO_LOCATION::f, GEO_LOCATION::g, GEO_E, GEO_F, GEO_G, GEO_X, GEO_Y, GEO_Z, GEO_LOCATION::slat, and GEO_LOCATION::slon.

609 {
610  double c1, c2, c3;
611  double nclonslat = -loc->clon * loc->slat;
612  double clonclat = loc->clon * loc->clat;
613  double nslonslat = -loc->slon * loc->slat;
614  double slonclat = loc->slon * loc->clat;
615  double* vector;
616 
617  // calculate end
618  double* vend = xyz_efg + (3 * count);
619 
620  /* Convert all the sets. */
621  for (vector = xyz_efg; vector < vend; vector += 3)
622  {
623  /* Do the matrix multiplication: */
624  c1 = -loc->slon * vector[GEO_X] +
625  nclonslat * vector[GEO_Y] +
626  clonclat * vector[GEO_Z];
627 
628  c2 = loc->clon * vector[GEO_X] +
629  nslonslat * vector[GEO_Y] +
630  slonclat * vector[GEO_Z];
631 
632  c3 = loc->clat * vector[GEO_Y] +
633  loc->slat * vector[GEO_Z];
634 
635  /* Add resultant matrix to local EFG to get remote EFG: */
636  vector[GEO_E] = c1 + loc->e;
637  vector[GEO_F] = c2 + loc->f;
638  vector[GEO_G] = c3 + loc->g;
639  }
640 
641 } /* End procedure xyz_to_efg */
double geoXyz2R ( double  x,
double  y,
double  z 
)

Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2R calculates the range to that point.

Notes:

  • X is understood to be the east-west displacement of the point, with east being the positive direction.
  • Y is the north-south displacement, with north being positive.
  • Z is the vertical displacement of the point.
  • Range is in meters.
Parameters
doublexyz_in[]
Returns
double range

Definition at line 428 of file geoPoint.c.

References GEO_RNG, and geoXyz2Rae().

429 {
430  double rae[3],xyz[3];
431  xyz[0]=x;
432  xyz[1]=y;
433  xyz[2]=z;
434  geoXyz2Rae(xyz,rae);
435  return(rae[GEO_RNG]);
436 }

Here is the call graph for this function:

void geoXyz2Rae ( double  xyz_in[],
double  rae_out[] 
)

Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2Rae calculates the range, azimuth, and elevation to that point.

Notes:

  • X is understood to be the east-west displacement of the point, with east being the positive direction.
  • Y is the north-south displacement, with north being positive.
  • Z is the vertical displacement of the point.
  • Range is in meters. Azimuth and elevation are in radians
Parameters
doublexyz_in[]
doublerae_out[]
Returns
nothing

Definition at line 339 of file geoPoint.c.

References GEO_AZ, GEO_EL, GEO_RNG, GEO_X, GEO_Y, GEO_Z, and M_PI.

Referenced by geoXyz2A(), geoXyz2E(), and geoXyz2R().

341 {
342  double horz_dist;
343 
344  /* Determine the range: */
345  rae_out[GEO_RNG] =
346  sqrt(pow(xyz_in[GEO_X],2.0) + pow(xyz_in[GEO_Y],2.0) + pow(xyz_in[GEO_Z],2.0));
347 
348  /* Determine the azimuth: */
349  rae_out[GEO_AZ] = atan2(xyz_in[GEO_X], xyz_in[GEO_Y]);
350  //if((xyz_in[GEO_X] >= 0.0) && (xyz_in[GEO_Y] < 0.0)) rae_out[GEO_AZ] += M_PI;
351  if((xyz_in[GEO_X] < 0.0) && (xyz_in[GEO_Y] < 0.0)) rae_out[GEO_AZ] += (2.0 * M_PI);
352  if((xyz_in[GEO_X] < 0.0) && (xyz_in[GEO_Y] > 0.0)) rae_out[GEO_AZ] += (2.0 * M_PI);
353 
354  /* Determine the elevation: */
355  horz_dist = sqrt(pow(xyz_in[GEO_X],2.0) + pow(xyz_in[GEO_Y],2.0));
356  rae_out[GEO_EL] = atan2(xyz_in[GEO_Z], horz_dist);
357  if(rae_out[GEO_EL] < 0.0) rae_out[GEO_EL] += (2.0 * M_PI);
358 
359 } /* End procedure xyz_to_rae */
void geoXyz2Rae_packed ( int  count,
double  xyz_rae[] 
)

Given the X, Y, and Z coordinates (in meters) of a point in space, the procedure geoXyz2Rae calculates the range, azimuth, and elevation to that point.

Notes:

  • X is understood to be the east-west displacement of the point, with east being the positive direction.
  • Y is the north-south displacement, with north being positive.
  • Z is the vertical displacement of the point.
  • Range is in meters. Azimuth and elevation are in radians
    Parameters
    countNumber of vertices
    xyz_rae[]Pointer to the first coordinate of the first vertex of the array.
    Returns
    nothing

Definition at line 378 of file geoPoint.c.

References GEO_AZ, GEO_EL, GEO_RNG, GEO_X, GEO_Y, GEO_Z, and M_PI.

380 {
381  double horz_dist;
382  double rng, az;
383  double* vector;
384 
385  // calculate end
386  double* vend = xyz_rae + (3 * count);
387 
388  /* Convert all the sets. */
389  for (vector = xyz_rae; vector < vend; vector += 3)
390  {
391  /* Determine the range: */
392  rng =
393  sqrt(vector[GEO_X]*vector[GEO_X] + vector[GEO_Y]*vector[GEO_Y] + vector[GEO_Z]*vector[GEO_Z]);
394 
395  /* Determine the azimuth: */
396  az = atan2(vector[GEO_X], vector[GEO_Y]);
397 
398  //if((vector[GEO_X] < 0.0) && (vector[GEO_Y] < 0.0)) az += (2.0 * M_PI);
399  //if((vector[GEO_X] < 0.0) && (vector[GEO_Y] > 0.0)) az += (2.0 * M_PI);
400  if (az < -0.0f) az += (2.0 * M_PI);
401 
402  /* Determine the elevation: */
403  horz_dist = sqrt(vector[GEO_X]*vector[GEO_X] + vector[GEO_Y]*vector[GEO_Y]);
404  vector[GEO_RNG] = rng;
405  vector[GEO_AZ] = az;
406  vector[GEO_EL] = atan2(vector[GEO_Z], horz_dist);
407  if(vector[GEO_EL] < -0.0f) vector[GEO_EL] += (2.0 * M_PI);
408  }
409 } /* End procedure xyz_to_rae */

Variable Documentation

GEO_ELLIPSOID ellips[]

This structure array contains the all of the ellipsoids used in this library.

Definition at line 46 of file geoEllips.c.

Referenced by geomg1().

double geoAccuracy
int geoSunError

Definition at line 15 of file geoAstro.c.

Referenced by geoGetSunError(), and geoSunAzElJD().