Files
raytracing/src/ray.rs
2026-05-03 14:58:56 +02:00

25 lines
378 B
Rust

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