INTERFACE R2; (* Linear algebra and analytic geometry in R^2. Created 94-04-18 by Jorge Stolfi. Based on R3.pas by J. Stolfi. Last edited by stolfi *) IMPORT Wr; TYPE T = ARRAY [0..1] OF REAL; CONST Zero = T{0.0, ..}; Ones = T{1.0, ..}; Axis = ARRAY [0..1] OF T{ T{1.0, 0.0}, T{0.0, 1.0} }; PROCEDURE Add(READONLY x, y: T): T; (* Returns "x + y". *) PROCEDURE Sub(READONLY x, y: T): T; (* Returns "x - y". *) PROCEDURE Neg(READONLY x: T): T; (* Returns "-x" *) PROCEDURE Scale(s: REAL; READONLY x: T): T; (* Returns "s * x"; *) PROCEDURE Length(READONLY x: T): REAL; (* Returns the Euclidean norm (length) of "x". May overflow. *) PROCEDURE LInfLength(READONLY x: T): REAL; (* Returns the L_infinity norm of "x", i.e. the max absolute coordinate. *) PROCEDURE LengthSqr(READONLY x: T): LONGREAL; (* Returns the square of the Euclidean length of "x", i.e. Dot(x,x). *) PROCEDURE Dist(READONLY x, y: T): REAL; (* Returns the Euclidean distance between "x" and "y". May overflow. *) PROCEDURE DistSqr(READONLY x, y: T): LONGREAL; (* Returns the square of the Euclidean distance between "x" and "y". *) PROCEDURE Reduce(READONLY x: T): T; (* Returns "x" scaled to unit Euclidean *) PROCEDURE LInfReduce(READONLY x: T): T; (* Returns "x" scaled to unit L_infinity norm *) PROCEDURE Dot(READONLY x, y: T): LONGREAL; (* Returns the dot product of "x" and "y" *) PROCEDURE Orthize(READONLY x, u: T): T; (* Returns the component of "x" that is orthogonal to "u". *) PROCEDURE Print(wr: Wr.T; READONLY x: T); (* Prints "x" to the given writer. *) END R2.