/******************************************************************/ /* This file is part of the homework assignments for CSCI-427/527 */ /* at The College of William & Mary and authored by Pieter Peers. */ /* No part of this file, whether altered or in original form, can */ /* be distributed or used outside the context of CSCI-427/527 */ /* without consent of either the College of William & Mary or */ /* Pieter Peers. */ /******************************************************************/ #ifndef _RAY_H_ #define _RAY_H_ #include #include "vec3d.h" #include "transformation3d.h" class ray { public: ////////////////// // Constructors // ////////////////// ray(const vec3d& origin = vec3d(), const vec3d& direction = vec3d()); ray(const ray& src); //////////////// // Inspectors // //////////////// const vec3d& origin(void) const { return _origin; } const vec3d& direction(void) const { return _direction; } /////////////// // Operators // /////////////// ray& operator=(const ray& r); vec3d operator()(float t) const; float operator()(const vec3d& point) const; ////////////// // Mutators // ////////////// ray& transform(const transformation3d& t); ray& inverseTransform(const transformation3d& t); ///////////// // Friends // ///////////// friend void swap(ray& a, ray& b) { a._swap(b); } friend ray transform(const ray& r, const transformation3d& t) { return ray(r).transform(t); } friend ray inverseTransform(const ray& r, const transformation3d& t) { return ray(r).inverseTransform(t); } friend std::ostream& operator<<(std::ostream& s, const ray& r) { s << r.origin() << "->" << r.direction(); return s; } private: ///////////////////// // Private Methods // ///////////////////// void _swap(ray& r); void _assign(const ray& r); ////////////////// // Data Members // ////////////////// vec3d _origin; vec3d _direction; }; #endif /* _RAY_H_ */