dykow

Plane

Nov 16th, 2021
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. int Plane::FindInter(const Ray &ray_cp, double &t)
  2. {
  3.     // Uwaga: parametry A, B, C plaszczyzny to po prostu skladowe jej wektora normalnego
  4.  
  5.     double tt = (-(ray_cp.Point()[0] * normal[0] + ray_cp.Point()[1] * normal[1] + ray_cp.Point()[2] * normal[2] + d))
  6.         / (normal[0] * ray_cp.Direction()[0] + normal[1] * ray_cp.Direction()[1] + normal[2] * ray_cp.Direction()[2]);;
  7.     if (tt>0.001 && tt < t)
  8.     {
  9.         t = tt;
  10.         return 1;
  11.     }
  12.     return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment