File:  [Research Unix] / researchv9 / jerq / src / lib / j / drek / arith.oc
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

#include <jerq.h>

Point
add(a, b)
	Point a, b;
{
	register Point *ap= &a, *bp= &b;
	ap->x+=bp->x;
	ap->y+=bp->y;
	return(*ap);
}

Point
sub(a, b)
	Point a, b;
{
	register Point *ap= &a, *bp= &b;
	ap->x-=bp->x;
	ap->y-=bp->y;
	return(*ap);
}

Rectangle
inset(r,n)
	Rectangle r;
{
	r.origin = add(r.origin,Pt(n,n));
	r.corner = sub(r.corner,Pt(n,n));
	return(r);
}

Point
div(a, b)
	Point a;
	register b;
{
	register Point *ap= &a;
	ap->x/=b;
	ap->y/=b;
	return(*ap);
}

Point
mul(a, b)
	Point a;
	register b;
{
	register Point *ap= &a;
	ap->x*=b;
	ap->y*=b;
	return(*ap);
}

Rectangle
rsubp(r, p)
	Rectangle r;
	Point p;
{
	register Rectangle *rp= &r;
	register Point *pp= &p;
	rp->origin.x-=pp->x;
	rp->origin.y-=pp->y;
	rp->corner.x-=pp->x;
	rp->corner.y-=pp->y;
	return(*rp);
}
Rectangle
raddp(r, p)
	Rectangle r;
	Point p;
{
	register Rectangle *rp= &r;
	register Point *pp= &p;
	rp->origin.x+=pp->x;
	rp->origin.y+=pp->y;
	rp->corner.x+=pp->x;
	rp->corner.y+=pp->y;
	return(*rp);
}

eqpt(p, q)
	Point p, q;
{
	return(p.x==q.x && p.y==q.y);
}

eqrect(r, s)
	Rectangle r, s;
{
#define o origin
#define c corner
	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);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.