//---------------------------------------------------------------------------- // William Baxter III's Ray Tracer // // Project for Comp 238, Raster Graphics // University of North Carolina at Chapel Hill // // $Id:$ //---------------------------------------------------------------------------- #ifndef RAY3F_H #define RAY3F_H #include class Ray3f { public: Ray3f(); Ray3f(const Vec3f& direction); Ray3f(const Vec3f& origin, const Vec3f& direction); ~Ray3f() {}; void Set(const Vec3f& origin, const Vec3f& direction); const Vec3f& P() const; // pt of application const Vec3f& V() const; // direction void Normalize(); // normalize direction vector // Return the point t units down a normalized ray Vec3f operator [] (const float t) const; Ray3f& operator = (const Ray3f& r); public: Vec3f m_p; // point of application Vec3f m_v; // direction }; //---------------------------------------------------------------------------- inline Ray3f::Ray3f() {} //---------------------------------------------------------------------------- inline Ray3f::Ray3f(const Vec3f& direction) : m_v(direction) {} //---------------------------------------------------------------------------- inline Ray3f::Ray3f(const Vec3f& origin, const Vec3f& direction) : m_p(origin), m_v(direction) {} //---------------------------------------------------------------------------- inline void Ray3f::Set(const Vec3f& origin, const Vec3f& direction) { m_p = origin; m_v = direction; } //---------------------------------------------------------------------------- inline const Vec3f& Ray3f::P() const { return m_p; } //---------------------------------------------------------------------------- inline const Vec3f& Ray3f::V() const { return m_v; } //---------------------------------------------------------------------------- inline void Ray3f::Normalize() { m_v.Normalize(); } //---------------------------------------------------------------------------- inline Vec3f Ray3f::operator [] (const float t) const { Vec3f ret(m_p + t*m_v); return ret; } //---------------------------------------------------------------------------- inline Ray3f& Ray3f::operator = (const Ray3f& r) { m_p = r.m_p; m_v = r.m_v; return *this; } //---------------------------------------------------------------------------- #endif