`
yuanjinxiu
  • 浏览: 660038 次
文章分类
社区版块
存档分类
最新评论

D3DXPlaneTransform 函数

 
阅读更多

D3DXPlaneTransform 函数


用矩阵去变换平面。输入的矩阵是一个逆矩阵的转置矩阵。

定义:

D3DXPLANE*WINAPID3DXPlaneTransform(

D3DXPLANE*pOut,
CONST D3DXPLANE*pP,
CONST D3DXMATRIX*pM
);

参数:

pOut

[in, out]指向 D3DXPLANE 结构的变换后的平面方程。

pP

[in]指向 D3DXPLANE 的结构,它是将要用矩阵变换的平面方程,但在变换之前要作规格化,如下面的例子所示。

pM

[in]指向D3DXMATRIX 结构的矩阵,并且矩阵是一个逆矩阵的转置矩阵。

返回值:

指向 D3DXPLANE 结构的变换后的平面方程,

函数返回值跟pOut 参数返回值是一样的。这样可以让函数D3DXPlaneTransform作为其它函数的参数使用。

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

例:

这个例子用非等比例缩放平面:

D3DXPLANE planeNew;

D3DXPLANE plane(0,1,1,0);//平面。

D3DXPlaneNormalize(&plane, &plane);//规格化平面。

D3DXMATRIX matrix;

D3DXMatrixScaling(&matrix, 1.0f,2.0f,3.0f); //

D3DXMatrixInverse(&matrix, NULL, &matrix);

D3DXMatrixTranspose(&matrix, &matrix);

D3DXPlaneTransform(&planeNew, &plane, &matrix);

平面方程是 ax + by + cz + dw = 0,所以平面系数是(a,b,c,d) = (0,1,1,0),因此平面方程就是y + z = 0。在缩放之后,平面方程系数是 (a,b,c,d) = (0, 0.353f, 0.235f, 0),所以平面方程就是0.353y + 0.235z = 0。

参数pM 是一个逆矩阵的转置,并且平面系数是作规格化,这个函数才能正确计算。

函数信息:

Header

d3dx9math.h

Import library

d3dx9.lib

Minimum operating systems

Windows98

相关函数:

D3DXPlaneNormalize, D3DXMatrixRotationX, D3DXMatrixRotationY, D3DXMatrixRotationZ, D3DXMatrixInverse, D3DXMatrixTranspose



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics