diff options
author | Gary E. Miller <gem@rellim.com> | 2005-02-21 22:42:06 +0000 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2005-02-21 22:42:06 +0000 |
commit | bf5c700bef1c79b81db550d4bbb575bc76b502a4 (patch) | |
tree | 83f7bd31e525e3f7d8d1a584c3e4878b4635b78c | |
parent | 0ffff462f35272faefc8357463dcde1fd168751e (diff) | |
download | gpsd-bf5c700bef1c79b81db550d4bbb575bc76b502a4.tar.gz |
Be a little smarter about PI
-rw-r--r-- | Tachometer.c | 2 | ||||
-rw-r--r-- | display.c | 5 | ||||
-rw-r--r-- | garmin.c | 4 | ||||
-rw-r--r-- | gps.h | 2 |
4 files changed, 6 insertions, 7 deletions
diff --git a/Tachometer.c b/Tachometer.c index 45122c95..c1b044d7 100644 --- a/Tachometer.c +++ b/Tachometer.c @@ -19,7 +19,7 @@ #include <math.h> #include "config.h" /* must define UNUSED */ -#define D2R (3.14159265358979323846 / 180.0) /* Degrees to radians */ +#define D2R 0.0174532925199432957692369076848861271L /* radians = pi/180 */ /**************************************************************** * @@ -5,7 +5,6 @@ #include "config.h" #include "display.h" -#define DEG2RAD (PI/180.0) #define RM 20 #undef min @@ -49,9 +48,9 @@ void register_canvas(Widget w, GC gc) static void pol2cart(double azimuth, double elevation, int *xout, int *yout) { - azimuth *= DEG2RAD; + azimuth *= DEG_2_RAD; #ifdef PCORRECT - elevation = sin((90.0 - elevation) * DEG2RAD); + elevation = sin((90.0 - elevation) * DEG_2_RAD); #else elevation = ((90.0 - elevation) / 90.0); #endif @@ -168,7 +168,7 @@ static inline int get_int(const unsigned char *buf) // convert radians to degrees static inline double radtodeg( double rad) { - return ( rad * 180.0 / PI ); + return ( rad * RAD_2_DEG ); } static void PrintPacket(struct gps_session_t *session, Packet_t *pkt ); @@ -236,9 +236,7 @@ static void PrintPacket(struct gps_session_t *session, Packet_t *pkt ) time_l = 631065600 + (pvt->grmn_days * 86400); time_l -= pvt->leap_sec; // gps_tow is always like x.999 or x.998 so just round it - //time_l += (long)nearbyint(pvt->gps_tow); time_l += (time_t) rint(pvt->gps_tow); - //time_l += pvt->gps_tow; gpsd_report(5, "time_l: %ld\n", time_l); tm = gmtime(&time_l); @@ -137,6 +137,8 @@ void gps_set_raw_hook(struct gps_data_t *gpsdata, void (*hook)(char *buf)); #define KNOTS_TO_MPH 1.1507794 /* International miles and knots */ #define KNOTS_TO_KPH 1.852 /* International knots */ #define PI 3.1415926535897932384626433832795029L /* for radians-to-degrees and vv. */ +#define RAD_2_DEG 57.2957795130823208767981548141051703L /* degrees = 180/pi */ +#define DEG_2_RAD 0.0174532925199432957692369076848861271L /* radians = pi/180 */ /* gps_open() error return values */ #define NL_NOSERVICE -1 /* can't get service entry */ |