From: Sandro Santilli Date: Fri, 8 Oct 2004 13:15:26 +0000 (+0000) Subject: Initial revision X-Git-Tag: pgis_1_0_0RC1~314 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7980bc7127d1edd4e9b7c01f515ccb40ae3aa7e6;p=postgis Initial revision git-svn-id: http://svn.osgeo.org/postgis/trunk@964 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/box2d.c b/lwgeom/box2d.c new file mode 100644 index 000000000..e20977e9c --- /dev/null +++ b/lwgeom/box2d.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include + +#include "liblwgeom.h" + +#ifndef EPSILON +#define EPSILON 1.0E-06 +#endif +#ifndef FPeq +#define FPeq(A,B) (fabs((A) - (B)) <= EPSILON) +#endif + + +/* Expand given box of 'd' units in all directions */ +void +expand_box2d(BOX2DFLOAT4 *box, double d) +{ + box->xmin -= d; + box->ymin -= d; + + box->xmax += d; + box->ymax += d; +} + + +char +box2d_same(BOX2DFLOAT4 *box1, BOX2DFLOAT4 *box2) +{ + return(FPeq(box1->xmax, box2->xmax) && + FPeq(box1->xmin, box2->xmin) && + FPeq(box1->ymax, box2->ymax) && + FPeq(box1->ymin, box2->ymin)); +} + +BOX2DFLOAT4 * +box2d_clone(const BOX2DFLOAT4 *in) +{ + BOX2DFLOAT4 *ret = lwalloc(sizeof(BOX2DFLOAT4)); + memcpy(ret, in, sizeof(BOX2DFLOAT4)); + return ret; +}