Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- impl Intersectable for Plane {
- fn intersect(&self, ray: &Ray) -> Option<f64> {
- let normal = &self.normal;
- let denom = normal.dot(&ray.direction);
- if denom > 1e-6 {
- let v = self.origin - ray.origin;
- let distance = v.dot(&normal) / denom;
- if distance >= 0.0 {
- return Some(distance);
- }
- }
- None
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement