diff options
author | Keuin <[email protected]> | 2022-04-11 22:13:57 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-11 22:13:57 +0800 |
commit | 43714bd116945573e7e4c854445462afa7f9b1b4 (patch) | |
tree | 7570dd1ab5e0feb38e504b4a49f4e8d2d0774873 /ray.h | |
parent | f6661b0243cb359fb4929aee06d1247944f3d2dd (diff) |
Implement ray3, timer and a simple viewport scanner.
Fix bitmap wrong pixel sequence.
Remove default constructor of bitmap.
Add pixel mixture method.
Diffstat (limited to 'ray.h')
-rw-r--r-- | ray.h | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -0,0 +1,36 @@ +// +// 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<typename T> +class ray3 { + const vec3<T> source_; + const vec3<T> direction_; // unit vector + +public: + ray3() = delete; + ray3(const vec3<T> &source, const vec3<T> &direction) : source_(source), direction_(direction.unit_vec()) {} + + vec3<T> source() const { + return source_; + } + + vec3<T> direction() const { + return direction_; + } + + template<typename U> + vec3<T> at(U t) const { + return source_ + direction_ * t; + } +}; + +using ray3d = ray3<double>; + +#endif //RT_RAY_H |