Cube.h
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @class Cube 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Representation of a unit cube in 3-space from (-.5,-.5,-.5) to (.5,.5,.5) 00009 <!-------------------------------------------------------------------->**/ 00010 00011 #ifndef CUBE_H_ 00012 #define CUBE_H_ 00013 00014 #include <shapes/Implicit.h> 00015 00016 class Cube : public Implicit { 00017 public: 00018 ///@name Intersection routines 00019 //@{----------------------------------------------------------------- 00020 00021 virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt); 00022 00023 virtual bool intersects(const Ray &ray, real_t tMax = INFINITY); 00024 00025 00026 //@}----------------------------------------------------------------- 00027 ///@name Core functionality 00028 //@{----------------------------------------------------------------- 00029 00030 virtual void preview(); 00031 00032 00033 //@}----------------------------------------------------------------- 00034 00035 protected: 00036 virtual void _getUV(SurfacePoint &pt) const; 00037 virtual void _getGeometricNormal(SurfacePoint &pt) const; 00038 00039 /** 00040 * @returns the total surface area of this shape 00041 */ 00042 virtual real_t _getSurfaceArea(); 00043 00044 inline real_t _parallelogramArea(const Vector3 &b1, const Vector3 &b2) { 00045 return b1.cross(b2).getMagnitude(); 00046 // area = |b1| * |b2| * sin(theta), theta = acos(b1.norm, b2.norm) 00047 //return b1.getMagnitude() * b2.getMagnitude() * 00048 // sin(acos(b1.getNormalized().dot(b2.getNormalized()))); 00049 } 00050 }; 00051 00052 #endif // CUBE_H_ 00053
Generated on 28 Feb 2009 for Milton by
1.5.6