Renderer/src/ray.rs

26 lines
398 B
Rust
Raw Permalink Normal View History

2022-04-20 18:58:58 +02:00
use super::Point3;
use super::Vec3;
pub struct Ray {
pub orig: Point3,
2022-04-20 18:59:29 +02:00
pub dir: Vec3,
2022-04-20 18:58:58 +02:00
}
impl Ray {
pub fn new(o: Point3, d: Vec3) -> Ray {
Ray { orig: o, dir: d }
}
pub fn origin(&self) -> Point3 {
self.orig
}
pub fn direction(&self) -> Vec3 {
self.dir
}
pub fn at(&self, t: f64) -> Point3 {
2022-04-20 18:59:29 +02:00
self.orig + t * self.dir
2022-04-20 18:58:58 +02:00
}
2022-04-20 18:59:29 +02:00
}