Matrix

#include <graphics/matrix4.h>
struct matrix4

Matrix structure

struct vec4 matrix4.x

X component vector

struct vec4 matrix4.y

Y component vector

struct vec4 matrix4.z

Z component vector

struct vec4 matrix4.w

W component vector


void matrix4_copy(struct matrix4 *dst, const struct matrix4 *m)

Copies a matrix

Parameters:
  • dst – Destination matrix

  • m – Matrix to copy


void matrix4_identity(struct matrix4 *dst)

Sets an identity matrix

Parameters:
  • dst – Destination matrix


void matrix4_from_quat(struct matrix4 *dst, const struct quat *q)

Converts a quaternion to a matrix

Parameters:
  • dst – Destination matrix

  • q – Quaternion to convert


void matrix4_from_axisang(struct matrix4 *dst, const struct axisang *aa)

Converts an axis angle to a matrix

Parameters:
  • dst – Destination matrix

  • aa – Axis angle to convert


void matrix4_mul(struct matrix4 *dst, const struct matrix4 *m1, const struct matrix4 *m2)

Multiples two matrices

Parameters:
  • dst – Destination matrix

  • m1 – Matrix 1

  • m2 – Matrix 2


float matrix4_determinant(const struct matrix4 *m)

Gets the determinant value of a matrix

Parameters:
  • m – Matrix

Returns:

Determinant


void matrix4_translate3v(struct matrix4 *dst, const struct matrix4 *m, const struct vec3 *v)
void matrix4_translate3f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z)

Translates the matrix by a 3-component vector

Parameters:
  • dst – Destination matrix

  • m – Matrix to translate

  • v – Translation vector


void matrix4_translate4v(struct matrix4 *dst, const struct matrix4 *m, const struct vec4 *v)

Translates the matrix by a 4-component vector

Parameters:
  • dst – Destination matrix

  • m – Matrix to translate

  • v – Translation vector


void matrix4_rotate(struct matrix4 *dst, const struct matrix4 *m, const struct quat *q)

Rotates a matrix by a quaternion

Parameters:
  • dst – Destination matrix

  • m – Matrix to rotate

  • q – Rotation quaternion


void matrix4_rotate_aa(struct matrix4 *dst, const struct matrix4 *m, const struct axisang *aa)
void matrix4_rotate_aa4f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z, float rot)

Rotates a matrix by an axis angle

Parameters:
  • dst – Destination matrix

  • m – Matrix to rotate

  • aa – Rotation anxis angle


void matrix4_scale(struct matrix4 *dst, const struct matrix4 *m, const struct vec3 *v)
void matrix4_scale3f(struct matrix4 *dst, const struct matrix4 *m, float x, float y, float z)

Scales each matrix component by the components of a 3-component vector

Parameters:
  • dst – Destination matrix

  • m – Matrix to scale

  • v – Scale vector


bool matrix4_inv(struct matrix4 *dst, const struct matrix4 *m)

Inverts a matrix

Parameters:
  • dst – Destination matrix

  • m – Matrix to invert


void matrix4_transpose(struct matrix4 *dst, const struct matrix4 *m)

Transposes a matrix

Parameters:
  • dst – Destination matrix

  • m – Matrix to transpose