]> granicus.if.org Git - postgis/commitdiff
Replace pow(,2.0) with POW2 macro.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Sun, 22 Nov 2009 04:28:01 +0000 (04:28 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Sun, 22 Nov 2009 04:28:01 +0000 (04:28 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@4879 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeodetic.c
liblwgeom/lwgeodetic.h
liblwgeom/lwspheroid.c

index 857f0fcb49aba94cfe97c3c90e4cac47862b999d..23ef86809a08c5d9458f450555f1141ddb0b43f9 100644 (file)
@@ -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;
        }
index be6ef4b2b4a4779085b7df75c7d33891c86b764c..aa626535e765c018a161aa2d0e00d37ae63b0c89 100644 (file)
@@ -14,6 +14,8 @@
 
 extern int gbox_geocentric_slow;
 
+#define POW2(x) ((x)*(x))
+
 /**
 * Point in spherical coordinates on the world. Units of radians.
 */
index 7514c7fefb4ac410df513ba574e358aa7b7a0a4d..fb37936588f5a2551bda2b3825b0f11c379febb6 100644 (file)
@@ -12,8 +12,6 @@
 
 #include "lwgeodetic.h"
 
-#define POW2(x) ((x)*(x))
-
 /**
 * Initialize spheroid object based on major and minor axis
 */