|  |  |  | Grits Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
#define EARTH_C #define EARTH_R #define EAST #define FOV_DIST struct GritsBounds; struct GritsPoint; #define MPPX (dist) #define NORTH #define SOUTH #define WEST #define azim2lon (azim) void crossd (gdouble *a,gdouble *b,gdouble *out); void crossd3 (gdouble *a,gdouble *b,gdouble *c,gdouble *out); #define deg2rad (deg) gdouble distd (gdouble *a,gdouble *b); #define elev2rad (elev) void free_points (GritsPoints *points); void grits_bounds_set_bounds (GritsBounds *bounds,gdouble n,gdouble s,gdouble e,gdouble w); void grits_point_set_lle (GritsPoint *point,gdouble lat,gdouble lon,gdouble elev); #define incl2lat (incl) #define lat2incl (lat) gdouble lengthd (gdouble *a); gdouble ll2m (gdouble lon_dist,gdouble lat); void lle2xyz (gdouble lat,gdouble lon,gdouble elev,gdouble *x,gdouble *y,gdouble *z); #define lon2azim (lon) gdouble lon_avg (gdouble a,gdouble b); void normd (gdouble *a); GritsPoints * parse_points (const gchar *string,const gchar *group_sep,const gchar *point_sep,const gchar *coord_sep,GritsBounds *bounds,GritsPoint *center); #define rad2deg (rad) #define rad2elev (rad) void xyz2ll (gdouble x,gdouble y,gdouble z,gdouble *lat,gdouble *lon); void xyz2lle (gdouble x,gdouble y,gdouble z,gdouble *lat,gdouble *lon,gdouble *elev);
Miscellaneous utility functions, these deal mostly with coordinate conversion. Below are some examples that should help demonstrate how these functions work.
Example 1. Terminology
deg - Degrees rad - Radians, also radius m - Meters, for earth-based distances px - Pixels, for screen-based distances height - Height, the distance above the geoid (ground) elev - Elevation, the distance above the spheroid rad - Radius, the distance from the center of the earth lat - Latitude, amount north-south, -90 (S) .. 90 (N) lon - Longitude, amount east-west, -180 (W) .. 180 (E) incl - Inclination, polar equiv of latitude, Pi .. 0 azim - Azimuth, polar equiv of longitude, -Pi .. Pi x - 0° lon is positive y - 90° lon is positive z - North pole is positive llh - lat,lon,height lle - lat,lon,elev llr - lat,lon,rad pol - incl,azim,rad xyz - x,y,z
Example 2. Conversions
            lat    lon   elev ->      x      y      z
lle2xyz:    0.0,   0.0,   0.0 ->    0.0,   0.0,  10.0
lle2xyz:   90.0,   0.0,   0.0 ->    0.0,  10.0,   0.0
lle2xyz:    0.0,  90.0,   0.0 ->   10.0,   0.0,   0.0
              x      y      z ->    lat    lon   elev
xyz2lle:   10.0,   0.0,   0.0 ->    0.0,  90.0,   0.0
xyz2lle:    0.0,  10.0,   0.0 ->   90.0,   0.0,   0.0
xyz2lle:    0.0,   0.0,  10.0 ->    0.0,   0.0,   0.0
#define MPPX(dist) (dist/FOV_DIST)
Get the resolution that a point would be drawn at on the screen
| 
 | the distance between the eye and the point in question | 
| Returns : | the resolution in meters per pixel | 
#define azim2lon(azim) ((azim)*180/G_PI)
Convert azimuth to longitude
| 
 | the azimuth in radians | 
| Returns : | the longitude | 
void crossd (gdouble *a,gdouble *b,gdouble *out);
Calculate the cross product of two vectors
| 
 | the first vector | 
| 
 | the second vector | 
void crossd3 (gdouble *a,gdouble *b,gdouble *c,gdouble *out);
Calculate the cross product of three points
| 
 | the left point | 
| 
 | the center point | 
| 
 | the right point | 
| 
 | the cross product | 
#define deg2rad(deg) (((deg)*G_PI)/180.0)
Convert degrees to radians
| 
 | the angle in degrees | 
| Returns : | the angle in radians | 
gdouble distd (gdouble *a,gdouble *b);
Calculate the distance between two three dimensional points.
| 
 | the first point | 
| 
 | the second point | 
