// ray.h // // Copyright (C) 2002, Chris Laurel // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. #ifndef _CELMATH_RAY_H_ #define _CELMATH_RAY_H_ #include "vecmath.h" template class Ray3 { public: Ray3(); Ray3(const Point3&, const Vector3&); Point3 point(T) const; public: Point3 origin; Vector3 direction; }; typedef Ray3 Ray3f; typedef Ray3 Ray3d; template Ray3::Ray3() : origin(0, 0, 0), direction(0, 0, -1) { } template Ray3::Ray3(const Point3& _origin, const Vector3& _direction) : origin(_origin), direction(_direction) { } template Point3 Ray3::point(T t) const { return origin + direction * t; } template Ray3 operator*(const Ray3& r, const Matrix3& m) { return Ray3(r.origin * m, r.direction * m); } template Ray3 operator*(const Ray3& r, const Matrix4& m) { return Ray3(r.origin * m, r.direction * m); } #endif // _CELMATH_RAY_H_