Ray.h

Go to the documentation of this file.
00001 
00005 #ifndef Ray_h
00006 #define Ray_h
00007 
00008 #include "Point.h"
00009 #include "Vector.h"
00010 
00011 class Ray {
00012  public:
00013   unsigned char is_neg[3];
00014   Vector inv_direction;
00015 
00016 
00017   Ray() {
00018       org = Point(0.0, 0.0, 0.0);
00019       dir = Vector::zero();
00020       inv();
00021   }
00022   Ray(const Point& origin, const Vector& direction)
00023     : org(origin), dir(direction) {
00024       inv();
00025   }
00026     
00027   ~Ray() {
00028   }
00029   Ray(const Ray& copy)
00030       : org(copy.org), dir(copy.dir) {
00031       inv();
00032   }
00033 #if 0
00034   Ray& operator=(const Ray& copy) {
00035     org = copy.org;
00036     dir = copy.dir;
00037     inv();
00038     return *this;
00039   }
00040 #endif
00041   const Point& origin() const {
00042     return org;
00043   }
00044   const Vector& direction() const {
00045     return dir;
00046   }
00047 
00048  private:
00049    Point org;
00050    Vector dir;
00051 
00052    void inv()
00053    {
00054       inv_direction = Vector(1/dir.x(), 1/dir.y(), 1/dir.z()); 
00055       is_neg[0] = ( (inv_direction.x() < 0) ? 1 : 0); 
00056       is_neg[1] = ( (inv_direction.y() < 0) ? 1 : 0); 
00057       is_neg[2] = ( (inv_direction.z() < 0) ? 1 : 0); 
00058    }
00059 
00060 
00061 };
00062 
00063 #endif

Generated on Tue Jan 29 21:34:54 2008 for specter by  doxygen 1.4.6