istereo
diff libs/vmath/ray_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/ray_c.c Thu Sep 08 08:30:42 2011 +0300 1.3 @@ -0,0 +1,18 @@ 1.4 +#include "ray.h" 1.5 +#include "vector.h" 1.6 + 1.7 +ray_t ray_transform(ray_t r, mat4_t xform) 1.8 +{ 1.9 + mat4_t upper; 1.10 + vec3_t dir; 1.11 + 1.12 + m4_copy(upper, xform); 1.13 + upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0; 1.14 + upper[3][3] = 1.0; 1.15 + 1.16 + dir = v3_sub(r.dir, r.origin); 1.17 + dir = v3_transform(dir, upper); 1.18 + r.origin = v3_transform(r.origin, xform); 1.19 + r.dir = v3_add(dir, r.origin); 1.20 + return r; 1.21 +}