blob: 33e62f21357b0532c5c9fd422b5190206f74738d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use crate::vec3::Vec3;
pub struct Ray {
origin: Vec3,
direction: Vec3,
}
impl Ray {
pub fn new(origin: Vec3, direction: Vec3) -> Ray {
Ray { origin, direction }
}
pub fn origin(&self) -> &Vec3 {
&self.origin
}
pub fn direction(&self) -> &Vec3 {
&self.direction
}
pub fn at(&self, go_length: f64) -> Vec3 {
self.origin + go_length * self.direction
}
}
|