// // Created by Keuin on 2022/4/11. // #ifndef RT_RAY_H #define RT_RAY_H #include "vec.h" // A ray is a half-line, starts from a 3d point, along the direction of a unit vector, to the infinity template class ray3 { const vec3 source_; const vec3 direction_; // unit vector public: ray3() = delete; ray3(const vec3 &source, const vec3 &direction) : source_(source), direction_(direction.unit_vec()) {} vec3 source() const { return source_; } vec3 direction() const { return direction_; } template vec3 at(U t) const { return source_ + direction_ * t; } }; using ray3d = ray3; #endif //RT_RAY_H