SHARE
TWEET

Untitled

a guest Mar 20th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. impl Intersectable for Plane {
  2.     fn intersect(&self, ray: &Ray) -> Option<f64> {
  3.         let normal = &self.normal;
  4.         let denom = normal.dot(&ray.direction);
  5.         if denom > 1e-6 {
  6.             let v = self.origin - ray.origin;
  7.             let distance = v.dot(&normal) / denom;
  8.             if distance >= 0.0 {
  9.                 return Some(distance);
  10.             }
  11.         }
  12.         None
  13.     }
  14. }
RAW Paste Data
Top