13 Ray() : dir(0, 0, 1) {}
14 Ray(const Vector3 &o, const Vector3 &d) : origin(o), dir(d) {}
17 inline Ray operator *(const Ray &r, const Matrix4x4 &m)
20 up[0][3] = up[1][3] = up[2][3] = up[3][0] = up[3][1] = up[3][2] = 0.0;
23 return Ray(r.origin * m, r.dir * up);
26 inline Ray operator *(const Matrix4x4 &m, const Ray &r)
29 up[0][3] = up[1][3] = up[2][3] = up[3][0] = up[3][1] = up[3][2] = 0.0;
32 return Ray(m * r.origin, m * r.dir);
36 inline Ray reflect(const Ray &ray, const Vector3 &n)
38 return Ray(ray.origin, reflect(ray.dir, n));
41 inline Ray refract(const Ray &ray, const Vector3 &n, float ior)
43 return Ray(ray.origin, refract(ray.dir, n, ior));
46 inline Ray refract(const Ray &ray, const Vector3 &n, float from_ior, float to_ior)
48 return Ray(ray.origin, refract(ray.dir, n, from_ior, to_ior));
54 #endif // GMATH_RAY_H_