Manual Page Result
0
Command: add | Section: 9 | Source: UNIX v10 | File: add.9
ADD(9.3) ADD(9.3)
NAME
add, sub, mul, div, eqpt, eqrect, inset, muldiv, ptinrect, raddp,
rsubp, rectXrect, rectclip - arithmetic on points and rectangles
SYNOPSIS
#include <jerq.h>
Point add(p, q) Point p, q;
Point sub(p, q) Point p, q;
Point mul(p, a) Point p; int a;
Point div(p, a) Point p; int a;
int eqpt(p, q) Point p, q;
int eqrect(r, s) Rectangle r, s;
Rectangle inset(r, n) Rectangle r; int n;
int muldiv(a, b, c) int a, b, c;
int ptinrect(p, r) Point p; Rectangle r;
Rectangle raddp(r, p) Rectangle r; Point p;
Rectangle rsubp(r, p) Rectangle r; Point p;
int rectXrect(r, s) Rectangle r, s;
int rectclip(rp, s) Rectangle *rp, s;
DESCRIPTION
Add returns the Point sum of its arguments: Pt(p.x+q.x, p.y+q.y). Sub
returns the Point difference of its arguments: Pt(p.x-q.x, p.y-q.y).
Mul returns the Point Pt(p.x*a, p.y*a). Div returns the Point
Pt(p.x/a, p.y/a).
Eqpt and eqrect compare their arguments and return 0 if unequal, 1 if
equal.
Inset returns the Rectangle Rect(r.origin.x+n, r.origin.y+n, r.cor-
ner.x-n, r.corner.y-n). The following code creates a clear rectangle r
with a 2-pixel wide border inside r:
rectf(&display, r, F_OR);
rectf(&display, inset(r, 2), F_CLR);
Muldiv is a macro that returns the 16-bit result (a*b)/c, with (a*b)
calculated to 32 bits, so no precision is lost.
Ptinrect returns 1 if p is a point within r, and 0 otherwise.
Raddp returns the Rectangle Rect(add(r.origin, p), add(r.corner, p));
rsubp returns the Rectangle Rect(sub(r.origin, p), sub(r.corner, p)).
RectXrect returns 1 if r and s share any point; 0 otherwise.
Rectclip clips in place the Rectangle pointed to by rp so that it is
completely contained within s. The return value is 1 if any part of
*rp is within s. Otherwise, the return value is 0 and *rp is un-
changed.
SEE ALSO
types(9.5)
ADD(9.3)