XMPlaneFromPoints 函式 (directxmath.h)

計算從平面中三個點建構的平面方程式。

語法

XMVECTOR XM_CALLCONV XMPlaneFromPoints(
  [in] FXMVECTOR Point1,
  [in] FXMVECTOR Point2,
  [in] FXMVECTOR Point3
) noexcept;

參數

[in] Point1

描述平面中點的 3D 向量。

[in] Point2

描述平面中點的 3D 向量。

[in] Point3

描述平面中點的 3D 向量。

傳回值

傳回向量,其元件是平面的係數, (A、B、C、D) 平面方程式

XMVECTOR Result;
XMVECTOR N;
XMVECTOR D;

XMVECTOR V21 = XMVectorSubtract(Point1, Point2);
XMVECTOR V31 = XMVectorSubtract(Point1, Point3);

N = XMVector3Cross(V21, V31);
N = XMVector3Normalize(N);

D = XMPlaneDotNormal(N, Point1);

Result.x = N.x;
Result.y = N.y;
Result.z = N.z;
Result.w = -D.w;

return Result;

.

備註

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

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 程式庫平面函式