Renderer/src/ray.rs
Jonathan Flueren 91876b66dd more new stuff
2022-04-20 19:05:56 +02:00

25 lines
398 B
Rust

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
}
}