|
|
1.1 root 1: #include <jerq.h>
2:
3: Point
4: add(a, b)
5: Point a, b;
6: {
7: register Point *ap= &a, *bp= &b;
8: ap->x+=bp->x;
9: ap->y+=bp->y;
10: return(*ap);
11: }
12:
13: Point
14: sub(a, b)
15: Point a, b;
16: {
17: register Point *ap= &a, *bp= &b;
18: ap->x-=bp->x;
19: ap->y-=bp->y;
20: return(*ap);
21: }
22:
23: Rectangle
24: inset(r,n)
25: Rectangle r;
26: {
27: r.origin = add(r.origin,Pt(n,n));
28: r.corner = sub(r.corner,Pt(n,n));
29: return(r);
30: }
31:
32: Point
33: div(a, b)
34: Point a;
35: register b;
36: {
37: register Point *ap= &a;
38: ap->x/=b;
39: ap->y/=b;
40: return(*ap);
41: }
42:
43: Point
44: mul(a, b)
45: Point a;
46: register b;
47: {
48: register Point *ap= &a;
49: ap->x*=b;
50: ap->y*=b;
51: return(*ap);
52: }
53:
54: Rectangle
55: rsubp(r, p)
56: Rectangle r;
57: Point p;
58: {
59: register Rectangle *rp= &r;
60: register Point *pp= &p;
61: rp->origin.x-=pp->x;
62: rp->origin.y-=pp->y;
63: rp->corner.x-=pp->x;
64: rp->corner.y-=pp->y;
65: return(*rp);
66: }
67: Rectangle
68: raddp(r, p)
69: Rectangle r;
70: Point p;
71: {
72: register Rectangle *rp= &r;
73: register Point *pp= &p;
74: rp->origin.x+=pp->x;
75: rp->origin.y+=pp->y;
76: rp->corner.x+=pp->x;
77: rp->corner.y+=pp->y;
78: return(*rp);
79: }
80:
81: eqpt(p, q)
82: Point p, q;
83: {
84: return(p.x==q.x && p.y==q.y);
85: }
86:
87: eqrect(r, s)
88: Rectangle r, s;
89: {
90: #define o origin
91: #define c corner
92: return(r.o.x==s.o.x && r.o.y==s.o.y && r.c.x==s.c.x && r.c.y==s.c.y);
93: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.