28 lines
424 B
Rust
28 lines
424 B
Rust
use crate::vec3::Vec3;
|
|
|
|
pub struct Ray {
|
|
origin: Vec3,
|
|
dir: Vec3,
|
|
}
|
|
|
|
impl Ray {
|
|
pub fn new(origin: Vec3, dir: Vec3) -> Self {
|
|
Self {
|
|
origin: origin,
|
|
dir: dir,
|
|
}
|
|
}
|
|
|
|
pub fn at(&self, t: f32) -> Vec3 {
|
|
self.origin + t * self.dir
|
|
}
|
|
|
|
pub fn origin(&self) -> &Vec3 {
|
|
&self.origin
|
|
}
|
|
|
|
pub fn dir(&self) -> &Vec3 {
|
|
&self.dir
|
|
}
|
|
}
|