Advertisement
Guest User

Untitled

a guest
May 16th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.41 KB | None | 0 0
  1. let boolX = r.GetDirection.X >= 0.0
  2.         let boolY = r.GetDirection.Y >= 0.0
  3.         let boolZ = r.GetDirection.Z >= 0.0
  4.        
  5.         let tx =  match boolX with
  6.                   |true -> (lowPoint.X - r.GetOrigin.X)/r.GetDirection.X
  7.                   |false -> (highPoint.X - r.GetOrigin.X)/r.GetDirection.X
  8.         let tx' = match boolX with
  9.                  |true -> (highPoint.X - r.GetOrigin.X)/r.GetDirection.X
  10.                  |false -> (lowPoint.X - r.GetOrigin.X)/r.GetDirection.X
  11.        let ty =  match boolY with
  12.                  |true -> (lowPoint.Y - r.GetOrigin.Y)/r.GetDirection.Y
  13.                  |false -> (highPoint.Y - r.GetOrigin.Y)/r.GetDirection.Y
  14.        let ty' = match boolY with
  15.                   |true -> (highPoint.Y - r.GetOrigin.Y)/r.GetDirection.Y
  16.                   |false -> (lowPoint.Y - r.GetOrigin.Y)/r.GetDirection.Y
  17.         let tz =  match boolZ with
  18.                   |true -> (lowPoint.Z - r.GetOrigin.Z)/r.GetDirection.Z
  19.                   |false -> (highPoint.Z - r.GetOrigin.Z)/r.GetDirection.Z
  20.         let tz' = match boolZ with
  21.                  |true -> (highPoint.Z - r.GetOrigin.Z)/r.GetDirection.Z
  22.                  |false -> (lowPoint.Z - r.GetOrigin.Z)/r.GetDirection.Z
  23.        
  24.  
  25.        let t = max tx (max ty tz)
  26.  
  27.        let t' = min tx' (min ty' tz')
  28.  
  29.        match (t < t' && t' > 0.0) with
  30.        |true -> Some(t, t')
  31.         |false -> None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement