First commit
This commit is contained in:
commit
b75663feab
7 changed files with 348 additions and 0 deletions
34
ray.hpp
Normal file
34
ray.hpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue