diff options
author | Yann Herklotz <git@yannherklotz.com> | 2020-04-26 21:15:53 +0100 |
---|---|---|
committer | Yann Herklotz <git@yannherklotz.com> | 2020-04-26 21:15:53 +0100 |
commit | 9f4cdae92c8df0a7990fdb77d9ff161b2eebf467 (patch) | |
tree | eb1e8c4de3b6040859c88fb8c2ea69580a73ec10 /src/camera.rs | |
download | leela-9f4cdae92c8df0a7990fdb77d9ff161b2eebf467.tar.gz leela-9f4cdae92c8df0a7990fdb77d9ff161b2eebf467.zip |
Add initial files
Diffstat (limited to 'src/camera.rs')
-rw-r--r-- | src/camera.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/camera.rs b/src/camera.rs new file mode 100644 index 0000000..8090bde --- /dev/null +++ b/src/camera.rs @@ -0,0 +1,25 @@ +use cgmath::{Vector3, vec3}; +use crate::ray::Ray; + +pub struct Camera { + origin: Vector3<f64>, + lower_left_corner: Vector3<f64>, + horizontal: Vector3<f64>, + vertical: Vector3<f64> +} + +impl Camera { + pub fn new() -> Camera { + Camera { + origin: vec3(0.0, 0.0, 0.0), + lower_left_corner: vec3(-2.0, -1.0, -1.0), + horizontal: vec3(4.0, 0.0, 0.0), + vertical: vec3(0.0, 2.0, 0.0) + } + } + + pub fn get_ray(&self, u: f64, v: f64) -> Ray { + Ray::new(self.origin, + self.lower_left_corner + u * self.horizontal + v * self.vertical) + } +} |