INTERFACE RT2; (* Real oriented projective geometry in two dimensions. Created 93-04-18 by Marcos C. Carrard. Based on H3.pas by J. Stolfi. Last edited by stolfi *) IMPORT R2, R3, R3x3; TYPE Point = RECORD c: R3.T END; (* c[0..2] are coords [w,x,y]. *) Line = RECORD f: R3.T END; (* f[0..2] are coeffs . *) Sign = [-1..1]; PROCEDURE FromCartesian(READONLY c: R2.T): Point; (* Point on "hither" side of space (i.e, with positive weight) whose Cartesian coordinates are "c". *) PROCEDURE ToCartesian(READONLY p: Point): R2.T; (* Cartesian coordinates of point "p" (which must be finite). *) PROCEDURE Test(READONLY p: Point; READONLY Q: Line): Sign; (* Returns sign of point "p" relative to line "Q": 0 on the line, +1 in positive halfplane, -1 in negative halfplane. May give inconsistent results for points very close to the line. *) PROCEDURE Join(READONLY p, q: Point): Line; (* Return the line through "p" and "q". *) PROCEDURE Meet(READONLY P, Q: Line): Point; (* Return the point common to "P" and "Q". *) PROCEDURE Dir(READONLY frm, tto: Point): R2.T; (* Direction (a unit-length vector) of point "tto" seen from point "frm". Works even if one of them is at infinity. Does not work if both are at infinity, or coincident, or antipodal. *) PROCEDURE Normal(READONLY P: Line): R2.T; (* The normal direction of line "P", on the hither side of T3, pointing into "P"'s positive halfspace. Assumes "P" is not the line at infinity. *) (* PROJECTIVE MAPS *) TYPE PMap = RECORD dir: R3x3.T; inv: R3x3.T END; (* "dir" is the map's matrix, "inv" is its inverse. *) PROCEDURE MapPoint(READONLY p: Point; READONLY m: PMap): Point; (* Applies projective map "m" to point "p". *) PROCEDURE MapLine(READONLY P: Line; READONLY m: PMap): Line; (* Applies projective map "m" to line "P" *) PROCEDURE CompMap(READONLY m, n: PMap): PMap; (* Returns the composition of "m" and "n", applied in that order *) END RT2.