GlmSharp/GlmSharpCompat5/Mat4x4/decmat4.cs
/// <summary>
/// Builds a perspective projection matrix based on a field of view.
/// </summary>
Builds a perspective projection matrix based on a field of view.
Builds a perspective projection matrix based on a field of view .
public static decmat4 PerspectiveFov(decimal fov, decimal width, decimal height, decimal zNear, decimal zFar)
        {
            if (width <= 0) throw new ArgumentOutOfRangeException("width");
            if (height <= 0) throw new ArgumentOutOfRangeException("height");
            if (fov <= 0) throw new ArgumentOutOfRangeException("fov");
            var h = Math.Cos((double)fov / 2.0) / Math.Sin((double)fov / 2.0);
            var w = h * (double)(height / width);
            var m = Zero;
            m.m00 = (decimal)w;
            m.m11 = (decimal)h;
            m.m22 = - (zFar + zNear)/(zFar - zNear);
            m.m23 = - 1;
            m.m32 = - (2*zFar*zNear)/(zFar - zNear);
            return m;
        }
public static decmat4 PerspectiveFov ( decimal fov , decimal width , decimal height , decimal zNear , decimal zFar ) { if ( width <= 0 ) throw new ArgumentOutOfRangeException ( " " ) ; if ( height <= 0 ) throw new ArgumentOutOfRangeException ( " " ) ; if ( fov <= 0 ) throw new ArgumentOutOfRangeException ( " " ) ; var h = Math . Cos ( ( double ) fov / 2.0 ) / Math . Sin ( ( double ) fov / 2.0 ) ; var w = h * ( double ) ( height / width ) ; var m = Zero ; m . m00 = ( decimal ) w ; m . m11 = ( decimal ) h ; m . m22 = - ( zFar + zNear ) / ( zFar - zNear ) ; m . m23 = - 1 ; m . m32 = - ( 2 * zFar * zNear ) / ( zFar - zNear ) ; return m ; }
Builds a perspective projection matrix based on a field of view.
Builds a perspective projection matrix based on a field of view .
fov
decimal
width
decimal
height
decimal
zNear
decimal
zFar
decimal