Changed UI and integrated rays into camera

This commit is contained in:
STP
2023-11-25 03:15:59 -05:00
parent ab284e8e98
commit 137fb9f6d7
10 changed files with 313 additions and 183 deletions

View File

@@ -6,6 +6,7 @@ use crate::{
};
use nalgebra::{Point3, Unit, Vector3};
#[derive(Clone)]
pub struct Ray {
pub a: Point3<f32>,
pub b: Unit<Vector3<f32>>,
@@ -15,6 +16,11 @@ impl Ray {
pub fn new(a: Point3<f32>, b: Unit<Vector3<f32>>) -> Ray {
Ray { a, b }
}
pub fn unit() -> Ray {
let a = Point3::new(0.0, 0.0, 0.0);
let b = Unit::new_normalize(Vector3::new(0.0, 1.0, 0.0));
Ray { a, b }
}
pub fn at_t(&self, t: f32) -> Point3<f32> {
self.a + self.b.into_inner() * (t + EPSILON)
}