INTERFACE R3x3; (* Operations on 3x3 matrices: linear maps of R^3. Created 93-04-31 by Marcos C. Carrard. Based on R3x3.pas by J. Stolfi. Last edited by stolfi *) IMPORT R3, Wr; TYPE T = ARRAY [0..2], [0..2] OF REAL; CONST N = 3; Null = T{R3.Zero, ..}; Identity = T{ R3.T{1.0, 0.0, 0.0}, R3.T{0.0, 1.0, 0.0}, R3.T{0.0, 0.0, 1.0} }; PROCEDURE MapRow(READONLY a: R3.T; READONLY m: T): R3.T; (* Returns the product of row vector "a" by the matrix "m". *) PROCEDURE MapCol(READONLY m: T; READONLY a: R3.T): R3.T; (* Returns the product of matrix "m" by the column vector "a". *) PROCEDURE Mul(READONLY m, n: T): T; (* Returns the product of matrices "m" and "n", in that order. *) PROCEDURE Det(READONLY m: T): LONGREAL; (* Returns the determinant of matrix "m". *) PROCEDURE Inv(READONLY m: T): T; (* Returns the inverse of matrix "m". Assumes its determinant is non-zero. *) PROCEDURE Adj(READONLY m: T): T; (* Returns the adjoint of matrix "m", such that "m * result = I * Det(m)" *) PROCEDURE Rotation(angle: LONGREAL; READONLY axis: R3.T): T; (* Returns an orthonormal matrix "R" such that "RowMul(v, R)" is "v" rotated by "angle" radians around the unit vector "axis". A positive "angle" means counterclockwise as seen from the tip of "axis" and looking towards the origin. Thus, for example, "Rotation(Pi/2, (0,0,1))" will take "(1,0,0)" to "(0,1,0)". If the "axis" vector doesn't have unit length, the result will be a similarity matrix whose scaling factor is the length of "axis", squared. *) PROCEDURE Print(wr: Wr.T; READONLY m: T; indent: CARDINAL := 0); (* Prints the matrix to the given writer. Indents continuation lines by at least "indent" blanks. *) END R3x3.