Пример #1
0
 public static Ray RayThruPixels(Camera cam, int i, int j)
 {
     double alpha = Math.Tan(DegreeToRadian(cam.GetFOVX()) / 2) * (j - (Screen.width / 2)) / (Screen.width / 2);
     double beta = Math.Tan(DegreeToRadian(cam.GetFOVY()) / 2) * ((Screen.height / 2) - i) / (Screen.height / 2);
     Vector position = cam.GetLookFrom();
     Vector temp = (cam.GetVectorU() * alpha + cam.GetVectorV() * beta - cam.GetVectorW() );
     Vector direction = temp / temp.Distance();
     return new Ray(position, direction);
 }