raytracer/src/ray.rs

25 lines
433 B
Rust

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