From 68c55afc7e4d2507a1244dba1b44f365663b4e7c Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Sun, 22 Nov 2009 04:28:01 +0000 Subject: [PATCH] Replace pow(,2.0) with POW2 macro. git-svn-id: http://svn.osgeo.org/postgis/trunk@4879 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwgeodetic.c | 10 +++++----- liblwgeom/lwgeodetic.h | 2 ++ liblwgeom/lwspheroid.c | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/liblwgeom/lwgeodetic.c b/liblwgeom/lwgeodetic.c index 857f0fcb4..23ef86809 100644 --- a/liblwgeom/lwgeodetic.c +++ b/liblwgeom/lwgeodetic.c @@ -587,8 +587,8 @@ double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e) double cos_lat_s = cos(s->lat); double sin_lat_s = sin(s->lat); - double a1 = pow(cos_lat_e * sin(d_lon), 2.0); - double a2 = pow(cos_lat_s * sin_lat_e - sin_lat_s * cos_lat_e * cos_d_lon, 2.0); + double a1 = POW2(cos_lat_e * sin(d_lon)); + double a2 = POW2(cos_lat_s * sin_lat_e - sin_lat_s * cos_lat_e * cos_d_lon); double a = sqrt(a1 + a2); double b = sin_lat_s * sin_lat_e + cos_lat_s * cos_lat_e * cos_d_lon; return atan2(a, b); @@ -1358,21 +1358,21 @@ void gbox_pt_outside(const GBOX *gbox, POINT2D *pt_outside) if((1.0 - gbox->xmax) > 0.1) { pt.x = gbox->xmax + (1.0 - gbox->xmax) * 0.01; - d = sqrt((1.0 - pow(pt.x, 2.0))/2.0); + d = sqrt((1.0 - POW2(pt.x))/2.0); pt.y = d; pt.z = d; } else if((1.0 - gbox->ymax) > 0.1) { pt.y = gbox->ymax + (1.0 - gbox->ymax) * 0.01; - d = sqrt((1.0 - pow(pt.y, 2.0))/2.0); + d = sqrt((1.0 - POW2(pt.y))/2.0); pt.x = d; pt.z = d; } else if((1.0 - gbox->zmax) > 0.1) { pt.z = gbox->zmax + (1.0 - gbox->zmax) * 0.01; - d = sqrt((1.0 - pow(pt.z, 2.0))/2.0); + d = sqrt((1.0 - POW2(pt.z))/2.0); pt.x = d; pt.y = d; } diff --git a/liblwgeom/lwgeodetic.h b/liblwgeom/lwgeodetic.h index be6ef4b2b..aa626535e 100644 --- a/liblwgeom/lwgeodetic.h +++ b/liblwgeom/lwgeodetic.h @@ -14,6 +14,8 @@ extern int gbox_geocentric_slow; +#define POW2(x) ((x)*(x)) + /** * Point in spherical coordinates on the world. Units of radians. */ diff --git a/liblwgeom/lwspheroid.c b/liblwgeom/lwspheroid.c index 7514c7fef..fb3793658 100644 --- a/liblwgeom/lwspheroid.c +++ b/liblwgeom/lwspheroid.c @@ -12,8 +12,6 @@ #include "lwgeodetic.h" -#define POW2(x) ((x)*(x)) - /** * Initialize spheroid object based on major and minor axis */ -- 2.50.1