00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _CELMATH_RAY_H_
00011 #define _CELMATH_RAY_H_
00012
00013 #include "vecmath.h"
00014
00015 template<class T> class Ray3
00016 {
00017 public:
00018 Ray3();
00019 Ray3(const Point3<T>&, const Vector3<T>&);
00020
00021 Point3<T> point(T) const;
00022
00023 public:
00024 Point3<T> origin;
00025 Vector3<T> direction;
00026 };
00027
00028 typedef Ray3<float> Ray3f;
00029 typedef Ray3<double> Ray3d;
00030
00031
00032 template<class T> Ray3<T>::Ray3() :
00033 origin(0, 0, 0), direction(0, 0, -1)
00034 {
00035 }
00036
00037 template<class T> Ray3<T>::Ray3(const Point3<T>& _origin,
00038 const Vector3<T>& _direction) :
00039 origin(_origin), direction(_direction)
00040 {
00041
00042 }
00043
00044 template<class T> Point3<T> Ray3<T>::point(T t) const
00045 {
00046 return origin + direction * t;
00047 }
00048
00049 template<class T> Ray3<T> operator*(const Ray3<T>& r, const Matrix3<T>& m)
00050 {
00051 return Ray3<T>(r.origin * m, r.direction * m);
00052 }
00053
00054 template<class T> Ray3<T> operator*(const Ray3<T>& r, const Matrix4<T>& m)
00055 {
00056 return Ray3<T>(r.origin * m, r.direction * m);
00057 }
00058
00059 #endif // _CELMATH_RAY_H_
00060