Commit 9e2a87b6 authored by Marc G. Fournier's avatar Marc G. Fournier

Major patch from Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>

OK, here are a passel of patches for the geometric data types.
These add a "circle" data type, new operators and functions
for the existing data types, and change the default formats
for some of the existing types to make them consistant with
each other. Current formatting conventions (e.g. compatible
with v6.0 to allow dump/reload) are supported, but the new
conventions should be an improvement and we can eventually
drop the old conventions entirely.

For example, there are two kinds of paths (connected line segments),
open and closed, and the old format was

'(1,2,1,2,3,4)' for a closed path with two points (1,2) and (3,4)
'(0,2,1,2,3,4)' for an open path with two points (1,2) and (3,4)

Pretty arcane, huh? The new format for paths is

'((1,2),(3,4))' for a closed path with two points (1,2) and (3,4)
'[(1,2),(3,4)]' for an open path with two points (1,2) and (3,4)

For polygons, the old convention is

'(0,4,2,0,4,3)' for a triangle with points at (0,0),(4,4), and (2,3)

and the new convention is

'((0,0),(4,4),(2,3))' for a triangle with points at (0,0),(4,4), and (2,3)

Other data types which are also represented as lists of points
(e.g. boxes, line segments, and polygons) have similar representations
(they surround each point with parens).

For v6.1, any format which can be interpreted as the old style format
is decoded as such; we can remove that backwards compatibility but ugly
convention for v7.0. This will allow dump/reloads from v6.0.

