INTERFACE RT3; (* Oriented projective geometry in three dimensions. Created 93-04-18 by Marcos C. Carrard. Based on H3.pas by J. Stolfi. Last edited by stolfi *) IMPORT R3, R4, R4x4; TYPE Point = RECORD c: R4.T END; (* c[0..3] are coords [w,x,y,z]. *) Plane = RECORD f: R4.T END; (* f[0..3] are coeffs . *) Sign = [-1..1]; PROCEDURE FromCartesian(READONLY c: R3.T): Point; (* Point on "hither" side of space (i.e, with positive weight) whose Cartesian coordinates are "c". *) PROCEDURE ToCartesian(READONLY p: Point): R3.T; (* Cartesian coordinates of point "p" (which must be finite). *) PROCEDURE Test(READONLY p: Point; READONLY Q: Plane): Sign; (* Returns sign of point "p" relative to plane "Q": 0 on the plane, +1 in positive halfspace, -1 in negative halfspace. May give inconsistent results for points very close to the plane. *) PROCEDURE Join(READONLY p, q, r: Point): Plane; (* Return the plane through "p", "q", and "r". *) PROCEDURE Meet(READONLY P, Q, R: Plane): Point; (* Return the point common to "P", "Q", and "R". *) PROCEDURE Dir(READONLY frm, tto: Point): R3.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: Plane): R3.T; (* The normal direction of plane "P", on the hither side of T3, pointing into "P"'s positive halfspace. Assumes "P" is not the plane at infinity. *) (* PROJECTIVE MAPS *) TYPE PMap = RECORD dir: R4x4.T; inv: R4x4.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 MapPlane(READONLY P: Plane; READONLY m: PMap): Plane; (* Applies projective map "m" to plane "P" *) PROCEDURE CompMap(READONLY m, n: PMap): PMap; (* Returns the composition of "m" and "n", applied in that order *) PROCEDURE PerspMap(READONLY obs, foc, upp: Point): PMap; (* Computes a perspective transformation with given viewing parameters. obs => the scenesys coords of imagesys (0,0,d) (observer) foc => the scenesys coords of imagesys (0,0,0) (image focus) up => the scenesys coords of some point with imagesys X = 0 (up reference). *) END RT3.