Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ray.h

Go to the documentation of this file.
00001 // ray.h
00002 //
00003 // Copyright (C) 2002, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
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 

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1