These include some updates to the regression test files to change the test
for creating a data type from "circle" to "widget" to keep the test from
trashing the new builtin circle type.
parent 051b4210
......@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.6 1997/03/14 23:17:41 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.7 1997/04/22 17:31:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -30,10 +30,10 @@ BOX
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
elog(WARN, "Cannot allocate box for union");
n->xh = Max(a->xh, b->xh);
n->yh = Max(a->yh, b->yh);
n->xl = Min(a->xl, b->xl);
n->yl = Min(a->yl, b->yl);
n->high.x = Max(a->high.x, b->high.x);
n->high.y = Max(a->high.y, b->high.y);
n->low.x = Min(a->low.x, b->low.x);
n->low.y = Min(a->low.y, b->low.y);
return (n);
}
......@@ -46,12 +46,12 @@ rt_box_inter(BOX *a, BOX *b)
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
elog(WARN, "Cannot allocate box for union");
n->xh = Min(a->xh, b->xh);
n->yh = Min(a->yh, b->yh);
n->xl = Max(a->xl, b->xl);
n->yl = Max(a->yl, b->yl);
n->high.x = Min(a->high.x, b->high.x);
n->high.y = Min(a->high.y, b->high.y);
n->low.x = Max(a->low.x, b->low.x);
n->low.y = Max(a->low.y, b->low.y);
if (n->xh < n->xl || n->yh < n->yl) {
if (n->high.x < n->low.x || n->high.y < n->low.y) {
pfree(n);
return ((BOX *) NULL);
}
......@@ -62,10 +62,10 @@ rt_box_inter(BOX *a, BOX *b)
void
rt_box_size(BOX *a, float *size)
{
if (a == (BOX *) NULL || a->xh <= a->xl || a->yh <= a->yl)
if (a == (BOX *) NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
*size = 0.0;
else
*size = (float) ((a->xh - a->xl) * (a->yh - a->yl));
*size = (float) ((a->high.x - a->low.x) * (a->high.y - a->low.y));
return;
}
......@@ -97,10 +97,10 @@ rt_poly_union(POLYGON *a, POLYGON *b)
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON);
p->npts = 0;
p->boundbox.xh = Max(a->boundbox.xh, b->boundbox.xh);
p->boundbox.yh = Max(a->boundbox.yh, b->boundbox.yh);
p->boundbox.xl = Min(a->boundbox.xl, b->boundbox.xl);
p->boundbox.yl = Min(a->boundbox.yl, b->boundbox.yl);
p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x);
p->boundbox.high.y = Max(a->boundbox.high.y, b->boundbox.high.y);
p->boundbox.low.x = Min(a->boundbox.low.x, b->boundbox.low.x);
p->boundbox.low.y = Min(a->boundbox.low.y, b->boundbox.low.y);
return p;
}
......@@ -111,12 +111,12 @@ rt_poly_size(POLYGON *a, float *size)
size = (float *) palloc(sizeof(float));
if (a == (POLYGON *) NULL ||
a->boundbox.xh <= a->boundbox.xl ||
a->boundbox.yh <= a->boundbox.yl)
a->boundbox.high.x <= a->boundbox.low.x ||
a->boundbox.high.y <= a->boundbox.low.y)
*size = 0.0;
else {
xdim = (a->boundbox.xh - a->boundbox.xl);
ydim = (a->boundbox.yh - a->boundbox.yl);
xdim = (a->boundbox.high.x - a->boundbox.low.x);
ydim = (a->boundbox.high.y - a->boundbox.low.y);
*size = (float) (xdim * ydim);
}
......@@ -137,12 +137,12 @@ rt_poly_inter(POLYGON *a, POLYGON *b)
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON);
p->npts = 0;
p->boundbox.xh = Min(a->boundbox.xh, b->boundbox.xh);
p->boundbox.yh = Min(a->boundbox.yh, b->boundbox.yh);
p->boundbox.xl = Max(a->boundbox.xl, b->boundbox.xl);
p->boundbox.yl = Max(a->boundbox.yl, b->boundbox.yl);
p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x);
p->boundbox.high.y = Min(a->boundbox.high.y, b->boundbox.high.y);
p->boundbox.low.x = Max(a->boundbox.low.x, b->boundbox.low.x);
p->boundbox.low.y = Max(a->boundbox.low.y, b->boundbox.low.y);
if (p->boundbox.xh < p->boundbox.xl || p->boundbox.yh < p->boundbox.yl)
if (p->boundbox.high.x < p->boundbox.low.x || p->boundbox.high.y < p->boundbox.low.y)
{
pfree(p);
return ((POLYGON *) NULL);
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_operator.h,v 1.8 1997/04/15 17:40:44 scrappy Exp $
* $Id: pg_operator.h,v 1.9 1997/04/22 17:31:49 scrappy Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -185,7 +185,7 @@ DATA(insert OID = 513 ( "@@" PGUID 0 l t f 0 603 600 0 0 0 0 box
DATA(insert OID = 514 ( "*" PGUID 0 b t f 23 23 23 514 0 0 0 int4mul intltsel intltjoinsel ));
DATA(insert OID = 515 ( "!" PGUID 0 r t f 23 0 23 0 0 0 0 int4fac intltsel intltjoinsel ));
DATA(insert OID = 516 ( "!!" PGUID 0 l t f 0 23 23 0 0 0 0 int4fac intltsel intltjoinsel ));
DATA(insert OID = 517 ( "<===>" PGUID 0 b t f 600 600 701 0 0 0 0 point_distance intltsel intltjoinsel ));
DATA(insert OID = 517 ( "<===>" PGUID 0 b t f 600 600 701 517 0 0 0 point_distance intltsel intltjoinsel ));
DATA(insert OID = 518 ( "<>" PGUID 0 b t f 23 23 16 518 96 0 0 int4ne neqsel neqjoinsel ));
DATA(insert OID = 519 ( "<>" PGUID 0 b t f 21 21 16 519 94 0 0 int2ne neqsel neqjoinsel ));
DATA(insert OID = 520 ( ">" PGUID 0 b t f 21 21 16 95 0 0 0 int2gt intgtsel intgtjoinsel ));
......@@ -279,6 +279,14 @@ DATA(insert OID = 609 ( "<" PGUID 0 b t f 26 26 16 610 612 0 0 int4l
DATA(insert OID = 610 ( ">" PGUID 0 b t f 26 26 16 609 611 0 0 int4gt intgtsel intgtjoinsel ));
DATA(insert OID = 611 ( "<=" PGUID 0 b t f 26 26 16 612 610 0 0 int4le intltsel intltjoinsel ));
DATA(insert OID = 612 ( ">=" PGUID 0 b t f 26 26 16 611 609 0 0 int4ge intgtsel intgtjoinsel ));
DATA(insert OID = 613 ( "<===>" PGUID 0 b t f 600 603 701 613 0 0 0 dist_pl intltsel intltjoinsel ));
DATA(insert OID = 614 ( "<===>" PGUID 0 b t f 600 601 701 614 0 0 0 dist_ps intltsel intltjoinsel ));
DATA(insert OID = 615 ( "<===>" PGUID 0 b t f 600 603 701 615 0 0 0 dist_pb intltsel intltjoinsel ));
DATA(insert OID = 616 ( "<===>" PGUID 0 b t f 600 603 701 616 0 0 0 dist_ps intltsel intltjoinsel ));
DATA(insert OID = 617 ( "<===>" PGUID 0 b t f 601 603 701 617 0 0 0 dist_sb intltsel intltjoinsel ));
DATA(insert OID = 618 ( "<===>" PGUID 0 b t f 600 602 701 618 0 0 0 dist_ppth intltsel intltjoinsel ));
DATA(insert OID = 620 ( "=" PGUID 0 b t t 700 700 16 620 621 622 622 float4eq eqsel eqjoinsel ));
DATA(insert OID = 621 ( "<>" PGUID 0 b t f 700 700 16 621 620 0 0 float4ne neqsel neqjoinsel ));
DATA(insert OID = 622 ( "<" PGUID 0 b t f 700 700 16 623 625 0 0 float4lt intltsel intltjoinsel ));
......@@ -341,6 +349,11 @@ DATA(insert OID = 681 ( "<>" PGUID 0 b t f 911 911 16 681 678 0 0 oidn
DATA(insert OID = 697 ( "~" PGUID 0 b t f 411 25 16 0 698 0 0 char8regexeq eqsel eqjoinsel ));
DATA(insert OID = 698 ( "!~" PGUID 0 b t f 411 25 16 0 697 0 0 char8regexne neqsel neqjoinsel ));
DATA(insert OID = 706 ( "<===>" PGUID 0 b t f 603 603 701 706 0 0 0 box_distance intltsel intltjoinsel ));
DATA(insert OID = 707 ( "<===>" PGUID 0 b t f 602 602 701 707 0 0 0 path_distance intltsel intltjoinsel ));
DATA(insert OID = 708 ( "<===>" PGUID 0 b t f 603 603 701 708 0 0 0 line_distance intltsel intltjoinsel ));
DATA(insert OID = 709 ( "<===>" PGUID 0 b t f 601 601 701 709 0 0 0 lseg_distance intltsel intltjoinsel ));
DATA(insert OID = 830 ( "<" PGUID 0 b t f 810 810 16 834 833 0 0 oidint2lt intltsel intltjoinsel ));
DATA(insert OID = 831 ( "<=" PGUID 0 b t f 810 810 16 833 834 0 0 oidint2le intltsel intltjoinsel ));
DATA(insert OID = 832 ( "=" PGUID 0 b t f 810 810 16 832 835 0 0 oidint2eq intltsel intltjoinsel ));
......@@ -509,7 +522,32 @@ DATA(insert OID = 1303 ( ">" PGUID 0 b t f 1296 1296 16 1302 1304 0 0 ti
DATA(insert OID = 1304 ( "<=" PGUID 0 b t f 1296 1296 16 1305 1303 0 0 timestample intltsel intltjoinsel ));
DATA(insert OID = 1305 ( ">=" PGUID 0 b t f 1296 1296 16 1304 1302 0 0 timestampge intltsel intltjoinsel ));
/* additional geometric operators - tgl 97/04/18 */
DATA(insert OID = 1500 ( "=" PGUID 0 b t t 718 718 16 1500 1501 1502 1502 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1501 ( "<>" PGUID 0 b t f 718 718 16 1501 1500 0 0 circle_ne neqsel neqjoinsel ));
DATA(insert OID = 1502 ( "<" PGUID 0 b t f 718 718 16 1503 1505 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1503 ( ">" PGUID 0 b t f 718 718 16 1502 1504 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1504 ( "<=" PGUID 0 b t f 718 718 16 1505 1503 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1505 ( ">=" PGUID 0 b t f 718 718 16 1504 1502 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1506 ( "<<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_left intltsel intltjoinsel ));
DATA(insert OID = 1507 ( "&<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overleft intltsel intltjoinsel ));
DATA(insert OID = 1508 ( "&>" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overright intltsel intltjoinsel ));
DATA(insert OID = 1509 ( ">>" PGUID 0 b t f 718 718 16 0 0 0 0 circle_right intltsel intltjoinsel ));
DATA(insert OID = 1510 ( "@" PGUID 0 b t f 718 718 16 0 0 0 0 circle_contained intltsel intltjoinsel ));
DATA(insert OID = 1511 ( "~" PGUID 0 b t f 718 718 16 0 0 0 0 circle_contain intltsel intltjoinsel ));
DATA(insert OID = 1512 ( "~=" PGUID 0 b t f 718 718 16 1512 0 0 0 circle_same intltsel intltjoinsel ));
DATA(insert OID = 1513 ( "&&" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overlap intltsel intltjoinsel ));
DATA(insert OID = 1514 ( "!^" PGUID 0 b t f 718 718 16 0 0 0 0 circle_above intltsel intltjoinsel ));
DATA(insert OID = 1515 ( "!|" PGUID 0 b t f 718 718 16 0 0 0 0 circle_below intltsel intltjoinsel ));
DATA(insert OID = 1516 ( "+" PGUID 0 b t f 718 600 718 1516 0 0 0 circle_add_pt - - ));
DATA(insert OID = 1517 ( "-" PGUID 0 b t f 718 600 718 0 0 0 0 circle_sub_pt - - ));
DATA(insert OID = 1518 ( "*" PGUID 0 b t f 718 600 718 1518 0 0 0 circle_mul_pt - - ));
DATA(insert OID = 1519 ( "/" PGUID 0 b t f 718 600 718 0 0 0 0 circle_div_pt - - ));
DATA(insert OID = 1520 ( "<===>" PGUID 0 b t f 718 718 701 1520 0 0 0 circle_distance intltsel intltjoinsel ));
DATA(insert OID = 1521 ( "#" PGUID 0 l t f 0 604 23 0 0 0 0 poly_npoints - - ));
/*
* function prototypes
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.10 1997/04/15 17:41:19 scrappy Exp $
* $Id: pg_type.h,v 1.11 1997/04/22 17:32:26 scrappy Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -220,7 +220,10 @@ DATA(insert OID = 601 ( lseg PGUID 32 48 f b t \054 0 600 lseg_in lseg_ou
DATA(insert OID = 602 ( path PGUID -1 -1 f b t \054 0 600 path_in path_out path_in path_out d _null_ ));
DATA(insert OID = 603 ( box PGUID 32 100 f b t \073 0 600 box_in box_out box_in box_out d _null_ ));
DATA(insert OID = 604 ( polygon PGUID -1 -1 f b t \054 0 -1 poly_in poly_out poly_in poly_out d _null_ ));
DATA(insert OID = 605 ( filename PGUID 256 -1 f b t \054 0 18 filename_in filename_out filename_in filename_out i _null_ ));
DATA(insert OID = 605 ( filename PGUID 256 -1 f b t \054 0 18 filename_in filename_out filename_in filename_out i _null_ ));
DATA(insert OID = 628 ( line PGUID 32 48 f b t \054 0 701 line_in line_out line_in line_out d _null_ ));
DATA(insert OID = 629 ( _line PGUID -1 -1 f b t \054 0 628 array_in array_out array_in array_out d _null_ ));
/* OIDS 700 - 799 */
......@@ -234,8 +237,9 @@ DATA(insert OID = 704 ( tinterval PGUID 12 47 f b t \054 0 0 tintervalin tin
DATA(insert OID = 705 ( unknown PGUID -1 -1 f b t \054 0 18 textin textout textin textout i _null_ ));
#define UNKNOWNOID 705
DATA(insert OID = 790 ( money PGUID 4 47 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ ));
#define CASHOID 790
DATA(insert OID = 718 ( circle PGUID 24 47 f b t \054 0 0 circle_in circle_out circle_in circle_out d _null_ ));
DATA(insert OID = 719 ( _circle PGUID -1 -1 f b t \054 0 718 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 790 ( money PGUID 4 24 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ ));
DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ ));
/* OIDS 800 - 899 */
......
This diff is collapsed.
......@@ -6,8 +6,8 @@ QUERY: CREATE OPERATOR ## (
);
QUERY: CREATE OPERATOR <% (
leftarg = point,
rightarg = circle,
procedure = pt_in_circle,
rightarg = widget,
procedure = pt_in_widget,
commutator = >=%
);
QUERY: CREATE OPERATOR @#@ (
......
QUERY: CREATE TYPE circle (
QUERY: CREATE TYPE widget (
internallength = 24,
input = circle_in,
output = circle_out,
input = widget_in,
output = widget_out,
alignment = double
);
QUERY: CREATE TYPE city_budget (
......
......@@ -3357,20 +3357,20 @@ QUERY: DROP FUNCTION hobbies(person);
QUERY: DROP FUNCTION hobby_construct(text,text);
QUERY: DROP FUNCTION equipment(hobbies_r);
QUERY: DROP FUNCTION user_relns();
QUERY: DROP FUNCTION circle_in(opaque);
QUERY: DROP FUNCTION circle_out(opaque);
QUERY: DROP FUNCTION pt_in_circle(point,circle);
QUERY: DROP FUNCTION widget_in(opaque);
QUERY: DROP FUNCTION widget_out(opaque);
QUERY: DROP FUNCTION pt_in_widget(point,widget);
QUERY: DROP FUNCTION overpaid(emp);
QUERY: DROP FUNCTION boxarea(box);
QUERY: DROP FUNCTION interpt_pp(path,path);
QUERY: DROP FUNCTION reverse_c16(char16);
QUERY: DROP OPERATOR ## (path, path);
QUERY: DROP OPERATOR <% (point, circle);
QUERY: DROP OPERATOR <% (point, widget);
QUERY: DROP OPERATOR @#@ (none, int4);
QUERY: DROP OPERATOR #@# (int4, none);
QUERY: DROP OPERATOR #%# (int4, none);
QUERY: DROP TYPE city_budget;
QUERY: DROP TYPE circle;
QUERY: DROP TYPE widget;
QUERY: DROP AGGREGATE newavg;
QUERY: DROP AGGREGATE newsum;
QUERY: DROP AGGREGATE newcnt;
......
......@@ -3,12 +3,12 @@
--
--
CREATE FUNCTION circle_in(opaque)
RETURNS circle
CREATE FUNCTION widget_in(opaque)
RETURNS widget
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';
CREATE FUNCTION circle_out(opaque)
CREATE FUNCTION widget_out(opaque)
RETURNS opaque
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';
......@@ -42,7 +42,7 @@ CREATE FUNCTION user_relns()
relkind <> ''i'' '
LANGUAGE 'sql';
CREATE FUNCTION pt_in_circle(point, circle)
CREATE FUNCTION pt_in_widget(point, widget)
RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';
......
/*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.5 1997/03/14 23:34:16 scrappy Exp $
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.6 1997/04/22 17:33:00 scrappy Exp $
*/
#include <float.h> /* faked on sunos */
......@@ -103,22 +103,19 @@ poly2path(poly)
{
int i;
char *output = (char *)PALLOC(2*(P_MAXDIG + 1)*poly->npts + 64);
char *outptr = output;
double *xp, *yp;
char buf[2*(P_MAXDIG)+20];
sprintf(outptr, "(1, %*d", P_MAXDIG, poly->npts);
xp = (double *) poly->pts;
yp = (double *) (poly->pts + (poly->npts * sizeof(double *)));
sprintf(output, "(1, %*d", P_MAXDIG, poly->npts);
for (i=1; i<poly->npts; i++,xp++,yp++)
for (i=0; i<poly->npts; i++)
{
sprintf(outptr, ",%*g,%*g", P_MAXDIG, *xp, P_MAXDIG, *yp);
outptr += 2*(P_MAXDIG + 1);
sprintf(buf, ",%*g,%*g", P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
strcat(output, buf);
}
*outptr++ = RDELIM;
*outptr = '\0';
return(path_in(outptr));
sprintf(buf, "%c", RDELIM);
strcat(output, buf);
return(path_in(output));
}
/* return the point where two paths intersect. Assumes that they do. */
......@@ -176,24 +173,29 @@ char overpaid(tuple)
return(salary > 699);
}
/* New type "widget"
* This used to be "circle", but I added circle to builtins,
* so needed to make sure the names do not collide. - tgl 97/04/21
*/
typedef struct {
Point center;
double radius;
} CIRCLE;
} WIDGET;
extern CIRCLE *circle_in (char *str);
extern char *circle_out (CIRCLE *circle);
extern int pt_in_circle (Point *point, CIRCLE *circle);
extern WIDGET *widget_in (char *str);
extern char *widget_out (WIDGET *widget);
extern int pt_in_widget (Point *point, WIDGET *widget);
#define NARGS 3
CIRCLE *
circle_in(str)
WIDGET *
widget_in(str)
char *str;
{
char *p, *coord[NARGS], buf2[1000];
int i;
CIRCLE *result;
WIDGET *result;
if (str == NULL)
return(NULL);
......@@ -202,39 +204,39 @@ char *str;
coord[i++] = p + 1;
if (i < NARGS - 1)
return(NULL);
result = (CIRCLE *) palloc(sizeof(CIRCLE));
result = (WIDGET *) palloc(sizeof(WIDGET));
result->center.x = atof(coord[0]);
result->center.y = atof(coord[1]);
result->radius = atof(coord[2]);
sprintf(buf2, "circle_in: read (%f, %f, %f)\n", result->center.x,
sprintf(buf2, "widget_in: read (%f, %f, %f)\n", result->center.x,
result->center.y,result->radius);
return(result);
}
char *
circle_out(circle)
CIRCLE *circle;
widget_out(widget)
WIDGET *widget;
{
char *result;
if (circle == NULL)
if (widget == NULL)
return(NULL);
result = (char *) palloc(60);
(void) sprintf(result, "(%g,%g,%g)",
circle->center.x, circle->center.y, circle->radius);
widget->center.x, widget->center.y, widget->radius);
return(result);
}
int
pt_in_circle(point, circle)
pt_in_widget(point, widget)
Point *point;
CIRCLE *circle;
WIDGET *widget;
{
extern double point_dt();
return( point_dt(point, &circle->center) < circle->radius );
return( point_dt(point, &widget->center) < widget->radius );
}
#define ABS(X) ((X) > 0 ? (X) : -(X))
......@@ -247,8 +249,8 @@ BOX *box;
{
int width, height;
width = ABS(box->xh - box->xl);
height = ABS(box->yh - box->yl);
width = ABS(box->high.x - box->low.x);
height = ABS(box->high.y - box->low.y);
return (width * height);
}
......
......@@ -10,8 +10,8 @@ CREATE OPERATOR ## (
CREATE OPERATOR <% (
leftarg = point,
rightarg = circle,
procedure = pt_in_circle,
rightarg = widget,
procedure = pt_in_widget,
commutator = >=%
);
......
......@@ -3,10 +3,10 @@
--
--
CREATE TYPE circle (
CREATE TYPE widget (
internallength = 24,
input = circle_in,
output = circle_out,
input = widget_in,
output = widget_out,
alignment = double
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment