|
|
1.1 ! root 1: .TH ADD 9.3 ! 2: .CT 2 math ! 3: .SH NAME ! 4: add, sub, mul, div, eqpt, eqrect, inset, muldiv, ptinrect, raddp, rsubp, rectXrect, rectclip \- arithmetic on points and rectangles ! 5: .SH SYNOPSIS ! 6: .B #include <jerq.h> ! 7: .PP ! 8: .B Point add(p, q) ! 9: .B Point p, q; ! 10: .PP ! 11: .B Point sub(p, q) ! 12: .B Point p, q; ! 13: .PP ! 14: .B Point mul(p, a) ! 15: .B Point p; int a; ! 16: .PP ! 17: .B Point div(p, a) ! 18: .B Point p; int a; ! 19: .PP ! 20: .B int eqpt(p, q) ! 21: .B Point p, q; ! 22: .PP ! 23: .B int eqrect(r, s) ! 24: .B Rectangle r, s; ! 25: .PP ! 26: .B Rectangle inset(r, n) ! 27: .B Rectangle r; int n; ! 28: .PP ! 29: .B int muldiv(a, b, c) ! 30: .B int a, b, c; ! 31: .PP ! 32: .B int ptinrect(p, r) ! 33: .B Point p; Rectangle r; ! 34: .PP ! 35: .B Rectangle raddp(r, p) ! 36: .B Rectangle r; Point p; ! 37: .PP ! 38: .B Rectangle rsubp(r, p) ! 39: .B Rectangle r; Point p; ! 40: .PP ! 41: .B int rectXrect(r, s) ! 42: .B Rectangle r, s; ! 43: .PP ! 44: .B int rectclip(rp, s) ! 45: .B Rectangle *rp, s; ! 46: .SH DESCRIPTION ! 47: .I Add ! 48: returns the Point ! 49: sum of its arguments: ! 50: .BI Pt( p .x+ q .x, ! 51: .IB p .y+ q .y). ! 52: .I Sub ! 53: returns the Point ! 54: difference of its arguments: ! 55: .BI Pt( p .x- q .x, ! 56: .IB p .y- q .y). ! 57: .I Mul ! 58: returns the Point ! 59: .BI Pt( p .x* a , ! 60: .IB p .y* a ). ! 61: .I Div ! 62: returns the Point ! 63: .BI Pt( p .x/ a , ! 64: .IB p .y/ a ). ! 65: .PP ! 66: .I Eqpt ! 67: and ! 68: .I eqrect ! 69: compare their arguments and return ! 70: 0 if unequal, ! 71: 1 if equal. ! 72: .PP ! 73: .I Inset ! 74: returns the Rectangle ! 75: .BI Rect( r .origin.x+ n , ! 76: .IB r .origin.y+ n , ! 77: .IB r .corner.x- n , ! 78: .IB r .corner.y- n ) . ! 79: The following code creates a clear rectangle ! 80: .B r ! 81: with a 2-pixel wide border inside ! 82: .BR r : ! 83: .IP ! 84: .EX ! 85: rectf(&display, r, F_OR); ! 86: rectf(&display, inset(r, 2), F_CLR); ! 87: .EE ! 88: .PP ! 89: .I Muldiv ! 90: is a macro that returns the 16-bit result ! 91: .BI ( a * b )/ c\fR, ! 92: with ! 93: .BI ( a * b ) ! 94: calculated to 32 bits, so ! 95: no precision is lost. ! 96: .PP ! 97: .I Ptinrect ! 98: returns 1 if ! 99: .I p ! 100: is a point within ! 101: .IR r , ! 102: and 0 otherwise. ! 103: .PP ! 104: .I Raddp ! 105: returns the Rectangle ! 106: .BI Rect(add( r .origin, ! 107: .IB p ), ! 108: .BI add( r .corner, ! 109: .IB p ))\fR; ! 110: .I rsubp ! 111: returns the Rectangle ! 112: .BI Rect(sub( r .origin, ! 113: .IB p ), ! 114: .BI sub( r .corner, ! 115: .IB p ))\fR. ! 116: .PP ! 117: .I RectXrect ! 118: returns 1 if ! 119: .I r ! 120: and ! 121: .I s ! 122: share any point; 0 otherwise. ! 123: .PP ! 124: .I Rectclip ! 125: clips in place ! 126: the Rectangle pointed to by ! 127: .I rp ! 128: so that it is completely contained within ! 129: .IR s . ! 130: The return value is 1 if any part of ! 131: .RI * rp ! 132: is within ! 133: .IR s . ! 134: Otherwise, the return value is 0 and ! 135: .RI * rp ! 136: is unchanged. ! 137: .SH SEE ALSO ! 138: .IR types (9.5)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.