ft: 4: ray class + simpl gradient

This commit is contained in:
2026-04-15 12:11:04 +02:00
parent 8e96a0ba11
commit 67c1eb861d
3 changed files with 154 additions and 23 deletions

27
src/ray.rs Normal file
View File

@@ -0,0 +1,27 @@
use crate::vec3::Vec3;
pub struct Ray {
origin: Vec3,
dir: Vec3,
}
impl Ray {
pub fn at(self, t: f32) -> Vec3 {
self.origin + t * self.dir
}
pub fn new(origin: Vec3, dir: Vec3) -> Ray {
Ray {
origin: origin,
dir: dir,
}
}
pub fn origin(&self) -> &Vec3 {
&self.origin
}
pub fn dir(&self) -> &Vec3 {
&self.dir
}
}