-
-
Notifications
You must be signed in to change notification settings - Fork 0
Matrix4 Translate
Kion edited this page Sep 16, 2017
·
1 revision

Translates a given mat4 matrix by a vec3.
- mat4 m - the matrix to be translated
- vec3 t - x, y, z vector 3 to translate by
- mat4 dst - destination mat4
void mat4_translate(mat4 m, vec3 t, mat4 dst) {
mat4 tmp;
mat4_identity(dst);
tmp[M_00] = 1.0f;
tmp[M_10] = 0.0f;
tmp[M_20] = 0.0f;
tmp[M_30] = 0.0f;
tmp[M_01] = 0.0f;
tmp[M_11] = 1.0f;
tmp[M_21] = 0.0f;
tmp[M_31] = 0.0f;
tmp[M_02] = 0.0f;
tmp[M_12] = 0.0f;
tmp[M_22] = 1.0f;
tmp[M_32] = 0.0f;
tmp[M_03] = t[0];
tmp[M_13] = t[1];
tmp[M_23] = t[2];
tmp[M_33] = 1.0f;
mat4_multiply(m, tmp, dst);
}