diff options
| author | ladevieq <ladevie.quentin@gmail.com> | 2020-12-20 22:42:37 +0100 |
|---|---|---|
| committer | ladevieq <ladevie.quentin@gmail.com> | 2020-12-20 22:42:37 +0100 |
| commit | 643708a9922cabe9b37329ee41a8668087dc92d7 (patch) | |
| tree | e4052ae5b08569d97af39afc8456852d836d6c9f /include | |
| parent | 44c1eec63fc51d1a4eb888cde5e8f4b874876bab (diff) | |
Add a camera class
Diffstat (limited to 'include')
| -rw-r--r-- | include/camera.hpp | 21 | ||||
| -rw-r--r-- | include/rt.hpp | 7 |
2 files changed, 28 insertions, 0 deletions
diff --git a/include/camera.hpp b/include/camera.hpp new file mode 100644 index 0000000..82f7155 --- /dev/null +++ b/include/camera.hpp @@ -0,0 +1,21 @@ +#ifndef __CAMERA_HPP_ +#define __CAMERA_HPP_ + +#include "rt.hpp" + +class camera { + public: + camera(point3 position, double aspect_ratio, double focal_length); + + ray get_ray(double u, double v) const; + + point3 position; + double focal_length; + + vec3 horizontal; + vec3 vertical; + + point3 bottom_left_pixel; +}; + +#endif // !__CAMERA_HPP_ diff --git a/include/rt.hpp b/include/rt.hpp index 3c37fa1..a0c912e 100644 --- a/include/rt.hpp +++ b/include/rt.hpp @@ -19,10 +19,17 @@ inline double randd(double min, double max) { return min + randd() * (max - min); } +inline double clamp(double x, double min, double max) { + if (x < min) return min; + if (x > max) return max; + return x; +} + #include "vec3.hpp" #include "ray.hpp" #include "color.hpp" #include "sphere.hpp" +#include "camera.hpp" #endif // !__RT_HPP_ |
