Game Development Reference
In-Depth Information
n
p
d
0
0
n
p
d
0
n
p
d
0
The D3DX library provides the following function to perform this
calculation:
D3DXPLANE *D3DXPlaneFromPointNormal(
D3DXPLANE* pOut,
// Result.
CONST D3DXVECTOR3* pPoint,
// Point on the plane.
CONST D3DXVECTOR3* pNormal
// The normal of the plane.
);
The second way that we can construct a plane is by specifying three
points on the plane.
Given the points
p
0
,
p
1
,
p
2
, we can form two vectors on the plane:
u
p
p
1
0
v
p
p
2
0
From that we can compute the normal of the plane by taking the cross
product of the two vectors on the plane. Remember the left hand thumb
rule.
n
u
v
Then, -(
n
p
0
)=
d
.
The D3DX library provides the following function to compute a
plane, given three points on the plane:
D3DXPLANE *D3DXPlaneFromPoints(
D3DXPLANE* pOut,
// Result.
CONST D3DXVECTOR3* pV1,
// Point 1 on the plane.
CONST D3DXVECTOR3* pV2,
// Point 2 on the plane.
CONST D3DXVECTOR3* pV3
// Point 3 on the plane.
);
Normalizing a Plane
Sometimes we might have a plane and would like to normalize the nor-
mal vector. At first thought, it would seem that we could just normalize
the normal vector as we would any other vector. But recall that
d
=-
n
p
0
in
n
p
+
d
= 0. We see that the length of the normal vector
influences the constant
d
. Therefore, if we normalize the normal vector,
we must also recalculate
d
. Note that
d
n
n
n
p
0
.
Search WWH ::
Custom Search