istereo

view 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 source
1 #include "ray.h"
2 #include "vector.h"
4 ray_t ray_transform(ray_t r, mat4_t xform)
5 {
6 mat4_t upper;
7 vec3_t dir;
9 m4_copy(upper, xform);
10 upper[0][3] = upper[1][3] = upper[2][3] = upper[3][0] = upper[3][1] = upper[3][2] = 0.0;
11 upper[3][3] = 1.0;
13 dir = v3_sub(r.dir, r.origin);
14 dir = v3_transform(dir, upper);
15 r.origin = v3_transform(r.origin, xform);
16 r.dir = v3_add(dir, r.origin);
17 return r;
18 }