XMPlaneFromPoints function (directxmath.h)

Computes the equation of a plane constructed from three points in the plane.

Syntax

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

Parameters

[in] Point1

3D vector describing a point in the plane.

[in] Point2

3D vector describing a point in the plane.

[in] Point3

3D vector describing a point in the plane.

Return value

Returns a vector whose components are the coefficients of the plane (A, B, C, D) for the plane equation

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;

.

Remarks

The following pseudocode demonstrates the operation of the function:

Ax+By+Cz+D=0

Platform Requirements

Microsoft Visual Studio 2010 or Microsoft Visual Studio 2012 with the Windows SDK for Windows 8. Supported for Win32 desktop apps, Windows Store apps, and Windows Phone 8 apps.

Requirements

Requirement Value
Target Platform Windows
Header directxmath.h

See also

DirectXMath Library Plane Functions