rsrt/src/ray.rs

25 lines
392 B
Rust

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