Renderer/src/ray.rs

25 lines
394 B
Rust
Raw Normal View History

2022-04-20 18:58:58 +02:00
use super::Point3;
use super::Vec3;
pub struct Ray {
pub orig: Point3,
pub dir: Vec3
}
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 {
self.orig + t*self.dir
}
}