[GRASS-SVN] r68881 - in grass/trunk: imagery/i.atcorr imagery/i.biomass imagery/i.eb.netrad imagery/i.topo.corr include lib/htmldriver lib/rst/interp_float raster/r.flow raster/r.param.scale raster/r.ros raster/r.sunmask vector/v.vol.rst
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jul 7 05:07:35 PDT 2016
Author: neteler
Date: 2016-07-07 05:07:34 -0700 (Thu, 07 Jul 2016)
New Revision: 68881
Modified:
grass/trunk/imagery/i.atcorr/common.h
grass/trunk/imagery/i.biomass/solar_day.c
grass/trunk/imagery/i.eb.netrad/r_net.c
grass/trunk/imagery/i.topo.corr/local_proto.h
grass/trunk/include/gis.h
grass/trunk/lib/htmldriver/polygon.c
grass/trunk/lib/rst/interp_float/interp2d.c
grass/trunk/lib/rst/interp_float/secpar2d.c
grass/trunk/raster/r.flow/r.flow.h
grass/trunk/raster/r.param.scale/param.h
grass/trunk/raster/r.ros/main.c
grass/trunk/raster/r.ros/spot_dist.c
grass/trunk/raster/r.sunmask/solpos00.c
grass/trunk/vector/v.vol.rst/user3.c
Log:
update private definitions of pi, rad2deg, deg2rad to use global definitions in gis.h
Modified: grass/trunk/imagery/i.atcorr/common.h
===================================================================
--- grass/trunk/imagery/i.atcorr/common.h 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/imagery/i.atcorr/common.h 2016-07-07 12:07:34 UTC (rev 68881)
@@ -29,7 +29,7 @@
#include "output.h"
-
+/* or better #include <grass/gis.h> ? */
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif /* M_PI */
Modified: grass/trunk/imagery/i.biomass/solar_day.c
===================================================================
--- grass/trunk/imagery/i.biomass/solar_day.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/imagery/i.biomass/solar_day.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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;
Modified: grass/trunk/imagery/i.eb.netrad/r_net.c
===================================================================
--- grass/trunk/imagery/i.eb.netrad/r_net.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/imagery/i.eb.netrad/r_net.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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)
Modified: grass/trunk/imagery/i.topo.corr/local_proto.h
===================================================================
--- grass/trunk/imagery/i.topo.corr/local_proto.h 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/imagery/i.topo.corr/local_proto.h 2016-07-07 12:07:34 UTC (rev 68881)
@@ -1,3 +1,4 @@
+#include <grass/gis.h>
#include <grass/raster.h>
#ifndef _LOCAL_PROTO_H
@@ -3,7 +4,7 @@
#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
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/include/gis.h 2016-07-07 12:07:34 UTC (rev 68881)
@@ -120,6 +120,12 @@
#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
Modified: grass/trunk/lib/htmldriver/polygon.c
===================================================================
--- grass/trunk/lib/htmldriver/polygon.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/lib/htmldriver/polygon.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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)
{
Modified: grass/trunk/lib/rst/interp_float/interp2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/interp2d.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/lib/rst/interp_float/interp2d.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -107,7 +107,7 @@
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);
}
Modified: grass/trunk/lib/rst/interp_float/secpar2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/secpar2d.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/lib/rst/interp_float/secpar2d.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -62,7 +62,7 @@
int i, got, bmask = 1;
static int first_time_g = 1;
- ro = 57.295779;
+ ro = M_R2D;
gradmin = 0.001;
Modified: grass/trunk/raster/r.flow/r.flow.h
===================================================================
--- grass/trunk/raster/r.flow/r.flow.h 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/raster/r.flow/r.flow.h 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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 */
Modified: grass/trunk/raster/r.param.scale/param.h
===================================================================
--- grass/trunk/raster/r.param.scale/param.h 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/raster/r.param.scale/param.h 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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
Modified: grass/trunk/raster/r.ros/main.c
===================================================================
--- grass/trunk/raster/r.ros/main.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/raster/r.ros/main.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -757,8 +757,8 @@
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 @@
*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;
Modified: grass/trunk/raster/r.ros/spot_dist.c
===================================================================
--- grass/trunk/raster/r.ros/spot_dist.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/raster/r.ros/spot_dist.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -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 */
Modified: grass/trunk/raster/r.sunmask/solpos00.c
===================================================================
--- grass/trunk/raster/r.sunmask/solpos00.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/raster/r.sunmask/solpos00.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -127,6 +127,7 @@
/* 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 */
Modified: grass/trunk/vector/v.vol.rst/user3.c
===================================================================
--- grass/trunk/vector/v.vol.rst/user3.c 2016-07-07 08:33:57 UTC (rev 68880)
+++ grass/trunk/vector/v.vol.rst/user3.c 2016-07-07 12:07:34 UTC (rev 68881)
@@ -62,7 +62,7 @@
int bmask = 1;
static int first_t = 1;
- ro = 57.295779;
+ ro = M_R2D;
gradmin = 0.0;
/*
for (i = ngstc; i <= nszc; i++)
More information about the grass-commit
mailing list