aboutsummaryrefslogtreecommitdiffstats
path: root/src/camera.rs
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-04-26 21:15:53 +0100
committerYann Herklotz <git@yannherklotz.com>2020-04-26 21:15:53 +0100
commit9f4cdae92c8df0a7990fdb77d9ff161b2eebf467 (patch)
treeeb1e8c4de3b6040859c88fb8c2ea69580a73ec10 /src/camera.rs
downloadleela-9f4cdae92c8df0a7990fdb77d9ff161b2eebf467.tar.gz
leela-9f4cdae92c8df0a7990fdb77d9ff161b2eebf467.zip
Add initial files
Diffstat (limited to 'src/camera.rs')
-rw-r--r--src/camera.rs25
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)
+ }
+}