| Returns : | the distance between the points | 
#define elev2rad(elev) ((elev)+EARTH_R)
Convert elevation to radius
| 
 | the elevation in meters above the earth surface | 
| Returns : | the radius in meters | 
void                free_points                         (GritsPoints *points);
Frees all data allocated by parse_points
| 
 | Array of points allocated by parse_points() | 
void grits_bounds_set_bounds (GritsBounds *bounds,gdouble n,gdouble s,gdouble e,gdouble w);
Set the north, south, east, and west edges of the bounding box
| 
 | the north edge | 
| 
 | the south edge | 
| 
 | the east edge | 
| 
 | the west edge | 
void grits_point_set_lle (GritsPoint *point,gdouble lat,gdouble lon,gdouble elev);
Set the latitude, longitude, and elevation for a point.
| 
 | the point to modify | 
| 
 | the new latitude | 
| 
 | the new longitude | 
| 
 | the new elevation | 
#define incl2lat(incl) (90-(incl)*180/G_PI)
Convert inclination to latitude
| 
 | the inclination in radians | 
| Returns : | the latitude | 
#define lat2incl(lat) ((90-(lat))*G_PI/180)
Convert latitude to inclination
| 
 | the latitude | 
| Returns : | the inclination in radians | 
gdouble             lengthd                             (gdouble *a);
Calculate the length (magnitude) of a vector.
| 
 | the vector | 
| Returns : | the length | 
gdouble ll2m (gdouble lon_dist,gdouble lat);
Calculate the distance of longitudinal span at a particular latitude.
| 
 | the distance in degrees of longitude | 
| 
 | the latitude to calculate at | 
| Returns : | the distance in meters | 
void lle2xyz (gdouble lat,gdouble lon,gdouble elev,gdouble *x,gdouble *y,gdouble *z);
Convert a point from latitude, longitude, and elevation to x, y and z coordinates.
| 
 | the latitude | 
| 
 | the longitude | 
| 
 | the elevation | 
| 
 | the resulting x coordinate | 
| 
 | the resulting y coordinate | 
| 
 | the resulting z coordinate | 
#define lon2azim(lon) ((lon)*G_PI/180)
Convert longitude to azimuth
| 
 | the longitude | 
| Returns : | the azimuth in radians | 
gdouble lon_avg (gdouble a,gdouble b);
Calculate the average longitude between two longitudes. This is smart about which side of the globe the resulting longitude is placed on.
| 
 | the first longitude | 
| 
 | the second longitude | 
| Returns : | the average | 
GritsPoints * parse_points (const gchar *string,const gchar *group_sep,const gchar *point_sep,const gchar *coord_sep,GritsBounds *bounds,GritsPoint *center);
Parse a string of the form:
  string -> group [group_sep group] ...
  group  -> point [point_sep point] ...
  point  -> latitude coord_sep longitude [coord_sep elevation]
For example parse_points("30,-80 30,-120 50,-120 50,-80", "\t", " ", ",");
| 
 | String representation of the points | 
| 
 | Group separator | 
| 
 | Point separator | 
| 
 | Coordinate separator | 
| 
 | The bounding box of all the points, or NULL | 
| 
 | The center of the bounds, or NULL | 
| Returns : | zero-terminated array of groups of points | 
#define rad2deg(rad) (((rad)*180.0)/G_PI)
Convert radians to degrees
| 
 | the angle in radians | 
| Returns : | the angle in degrees | 
#define rad2elev(rad) ((rad)-EARTH_R)
Convert radius to elevation
| 
 | the radius in meters | 
| Returns : | the elevation in meters above the earth surface | 
void xyz2ll (gdouble x,gdouble y,gdouble z,gdouble *lat,gdouble *lon);
Get the latitude and longitude for a x, y, z value.
| 
 | the x coordinate | 
| 
 | the y coordinate | 
| 
 | the z coordinate | 
| 
 | the resulting latitude | 
| 
 | the resulting longitude | 
void xyz2lle (gdouble x,gdouble y,gdouble z,gdouble *lat,gdouble *lon,gdouble *elev);
Convert a point from x, y and z coordinates to latitude, longitude, and elevation.
| 
 | the x coordinate | 
| 
 | the y coordinate | 
| 
 | the z coordinate | 
| 
 | the resulting latitude | 
| 
 | the resulting longitude | 
| 
 | the resulting elevation |