istereo
diff libs/vmath/basis_c.c @ 28:c0ae8e668447
added vmath library
author | John Tsiombikas <nuclear@mutantstargoat.com> |
---|---|
date | Thu, 08 Sep 2011 08:30:42 +0300 |
parents | |
children | ff055bff6a15 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/vmath/basis_c.c Thu Sep 08 08:30:42 2011 +0300 1.3 @@ -0,0 +1,19 @@ 1.4 +#include "basis.h" 1.5 +#include "matrix.h" 1.6 + 1.7 +void basis_matrix(mat4_t res, vec3_t i, vec3_t j, vec3_t k) 1.8 +{ 1.9 + m4_identity(res); 1.10 + m4_set_column(res, v4_cons(i.x, i.y, i.z, 1.0), 0); 1.11 + m4_set_column(res, v4_cons(j.x, j.y, j.z, 1.0), 1); 1.12 + m4_set_column(res, v4_cons(k.x, k.y, k.z, 1.0), 2); 1.13 +} 1.14 + 1.15 +void basis_matrix_dir(mat4_t res, vec3_t dir) 1.16 +{ 1.17 + vec3_t k = v3_normalize(dir); 1.18 + vec3_t j = {0, 1, 0}; 1.19 + vec3_t i = v3_cross(j, k); 1.20 + j = v3_cross(k, i); 1.21 + basis_matrix(res, i, j, k); 1.22 +}