34 lines
544 B
C++
34 lines
544 B
C++
#ifndef RAY_H
|
|
#define RAY_H
|
|
|
|
#include "vec3.hpp"
|
|
|
|
struct ray {
|
|
/* Attributes */
|
|
point3 origin;
|
|
vec3 direction;
|
|
|
|
/* Constructors */
|
|
|
|
// Default constructor. Everything gets set to 0
|
|
ray()
|
|
{
|
|
origin = vec3();
|
|
direction = vec3();
|
|
}
|
|
|
|
ray(const point3& origin, const vec3& direction)
|
|
{
|
|
this->origin = origin;
|
|
this->direction = direction;
|
|
}
|
|
|
|
// Returns position after time t
|
|
point3 at(double t) const
|
|
{
|
|
return origin + t*direction;
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|