matrix

matrix — Matrix manipulation and calculation

Functions

gboolean g3d_matrix_identity ()
gboolean g3d_matrix_multiply ()
gboolean g3d_matrix_translate ()
gboolean g3d_matrix_rotate ()
gboolean g3d_matrix_rotate_xyz ()
gboolean g3d_matrix_scale ()
gboolean g3d_matrix_transpose ()
G3DFloat g3d_matrix_determinant ()
gboolean g3d_matrix_dump ()

Types and Values

typedef G3DMatrix

Includes

#include <g3d/matrix.h>

Description

Matrices in libg3d have the following layout:

G3DMatrix matrix[16]:

matrix[col * 4 + row] = f;

Functions

g3d_matrix_identity ()

gboolean
g3d_matrix_identity (G3DMatrix *matrix);

Sets the given matrix to the identity matrix.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

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).

Parameters

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.

Parameters

matrix

the matrix

 

Returns

TRUE if matrix is dumped, FALSE else

Types and Values

G3DMatrix

typedef G3DFloat G3DMatrix;

Matrix element type.