1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
Description: R 4.5 no longer defines PI
Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Bug-Debian: https://bugs.debian.org/1103228
Forwarded: no - upstream removed from CRAN
--- r-cran-sdmtools-1.1-221.2.orig/src/pointinpolygon.c
+++ r-cran-sdmtools-1.1-221.2/src/pointinpolygon.c
@@ -8,7 +8,7 @@ vertices are within the polygon.
#include <R.h>
#include <Rinternals.h>
-double TWOPI = 2 * PI;
+double TWOPI = 2 * M_PI;
double epsilon = 0.000000000001; // threshold value
SEXP pip(SEXP pntx, SEXP pnty, SEXP pntn, SEXP polyx, SEXP polyy, SEXP polyn)
@@ -41,23 +41,23 @@ SEXP pip(SEXP pntx, SEXP pnty, SEXP pntn
x1 = plx[jj]; x2 = plx[(jj+1) % npl]; x = ptx[ii];
y1 = ply[jj]; y2 = ply[(jj+1) % npl]; y = pty[ii];
//check if point are vertix
- if (x == x1 && y == y1) { angle = PI+1; break; }
+ if (x == x1 && y == y1) { angle = M_PI+1; break; }
//check if point is on border line between 2 points
- if (x == x1 && x == x2) { if ((y1 <= y && y <= y2) || (y1 >= y && y >= y2)) { angle = PI+1; break; } } // check point between two horizontal points
- if (y == y1 && y == y2) { if ((x1 <= x && x <= x2) || (x1 >= x && x >= x2)) { angle = PI+1; break; } } // check point between two verticle points
+ if (x == x1 && x == x2) { if ((y1 <= y && y <= y2) || (y1 >= y && y >= y2)) { angle = M_PI+1; break; } } // check point between two horizontal points
+ if (y == y1 && y == y2) { if ((x1 <= x && x <= x2) || (x1 >= x && x >= x2)) { angle = M_PI+1; break; } } // check point between two verticle points
dy = (y1==y2) ? -9999:(y1-y)/(y1-y2); //check if the relative change in x == relative change in y
dx = (x1==x2) ? -9999:(x1-x)/(x1-x2); //check if the relative change in x == relative change in y
dd = dy-dx; dd = (dd<0) ? -dd:dd;
- if (dd < epsilon && dy>0 && dy<1) { angle = PI+1; break; } // if dx == dy and dy is between 0 & 1 ... point is on the border line
+ if (dd < epsilon && dy>0 && dy<1) { angle = M_PI+1; break; } // if dx == dy and dy is between 0 & 1 ... point is on the border line
// && dy > 0 && dy < 1
//if not a vertex or on border lines... sum the angles
double dtheta = atan2(y2 - y, x2 - x) - atan2(y1 - y, x1 - x);
- while (dtheta > PI) dtheta -= TWOPI;
- while (dtheta < -PI) dtheta += TWOPI;
+ while (dtheta > M_PI) dtheta -= TWOPI;
+ while (dtheta < -M_PI) dtheta += TWOPI;
angle += dtheta;
}
//write out if point is in polygon
- if (fabs(angle) < PI) { out[ii] = 0; } else { out[ii] = 1; }
+ if (fabs(angle) < M_PI) { out[ii] = 0; } else { out[ii] = 1; }
}
//return the output data
--- r-cran-sdmtools-1.1-221.2.orig/src/vincenty.geodesics.c
+++ r-cran-sdmtools-1.1-221.2/src/vincenty.geodesics.c
@@ -20,9 +20,9 @@ double a = 6378137, b = 6356752.3142, f
SEXP Dest(SEXP latitude1, SEXP longitude1, SEXP bearing, SEXP distance) {
//bring in the key data
- latitude1 = coerceVector(latitude1, REALSXP); double lat1 = REAL(latitude1)[0] * (PI/180); //first lat in radians
- longitude1 = coerceVector(longitude1, REALSXP); double lon1 = REAL(longitude1)[0] * (PI/180); //first lon in radians
- bearing = coerceVector(bearing, REALSXP); double alpha1 = REAL(bearing)[0] * (PI/180); //bearing in radians
+ latitude1 = coerceVector(latitude1, REALSXP); double lat1 = REAL(latitude1)[0] * (M_PI/180); //first lat in radians
+ longitude1 = coerceVector(longitude1, REALSXP); double lon1 = REAL(longitude1)[0] * (M_PI/180); //first lon in radians
+ bearing = coerceVector(bearing, REALSXP); double alpha1 = REAL(bearing)[0] * (M_PI/180); //bearing in radians
distance = coerceVector(distance, REALSXP); double s = REAL(distance)[0]; //distance in m
//define all the variables
@@ -43,7 +43,7 @@ SEXP Dest(SEXP latitude1, SEXP longitude
A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));
B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq)));
- sigma = s / (b*A), sigmaP = 2*PI;
+ sigma = s / (b*A), sigmaP = 2*M_PI;
cos2SigmaM = cos(2*sigma1 + sigma);
sinSigma = sin(sigma);
cosSigma = cos(sigma);
@@ -65,9 +65,9 @@ SEXP Dest(SEXP latitude1, SEXP longitude
revAz = atan2(sinAlpha, -tmp); // final bearing
SEXP ans; PROTECT(ans = allocVector(REALSXP, 3));
- REAL(ans)[0] = lat2 * (180 / PI);
- REAL(ans)[1] = lon1 * (180 / PI) + L * (180 / PI);
- REAL(ans)[2] = revAz * (180 / PI);
+ REAL(ans)[0] = lat2 * (180 / M_PI);
+ REAL(ans)[1] = lon1 * (180 / M_PI) + L * (180 / M_PI);
+ REAL(ans)[2] = revAz * (180 / M_PI);
UNPROTECT(1);
return(ans);
@@ -101,9 +101,9 @@ SEXP Dist(SEXP latitude1, SEXP longitude
if (lat1[ii] == lat2[ii] && lon1[ii] == lon2[ii]) {
out[ii] = 0;
} else {
- double L = (lon2[ii]-lon1[ii]) * (PI/180);
- double U1 = atan((1-f) * tan(lat1[ii] * (PI/180)));
- double U2 = atan((1-f) * tan(lat2[ii] * (PI/180)));
+ double L = (lon2[ii]-lon1[ii]) * (M_PI/180);
+ double U1 = atan((1-f) * tan(lat1[ii] * (M_PI/180)));
+ double U2 = atan((1-f) * tan(lat2[ii] * (M_PI/180)));
double sinU1 = sin(U1), cosU1 = cos(U1);
double sinU2 = sin(U2), cosU2 = cos(U2);
|