istereo

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