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 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 x: R3.T; READONLY m: T): R3.T; (* Returns the product of row vector "x" by matrix "m". *) PROCEDURE MapCol(READONLY m: T; READONLY x: R3.T): R3.T; (* Returns the product of matrix "m" by column vector "x". *) 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 the 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(READONLY axis: R3.T; angle: REAL): 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 end of "axis" looking towards the origin. For a pure rotation, the "axis" vector must have unit length. Otherwise the result will be a similarity matrix whose scaling factor is the length of "axis", squared. *) PROCEDURE Print(wr: Wr.T; READONLY m: T); (* Prints the matrix to the given writer. *) END R3x3.