These have similar functionality to the corresponding 3D functions. Only those which are different are commented on here.

void *mat2_alloc(void) void *mat2_make(Mat2 n) void mat2_free(void *m) Mat2 mat2(double mxx, double mxy, double myx, double myy) Mat2 mat2_unit(void) Mat2 mat2_zero(void) void mat2_comps(Mat2 m, float *mxx, float *mxy, float *myx, float *myy) Vec2 mat2_rowx(Mat2 m) Vec2 mat2_rowy(Mat2 m) Vec2 mat2_colx(Mat2 m) Vec2 mat2_coly(Mat2 m) Mat2 mat2_of_rows(Vec2 rx, Vec2 ry) Mat2 mat2_of_cols(Vec2 cx, Vec2 cy) Mat2 mat2_sum(Mat2 m, Mat2 n) Mat2 mat2_diff(Mat2 m, Mat2 n) Mat2 mat2_prod(Mat2 m, Mat2 n) Mat2 mat2_times(double k, Mat2 m)

Mat2 mat2_minus(Mat2 m) Mat2 mat2_inverse(Mat2 m) Mat2 mat2_transpose(Mat2 m) double mat2_trace(Mat2 m) double mat2_det(Mat2 m) Bool mat2_posdef(Mat2 m) Vec2 mat2_vprod(Mat2 m, Vec2 v) double mat2_sprod(Vec2 v, Mat2 m, Vec2 w) Mat2 mat2_tensor(Vec2 v, Vec2 w) Mat2 mat2_read(FILE *fp) void mat2_print(FILE *fp, Mat2 m) void mat2_pprint(FILE *fp, char *msg, Mat2 m) void mat2_format(Mat2 m)

Transformations (Rotations and Translations) in 3D

Rotations are represented by 3-Matrices (Mat3's, see above) of the active rotation i.e. the rotation represented by a matrix R takes the position x to the position Rx.

Functions have been supplied to return the matrix of a rotation with given angle and axis, and to recover the angle and axis from a rotation.

Rigid motions are represented by a Transform3 structure

typedef struct transf3 { Ts_id ts_id; /* Tina structure identifier */ unsigned int type; unsigned int label; Transform3 T; struct list *props; } Transf3;

which represents a rotation R followed by a translation t

x -> Rx+t .

Functions for applying a transform or its inverse to a vector have been supplied. As well as functions for representing the action in terms of coordinate frames.

Alternative representations, such as quaternions for rotations or 4x4 matrices for transformations were considered and rejected. Those adopted seem to offer the correct combination of convenience and simplicity.