rayzor
view src/vmathray.h @ 20:6b11a3f8706e
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Apr 2014 01:36:03 +0300 |
parents | 964f8ea5f095 |
children |
line source
1 #ifndef VMATH_RAY_H_
2 #define VMATH_RAY_H_
4 #include "vmath.h"
5 #include "vmathmat.h"
7 class Ray {
8 public:
9 Vector3 origin, dir;
11 Ray() {}
12 Ray(const Vector3 &p, const Vector3 &d) : origin(p), dir(d) {}
13 };
15 inline Ray transform(const Matrix4x4 &m, const Ray &r)
16 {
17 Matrix4x4 rmat = m;
18 rmat[0][3] = rmat[1][3] = rmat[2][3] = rmat[3][0] = rmat[3][1] = rmat[3][2] = 0.0;
19 rmat[3][3] = 1.0;
21 return Ray(transform(m, r.origin), transform(rmat, r.dir));
22 }
24 #endif // VMATH_RAY_H_