Browse Source

update private definitions of pi, rad2deg, deg2rad to use global definitions in gis.h

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68881 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 8 years ago
parent
commit
68cbd9e577

+ 1 - 1
imagery/i.atcorr/common.h

@@ -29,7 +29,7 @@ using std::numeric_limits;
 
 #include "output.h"
 
-
+/* or better #include <grass/gis.h> ? */
 #ifndef M_PI
 #define M_PI 3.1415926535897932384626433832795
 #endif /* M_PI */

+ 6 - 4
imagery/i.biomass/solar_day.c

@@ -1,12 +1,14 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <grass/gis.h>
 
     /*
      * Average Solar Diurnal Radiation after Bastiaanssen (1995) 
      */
     
-#define PI 3.1415927
+#define PI M_PI
+
 double solar_day(double lat, double doy, double tsw) 
 {
     double ws, cosun, n10_temp, delta, ds, result;

+ 7 - 5
imagery/i.eb.netrad/r_net.c

@@ -1,8 +1,10 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
- 
-#define PI 3.1415927
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <grass/gis.h>
+
+#define PI M_PI
+
 double r_net(double bbalb, double ndvi, double tempk, double dtair,
 	      double e0, double tsw, double doy, double utc,
 	      double sunzangle) 

+ 4 - 3
imagery/i.topo.corr/local_proto.h

@@ -1,11 +1,12 @@
+#include <grass/gis.h>
 #include <grass/raster.h>
 
 #ifndef _LOCAL_PROTO_H
 #define _LOCAL_PROTO_H
 
-#define PI   3.1415926535897932384626433832795
-#define R2D 57.295779513082320877
-#define D2R  0.017453292519943295769
+#define PI   M_PI
+#define R2D  M_R2D
+#define D2R  M_D2R
 
 typedef struct
 {

+ 6 - 0
include/gis.h

@@ -120,6 +120,12 @@ static const char *GRASS_copyright __attribute__ ((unused))
 #undef M_PI_4
 #define M_PI_4  0.78539816339744830962	/* pi/4 */
 
+#undef M_R2D
+#define M_R2D  57.295779513082320877    /* 180/pi */
+
+#undef M_D2R
+#define M_D2R   0.017453292519943295769 /* pi/180 */
+
 /* epsilon (IEEE: 2.220446e-16) */
 #define GRASS_EPSILON 1.0e-15
 

+ 1 - 1
lib/htmldriver/polygon.c

@@ -6,7 +6,7 @@
 #include "driverlib.h"
 #include "htmlmap.h"
 
-#define RAD_DEG 57.29578
+#define RAD_DEG M_R2D
 
 static void delete_point(int *x, int *y, int count)
 {

+ 1 - 1
lib/rst/interp_float/interp2d.c

@@ -107,7 +107,7 @@ int IL_grid_calc_2d(struct interp_params *params,
     double xxr, yyr;
 
     if (params->theta) {
-	teta = params->theta / 57.295779;	/* deg to rad */
+	teta = params->theta / M_R2D;	/* deg to rad */
 	rsin = sin(teta);
 	rcos = cos(teta);
     }

+ 1 - 1
lib/rst/interp_float/secpar2d.c

@@ -62,7 +62,7 @@ int IL_secpar_loop_2d(struct interp_params *params,
     int i, got, bmask = 1;
     static int first_time_g = 1;
 
-    ro = 57.295779;
+    ro = M_R2D;
     gradmin = 0.001;
 
 

+ 1 - 1
raster/r.flow/r.flow.h

@@ -44,7 +44,7 @@
 
 #define D_PI	180.
 #define D2_PI	360.
-#define DEG2RAD	0.0174532925199432958
+#define DEG2RAD	M_D2R
 #define UNDEF	365.		/* change to undefined when available */
 #define UNDEFZ	0.		/* change to undefined when available */
 #define HORIZ	1		/* magic        */

+ 2 - 2
raster/r.param.scale/param.h

@@ -21,8 +21,8 @@
 #define TRUE 1
 #define FALSE 0
 
-#define RAD2DEG 57.29578
-#define DEG2RAD 0.017453293
+#define RAD2DEG M_R2D
+#define DEG2RAD M_D2R
 
 #define TINY 1.0e-20
 

+ 7 - 7
raster/r.ros/main.c

@@ -757,8 +757,8 @@ int main(int argc, char *argv[])
 	    if (parm.slope->answer && parm.aspect->answer) {
 		phis =
 		    5.275 * pow(beta,
-				-0.3) * tan(0.01745 * slope[col]) *
-		    tan(0.01745 * slope[col]);
+				-0.3) * tan(M_D2R * slope[col]) *
+		    tan(M_D2R * slope[col]);
 	    }
 	    else
 		phis = 0.0;
@@ -767,13 +767,13 @@ int main(int argc, char *argv[])
 	     *vector adding for the effect of wind and slope*/
 	    if (parm.dir->answer && parm.aspect->answer) {
 		sin_fac =
-		    phiw * sin(0.01745 * dir[col]) +
-		    phis * sin(0.01745 * aspect[col]);
+		    phiw * sin(M_D2R * dir[col]) +
+		    phis * sin(M_D2R * aspect[col]);
 		cos_fac =
-		    phiw * cos(0.01745 * dir[col]) +
-		    phis * cos(0.01745 * aspect[col]);
+		    phiw * cos(M_D2R * dir[col]) +
+		    phis * cos(M_D2R * aspect[col]);
 		phi_ws = sqrt(sin_fac * sin_fac + cos_fac * cos_fac);
-		Rdir = atan2(sin_fac, cos_fac) / 0.01745;
+		Rdir = atan2(sin_fac, cos_fac) / M_D2R;
 	    }
 	    else if (parm.dir->answer && !(parm.aspect->answer)) {
 		phi_ws = phiw;

+ 1 - 1
raster/r.ros/spot_dist.c

@@ -36,7 +36,7 @@
 #include <grass/raster.h>
 
 #define DATA(map, r, c) (map)[(r) * ncols + (c)]
-#define	DEG2RAD		0.017453292
+#define	DEG2RAD		M_D2R
 /*#define DEBUG */
 
 

+ 1 - 0
raster/r.sunmask/solpos00.c

@@ -127,6 +127,7 @@ static int month_days[2][13] = { {0, 0, 31, 59, 90, 120, 151,
 
 		   /* cumulative number of days prior to beginning of month */
 
+/* TODO: the "degrad" - "raddeg" variable names are flipped - typo or severe bug?? */
 static float degrad = 57.295779513;	/* converts from radians to degrees */
 static float raddeg = 0.0174532925;	/* converts from degrees to radians */
 

+ 1 - 1
vector/v.vol.rst/user3.c

@@ -62,7 +62,7 @@ int secpar_loop(int ngstc, int nszc, int i)
     int bmask = 1;
     static int first_t = 1;
 
-    ro = 57.295779;
+    ro = M_R2D;
     gradmin = 0.0;
     /*
        for (i = ngstc; i <= nszc; i++)