XMPlaneNormalize 函数 (directxmath.h)

规范化平面的系数,使 x、y 和 z 系数形成单位法向量。

语法

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

参数

[in] P

描述平面方程的平面系数 (A、B、C、D) 的 XMVECTOR

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;

.

返回值

返回规范化平面作为 4D 向量,其分量是平面方程 Ax+By+Cz+D=0的平面系数 (A、B、C、D) 。

备注

以下伪代码演示函数的操作:

Ax+By+Cz+D=0

平台要求

带有 Windows SDK for Windows 8 的 Microsoft Visual Studio 2010 或 Microsoft Visual Studio 2012。 支持 Win32 桌面应用、Windows 应用商店应用和 Windows Phone 8 应用。

要求

   
目标平台 Windows
标头 directxmath.h

另请参阅

DirectXMath 库平面函数

XMPlaneNormalizeEst