Пример #1
0
        public ViewPlane(int width, int height, Camera camera)
        {
            this.pixelWidth = width;
            this.pixelHeight = height;
            this.camera = camera;

            this.worldHeight = 2 * Math.Tan(Func.DegreeToRadian(camera.GetFOVY())/2);
            this.worldWidth = worldHeight * (double)PixelWidth / (double)PixelHeight;

            CalculateUpperLeft();
        }
Пример #2
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);
 }