src/rcrt/math/Vec3D.h

Go to the documentation of this file.
00001 #ifndef VEC3D_H_
00002 #define VEC3D_H_
00003 
00004 #include <iostream>
00005 
00006 namespace rcrt
00007 {
00008 
00009 class Vec3D
00010 {
00011         friend Vec3D operator*(const float& f, const Vec3D& vec);
00012         
00013 private:
00014         float values[3];
00015         void assign(const Vec3D& vec);
00016         
00017 public:
00018         Vec3D();
00019         Vec3D(const float& val);
00020         Vec3D(const float& xc, const float& yc, const float& zc);
00021         Vec3D(const Vec3D& vec);
00022         virtual ~Vec3D();
00023         
00024         const Vec3D& operator= (const Vec3D& vec);
00025         Vec3D operator+ (const Vec3D& vec) const;
00026         Vec3D operator- (const Vec3D& vec) const;
00027         float operator* (const Vec3D& vec) const;
00028         float operator[] (int i) const;
00029         float& operator[] (int i);
00030         bool operator!= (const Vec3D& p) const;
00031         bool operator== (const Vec3D& p) const;
00032         
00033         Vec3D operator* (const float& f) const;
00034         Vec3D operator/ (const float& f) const;
00035         
00036         Vec3D crossP(const Vec3D& vec) const;
00037         Vec3D abs() const;
00038         const Vec3D& normalize();
00039         Vec3D normalized() const;
00040         float norm() const;
00041         Vec3D reflect(const Vec3D& normal) const;
00042         void getCS(Vec3D& u, Vec3D& v) const;
00043         
00044         const float& x() const;
00045         const float& y() const;
00046         const float& z() const;
00047 };
00048 
00049 //Friends of Vec3D
00050 //we have to include these in the header
00051 
00052 inline Vec3D operator*(const float& f, const Vec3D& vec)
00053 {
00054     return Vec3D(f*vec.values[0], f*vec.values[1], f*vec.values[2]);
00055 }
00056 
00057 inline std::ostream& operator<<(std::ostream& o, const Vec3D& v)
00058 {
00059         o << "V3D(" << v.x() << "," << v.y() << "," << v.z() << ")";
00060         return o;
00061 }
00062 
00063 
00064 }
00065 
00066 #endif /*VEC3D_H_*/

Generated on Thu Jan 31 19:26:19 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3