D3DXMatrixPerspectiveFovLH function (D3dx9math.h)

Note

The D3DX utility library is deprecated. We recommend that you use DirectXMath instead.

Builds a left-handed perspective projection matrix based on a field of view.

Syntax

``````D3DXMATRIX* D3DXMatrixPerspectiveFovLH(
_Inout_ D3DXMATRIX *pOut,
_In_    FLOAT      fovy,
_In_    FLOAT      Aspect,
_In_    FLOAT      zn,
_In_    FLOAT      zf
);
``````

Parameters

pOut [in, out]

Type: D3DXMATRIX*

Pointer to the D3DXMATRIX structure that is the result of the operation.

fovy [in]

Type: FLOAT

Field of view in the y direction, in radians.

Aspect [in]

Type: FLOAT

Aspect ratio, defined as view space width divided by height.

zn [in]

Type: FLOAT

Z-value of the near view-plane.

zf [in]

Type: FLOAT

Z-value of the far view-plane.

Return value

Type: D3DXMATRIX*

Pointer to a D3DXMATRIX structure that is a left-handed perspective projection matrix.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixPerspectiveFovLH function can be used as a parameter for another function.

To change the aspect ratio axis, use the calculation formula: fovy = 2 * math.atan(math.tan(fovy * 0.5) / aspect). Alternatively, add X and Y aspect ratio variables in the structure to scale the vertical view space: fovy = 2 * math.atan(math.tan(fovy * 0.5) / aspectY), aspect = aspectX * aspect Y.

This function computes the returned matrix as shown:

``````xScale     0          0               0
0        yScale       0               0
0          0       zf/(zf-zn)         1
0          0       -zn*zf/(zf-zn)     0
where:
yScale = cot(fovY/2)

xScale = yScale / aspect ratio
``````

Requirements

Requirement Value
Header
D3dx9math.h
Library
D3dx9.lib

See also

Math Functions

D3DXMatrixPerspectiveRH

D3DXMatrixPerspectiveLH

D3DXMatrixPerspectiveFovRH

D3DXMatrixPerspectiveOffCenterRH

D3DXMatrixPerspectiveOffCenterLH