XMPlaneNormalize 函式 (directxmath.h)

將平面的係數正規化,讓 x、y 和 z 的係數形成單位一般向量。

語法

XMVECTOR XM_CALLCONV XMPlaneNormalize(
  [in] FXMVECTOR P
) noexcept;

參數

[in] P

XMVECTOR ,描述平面方程式的平面係數 (A、B、C、D)

XMVECTOR Result;

float LengthSq = P.x * P.x + P.y * P.y + P.z * P.z;

float ReciprocalLength = 1.0f / sqrt(LengthSq);
Result.x = P.x * ReciprocalLength;
Result.y = P.y * ReciprocalLength;
Result.z = P.z * ReciprocalLength;
Result.w = P.w * ReciprocalLength;

return Result;

.

傳回值

傳回標準化平面做為平面方 Ax+By+Cz+D=0 程式的平面係數 (A、B、C、D) 的 4D 向量。

備註

下列虛擬程式碼示範函式的作業:

Ax+By+Cz+D=0

平臺需求

Microsoft Visual Studio 2010 或 Microsoft Visual Studio 2012 搭配 Windows SDK for Windows 8。 支援 Win32 傳統型應用程式、Windows 市集應用程式和 Windows Phone 8 個應用程式。

需求

   
目標平台 Windows
標頭 directxmath.h

另請參閱

DirectXMath 程式庫平面函式

XMPlaneNormalizeEst