## matrix

matrix — Matrix manipulation and calculation

## Synopsis

    #include <g3d/matrix.h>

    typedef             G3DMatrix;
    gboolean            g3d_matrix_identity                 (G3DMatrix *matrix);
    gboolean            g3d_matrix_multiply                 (G3DMatrix *m1,
                                                             G3DMatrix *m2,
                                                             G3DMatrix *rm);
    gboolean            g3d_matrix_translate                (G3DFloat x,
                                                             G3DFloat y,
                                                             G3DFloat z,
                                                             G3DMatrix *rm);
    gboolean            g3d_matrix_rotate                   (G3DFloat angle,
                                                             G3DFloat ax,
                                                             G3DFloat ay,
                                                             G3DFloat az,
                                                             G3DMatrix *rm);
    gboolean            g3d_matrix_rotate_xyz               (G3DFloat rx,
                                                             G3DFloat ry,
                                                             G3DFloat rz,
                                                             G3DMatrix *rm);
    gboolean            g3d_matrix_scale                    (G3DFloat x,
                                                             G3DFloat y,
                                                             G3DFloat z,
                                                             G3DMatrix *rm);
    gboolean            g3d_matrix_transpose                (G3DMatrix *matrix);
    G3DFloat            g3d_matrix_determinant              (G3DMatrix *matrix);
    gboolean            g3d_matrix_dump                     (G3DMatrix *matrix);

## Description

Matrices in libg3d have the following layout:

G3DMatrix matrix[16]:

matrix[col * 4 + row] = f;

## Details

### G3DMatrix

    typedef G3DFloat G3DMatrix;

Matrix element type.

### g3d_matrix_identity ()

    gboolean            g3d_matrix_identity                 (G3DMatrix *matrix);

Sets the given matrix to the identity matrix.

`matrix` : | 4x4 matrix (float[16])
Returns : | TRUE on success, FALSE else

### g3d_matrix_multiply ()

    gboolean            g3d_matrix_multiply                 (G3DMatrix *m1,
                                                             G3DMatrix *m2,
                                                             G3DMatrix *rm);

Multiplies the matrixes.

`m1` : | first matrix
`m2` : | second matrix
`rm` : | resulting matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_translate ()

    gboolean            g3d_matrix_translate                (G3DFloat x,
                                                             G3DFloat y,
                                                             G3DFloat z,
                                                             G3DMatrix *rm);

Adds a translation to the the matrix.

`x` : | x translation
`y` : | y translation
`z` : | z translation
`rm` : | resulting matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_rotate ()

    gboolean            g3d_matrix_rotate                   (G3DFloat angle,
                                                             G3DFloat ax,
                                                             G3DFloat ay,
                                                             G3DFloat az,
                                                             G3DMatrix *rm);

Adds a rotation to the matrix.

`angle` : | rotation angle
`ax` : | x component of rotation axis
`ay` : | y component of rotation axis
`az` : | z component of rotation axis
`rm` : | resulting matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_rotate_xyz ()

    gboolean            g3d_matrix_rotate_xyz               (G3DFloat rx,
                                                             G3DFloat ry,
                                                             G3DFloat rz,
                                                             G3DMatrix *rm);

Adds a rotation around the 3 coordinate system axes to the matrix.

`rx` : | rotation around x axis
`ry` : | rotation around y axis
`rz` : | rotation around z axis
`rm` : | resulting matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_scale ()

    gboolean            g3d_matrix_scale                    (G3DFloat x,
                                                             G3DFloat y,
                                                             G3DFloat z,
                                                             G3DMatrix *rm);

Adds a scaling to the matrix.

`x` : | x factor
`y` : | y factor
`z` : | z factor
`rm` : | resulting matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_transpose ()

    gboolean            g3d_matrix_transpose                (G3DMatrix *matrix);

Transposes the matrix.

`matrix` : | the matrix
Returns : | TRUE on success, FALSE else

### g3d_matrix_determinant ()

    G3DFloat            g3d_matrix_determinant              (G3DMatrix *matrix);

Calculate the determinant of the matrix (FIXME: not verified).

`matrix` : | the matrix
Returns : | the determinant.

### g3d_matrix_dump ()

    gboolean            g3d_matrix_dump                     (G3DMatrix *matrix);

If debugging is enabled, this function dump the matrix to stderr.

`matrix` : | the matrix
Returns : | TRUE if matrix is dumped, FALSE else