Example #1
0
        public static Transform Perspective(double fov, float n, double f)
        {
            // Perform projective divide for perspective projection
            Matrix4x4 persp = new Matrix4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, f / (f - n), -f * n / (f - n),
                                            0, 0, 1, 0);

            // Scale canonical perspective view to specified field of view
            double invTanAng = 1.0 / Math.Tan(PbrtMath.Radians(fov) / 2);

            return(Transform.Scale(invTanAng, invTanAng, 1.0) * new Transform(persp));
        }