]> granicus.if.org Git - postgis/commitdiff
Initial revision
authorSandro Santilli <strk@keybit.net>
Fri, 8 Oct 2004 13:15:26 +0000 (13:15 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 8 Oct 2004 13:15:26 +0000 (13:15 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@964 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/box2d.c [new file with mode: 0644]

diff --git a/lwgeom/box2d.c b/lwgeom/box2d.c
new file mode 100644 (file)
index 0000000..e20977e
--- /dev/null
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#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;
+}