istereo

view libs/vmath/basis_c.c @ 36:834503dcb486

fixed the rotated gui problem
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 09 Sep 2011 10:25:03 +0300
parents
children ff055bff6a15
line source
1 #include "basis.h"
2 #include "matrix.h"
4 void basis_matrix(mat4_t res, vec3_t i, vec3_t j, vec3_t k)
5 {
6 m4_identity(res);
7 m4_set_column(res, v4_cons(i.x, i.y, i.z, 1.0), 0);
8 m4_set_column(res, v4_cons(j.x, j.y, j.z, 1.0), 1);
9 m4_set_column(res, v4_cons(k.x, k.y, k.z, 1.0), 2);
10 }
12 void basis_matrix_dir(mat4_t res, vec3_t dir)
13 {
14 vec3_t k = v3_normalize(dir);
15 vec3_t j = {0, 1, 0};
16 vec3_t i = v3_cross(j, k);
17 j = v3_cross(k, i);
18 basis_matrix(res, i, j, k);
19 }