青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

DirectX 9的一些數學計算函數:平面


平面

將三維物體表面剖分為一系列的三角形面,物體的光照亮度處理就轉化為對這些平面三角形的照明處理,從而可簡單地通過平面三角形的法向量與光的入射方向的夾角,來確定各種入射光對平面上每一點所貢獻的亮度值。

對于三角形3個頂點p0,p1,p2構成的平面,選取一個垂直于該平面的法向量n。假設點p為平面上的任意一點,由于n . (p - p0) = 0,從而n . p - n . p0 = 0,由此展開向量的點積運算可知,平面方程具有如下的一般形式:ax+by+cz+d=0。如果要具體求出平面的方程,可取n=(p1-p0) x (p2 - p0)計算出來。

因為平面的方程式由4個系數a, b, c, d就可確定,因此,DirectX提供了如下的D3DXPLANE結構體保存方程式的4個系數,當然結構體還提供了基于方程式系數的加減乘除等運算。
 
typedef struct D3DXPLANE
{
#ifdef __cplusplus
public:
    D3DXPLANE() {}
    D3DXPLANE( CONST FLOAT* );
    D3DXPLANE( CONST D3DXFLOAT16* );
    D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d );

    
// casting
    operator FLOAT* ();
    
operator CONST FLOAT* () const;

    
// assignment operators
    D3DXPLANE& operator *= ( FLOAT );
    D3DXPLANE& 
operator /= ( FLOAT );

    
// unary operators
    D3DXPLANE operator + () const;
    D3DXPLANE 
operator - () const;

    
// binary operators
    D3DXPLANE operator * ( FLOAT ) const;
    D3DXPLANE 
operator / ( FLOAT ) const;

    friend D3DXPLANE 
operator * ( FLOAT, CONST D3DXPLANE& );

    BOOL 
operator == ( CONST D3DXPLANE& ) const;
    BOOL 
operator != ( CONST D3DXPLANE& ) const;

#endif //__cplusplus
    FLOAT a, b, c, d;
} D3DXPLANE, *LPD3DXPLANE;

DirectX還提供了基于三點的向量求平面的 D3DXPlaneFromPoints函數以及基于一點和一個法向量求平面的D3DXPlaneFromPointNormal函數。

Constructs a plane from three points.

D3DXPLANE * D3DXPlaneFromPoints(
D3DXPLANE * pOut,
CONST D3DXVECTOR3 * pV1,
CONST D3DXVECTOR3 * pV2,
CONST D3DXVECTOR3 * pV3
);

Parameters

pOut
[in, out] Pointer to the D3DXPLANE structure that is the result of the operation.
pV1
[in] Pointer to a D3DXVECTOR3 structure, defining one of the points used to construct the plane.
pV2
[in] Pointer to a D3DXVECTOR3 structure, defining one of the points used to construct the plane.
pV3
[in] Pointer to a D3DXVECTOR3 structure, defining one of the points used to construct the plane.

Return Values

Pointer to the D3DXPLANE structure constructed from the given points.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXPlaneFromPoints function can be used as a parameter for another function.

 

Constructs a plane from a point and a normal.

D3DXPLANE * D3DXPlaneFromPointNormal(
D3DXPLANE * pOut,
CONST D3DXVECTOR3 * pPoint,
CONST D3DXVECTOR3 * pNormal
);

Parameters

pOut
[in, out] Pointer to the D3DXPLANE structure that is the result of the operation.
pPoint
[in] Pointer to a D3DXVECTOR3 structure, defining the point used to construct the plane.
pNormal
[in] Pointer to a D3DXVECTOR3 structure, defining the normal used to construct the plane.

Return Values

Pointer to the D3DXPLANE structure constructed from the point and the normal.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXPlaneFromPointNormal function can be used as a parameter for another function.


要正確運行以下的示例程序,需要在工程中包含d3dx9.lib,或者在main函數前加入

#pragma comment(lib, "d3dx9.lib")

以指示編譯器鏈接d3dx9.lib。

代碼示例:

#include <stdio.h>
#include <D3DX9Math.h>

#pragma warning(disable : 4305)

int main()
{
    D3DXVECTOR3 P0(8.0,  -3.0, 6.0);
    D3DXVECTOR3 P1(2.0,  -3.0, -5.0);
    D3DXVECTOR3 P2(-1.0, -3.0, 10.0);

    D3DXPLANE plane;

    D3DXPlaneFromPoints(&plane, &P0, &P1, &P2);

    printf("Plane equation: %fx + %fy + %fz + %f = 0", plane.a, plane.b, plane.c, plane.d);
    printf("\n\n\n");

    
return 0;
}

結果輸出:

Plane equation: 0.000000x + 1.000000y + 0.000000z + 3.000000 = 0



直線與平面的交點

Finds the intersection between a plane and a line.

D3DXVECTOR3 * D3DXPlaneIntersectLine(
D3DXVECTOR3 * pOut,
CONST D3DXPLANE * pP,
CONST D3DXVECTOR3 * pV1,
CONST D3DXVECTOR3 * pV2
);

Parameters

pOut
[in, out] Pointer to a D3DXVECTOR3 structure, identifying the intersection between the specified plane and line.
pP
[in] Pointer to the source D3DXPLANE structure.
pV1
[in] Pointer to a source D3DXVECTOR3 structure, defining a line starting point.
pV2
[in] Pointer to a source D3DXVECTOR3 structure, defining a line ending point.

Return Values

Pointer to a D3DXVECTOR3 structure that is the intersection between the specified plane and line.

Remarks

If the line is parallel to the plane, NULL is returned.

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXPlaneIntersectLine function can be used as a parameter for another function.


代碼示例
 
#include <stdio.h>
#include <D3DX9Math.h>

#pragma comment(lib, "d3dx9.lib")
#pragma warning(disable : 4305)

int main()
{
    D3DXVECTOR3 A(0, 0, 0);
    D3DXVECTOR3 B(5, 5, 5);

    D3DXPLANE plane(0, 1, 0, -1);   
// equation: x = 1

    D3DXVECTOR3 intersect_point;

    D3DXPlaneIntersectLine(&intersect_point, &plane, &A, &B);

    
// intersect point must be: (1, 1, 1)
    printf("Intersect point: (%f, %f, %f)\n\n", intersect_point.x, intersect_point.y, intersect_point.z);

    
return 0;
}

輸出:

Intersect point: (1.000000, 1.000000, 1.000000)



點和平面的位置關系

對于1個給定了法向量n和內部一點p0的平面,任意1點p與該平面的位置關系可用兩向量的點積n . (p - p0) 進行判斷,分為如下的3種情形:
(1) 點p在法向量n的同一側,即n . (p - p0) > 0
(2) 點p在平面上,即n . (p - p0) = 0
(3) 點p在法向量n的反側,即n . (p - p0) < 0

對于以方程式ax+by+cz+d=0給出的平面,由系數a, b和c構成的向量(a, b, c)必然是1個垂直于該平面的向量法向量。

(證明如下:設平面上任意兩個點(x1,y1,z1), (x2,y2,z2),代入方程:
  ax1+by1+cz1+d=0;     ax2+by2+cz2+d=0 ;
  ====>
  a(x1-x2)+b(y1-y2)+c(z1-z2)=0
  ====>
  (a,b,c)(x1-x2, y1-y2, z1-z2)=0

即點積為0,因為兩點是任意的,所以具有一般性,即向量垂直與平面內任意一條直線。)
稱向量(a, b, c)為平面ax + by + cz +d = 0的默認法向量。

判斷一點p(x0, y0, z0)與ax+by+z+d=0平面的位置關系,可以直接利用ax0+by0+cz0+d的符號來決定。
 ax0 +by0+cz0+d > 0表示點p在默認法向量的一側,也可以說是位于平面的前方。
 ax0+by0+cz0+d = 0表示點p在平面上。
 ax0+by0+cz0+d < 0表示點p在默認法向量的另一側,也可以說是位于平面的后方。

平面(a, b, c, d)與任意點(x0, y0, z0)的ax0 + by0 + cz0值,可用DirectX提供的D3DXPlaneDotCoord函數計算出來,利用該函數返回值的符號可決定點在平面的那一側。

Computes the dot product of a plane and a 3D vector. The w parameter of the vector is assumed to be 1.

FLOAT D3DXPlaneDotCoord(
CONST D3DXPLANE * pP,
CONST D3DXVECTOR3 * pV
);

Parameters

pP
[in] Pointer to a source D3DXPLANE structure.
pV
[in] Pointer to a source D3DXVECTOR3 structure.

Return Values

The dot product of the plane and 3D vector.

Remarks

Given a plane (a, b, c, d) and a 3D vector (x, y, z) the return value of this function is a*x + b*y + c*z + d*1. The D3DXPlaneDotCoord function is useful for determining the plane's relationship with a coordinate in 3D space.


如果要計算平面法線和另一法線的夾角,可使用D3DXPlaneDotNormal。

Computes the dot product of a plane and a 3D vector. The w parameter of the vector is assumed to be 0.

FLOAT D3DXPlaneDotNormal(
CONST D3DXPLANE * pP,
CONST D3DXVECTOR3 * pV
);

Parameters

pP
[in] Pointer to a source D3DXPLANE structure.
pV
[in] Pointer to a source D3DXVECTOR3 structure.

Return Values

The dot product of the plane and 3D vector.

Remarks

Given a plane (a, b, c, d) and a 3D vector (x, y, z) the return value of this function is a*x + b*y + c*z + d*0. The D3DXPlaneDotNormal function is useful for calculating the angle between the normal of the plane, and another normal.


平面單位化:

如果平面ax+by+cz+d=0的默認法向量n =(a,b,c)為單位向量,那么該平面稱為單位化平面。

Normalizes the plane coefficients so that the plane normal has unit length.

D3DXPLANE * D3DXPlaneNormalize(
D3DXPLANE * pOut,
CONST D3DXPLANE * pP
);

Parameters

pOut
[in, out] Pointer to the D3DXPLANE structure that is the result of the operation.
pP
[in] Pointer to the source D3DXPLANE structure.

Return Values

Pointer to a D3DXPLANE structure that represents the normal of the plane.

Remarks

This function normalizes a plane so that |a,b,c| == 1.

The return value for this function is the same value returned in the pOut parameter. In this way, this function can be used as a parameter for another function.


代碼示例:

#include <stdio.h>
#include <D3DX9Math.h>

#pragma warning(disable : 4305)

int main()
{
    D3DXPLANE plane(1, 0, 0, -1);

    D3DXVECTOR3 p(5, 0, 0);

    
float dot = D3DXPlaneDotCoord(&plane, &p);
    printf("dot = %f\n\n", dot);

    dot = D3DXPlaneDotNormal(&plane, &p);
    printf("dot = %f\n\n", dot);

    D3DXPLANE plane2(3, 4, 0, 0);
    D3DXPlaneNormalize(&plane2, &plane2);
    printf("After normalize: (%f, %f, %f, %f)\n\n", plane2.a, plane2.b, plane2.c, plane2.d);

    
return 0;
}

輸出:

dot = 4.000000

dot = 5.000000

After normalize: (0.600000, 0.800000, 0.000000, 0.000000)

posted on 2007-05-04 01:18 lovedday 閱讀(1936) 評論(1)  編輯 收藏 引用 所屬分類: ■ DirectX 9 Program

評論

# re: DirectX 9的一些數學計算函數:平面 2008-11-19 05:42 Z. Yao

平面與平面的交線怎么計算  回復  更多評論   

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            国产精品国产自产拍高清av王其| 欧美日韩亚洲在线| 久久综合一区二区三区| 欧美专区中文字幕| 欧美伊人久久久久久午夜久久久久| 亚洲天堂av综合网| 亚洲欧美日韩在线综合| 久久国产一区二区| 欧美成人国产| 最近看过的日韩成人| 卡一卡二国产精品| 亚洲国产专区| 亚洲午夜国产成人av电影男同| 亚洲视频网在线直播| 欧美在线视频观看| 欧美mv日韩mv国产网站app| 欧美精品一区二区三区四区| 欧美日韩网站| 韩国视频理论视频久久| 在线精品亚洲一区二区| 洋洋av久久久久久久一区| 久久爱91午夜羞羞| 亚洲欧美国产制服动漫| 亚洲欧美另类中文字幕| 久久偷窥视频| 欧美日韩直播| 在线国产日韩| 亚洲欧美日本精品| 久久亚洲春色中文字幕久久久| 亚洲国产精品成人va在线观看| 一本色道久久综合精品竹菊| 久久久久久久久久久久久9999| 欧美日韩一区二区三区四区五区| 极品少妇一区二区三区精品视频| 亚洲视频在线观看视频| 欧美18av| 久久gogo国模裸体人体| 欧美日韩一区二区三区在线观看免| 国产一区观看| 亚洲欧美自拍偷拍| 亚洲人成网站在线观看播放| 久久久91精品国产| 国产精品一区在线观看| 一区二区日韩欧美| 91久久精品国产| 老司机免费视频一区二区三区| 国产精品久久九九| 宅男噜噜噜66国产日韩在线观看| 欧美成人精品不卡视频在线观看| 午夜精品久久| 国产久一道中文一区| 中国成人亚色综合网站| 亚洲国产欧美在线| 久久久欧美一区二区| 国产日韩欧美在线播放| 亚洲欧美在线高清| 在线亚洲欧美| 欧美日韩视频在线观看一区二区三区| 亚洲精品在线一区二区| 免费视频最近日韩| 久久九九99| 一色屋精品亚洲香蕉网站| 久热精品视频在线| 久久全球大尺度高清视频| 国产一区日韩二区欧美三区| 欧美一区二区三区啪啪| 一区二区三区四区国产精品| 欧美黄色日本| 中文日韩电影网站| 宅男精品视频| 国产麻豆91精品| 欧美一级免费视频| 久久福利资源站| 一区免费视频| 欧美a级一区| 欧美成人久久| 亚洲深夜福利在线| 亚洲制服少妇| 在线看片成人| 最新精品在线| 亚洲第一精品夜夜躁人人爽| 欧美风情在线观看| 免费成人黄色| 欧美二区视频| 亚洲一区精品在线| 亚洲女同同性videoxma| 国产欧美婷婷中文| 欧美激情按摩| 欧美三级在线播放| 欧美一级电影久久| 久久成人免费电影| 在线成人h网| 最新日韩在线| 国产欧美成人| 亚洲国产91| 国产精品一二三四区| 久久久夜夜夜| 欧美视频四区| 猛男gaygay欧美视频| 欧美日韩免费观看一区| 久久国产夜色精品鲁鲁99| 欧美成人国产一区二区| 亚洲欧美日韩另类精品一区二区三区| 久久成人亚洲| 亚洲一区在线免费| 久久久国产精品亚洲一区| 日韩一区二区免费看| 欧美一区二区三区视频免费播放| 亚洲人体影院| 欧美专区在线播放| 亚洲一二三级电影| 久久综合九色欧美综合狠狠| 亚洲欧美日韩高清| 欧美国产日韩a欧美在线观看| 欧美在线免费| 欧美亚男人的天堂| 亚洲国产黄色| 狠狠色狠色综合曰曰| 亚洲免费观看在线视频| 亚洲国产片色| 久久蜜桃精品| 久久成人亚洲| 国产精品久久久对白| 亚洲精品一区久久久久久| 永久免费毛片在线播放不卡| 亚洲一区二区在线免费观看| 亚洲精品视频一区| 久久久午夜视频| 欧美一区二区高清| 欧美三级资源在线| 亚洲精品一二区| 亚洲免费av网站| 欧美国产91| 91久久久久| 亚洲日本va在线观看| 久久精品国产欧美亚洲人人爽| 亚洲视频大全| 欧美日韩国产系列| 日韩手机在线导航| 99精品视频免费观看| 欧美激情aaaa| 亚洲欧洲一区二区三区在线观看| 亚洲人成绝费网站色www| 免费影视亚洲| 久久综合色88| 亚洲国产精品成人一区二区| 可以免费看不卡的av网站| 久久夜色精品亚洲噜噜国产mv| 伊人成人在线视频| 久久久噜噜噜久久人人看| 免费成人你懂的| 好吊日精品视频| 久久人人九九| 亚洲欧洲精品一区二区三区波多野1战4 | 欧美高清在线一区| 亚洲日本久久| 亚洲欧美国产高清va在线播| 国产精品日日摸夜夜添夜夜av| 亚洲影院色无极综合| 久久精品中文字幕免费mv| 国产一区 二区 三区一级| 久久视频精品在线| 亚洲人成在线观看| 午夜免费在线观看精品视频| 国产日韩精品在线播放| 久久精品亚洲热| 亚洲高清资源| 亚洲男人的天堂在线| 国产日韩欧美日韩大片| 久久综合伊人77777| 日韩视频中文字幕| 另类av一区二区| 一区二区三区精品在线| 国产欧美在线视频| 欧美理论在线| 午夜精品视频网站| 欧美国产视频在线| 亚洲欧美日韩一区二区在线| 尤物九九久久国产精品的分类| 欧美激情小视频| 欧美在线观看一区二区三区| 亚洲国产精品成人久久综合一区| 亚洲欧美日韩第一区| 亚洲人体影院| 伊人婷婷欧美激情| 国产精品99一区| 欧美成人激情视频| 久久精品国产清高在天天线 | 久久久国产精彩视频美女艺术照福利| 亚洲精美视频| 玖玖视频精品| 久久aⅴ国产欧美74aaa| 一区二区三区 在线观看视频 | 亚洲欧美精品在线| 亚洲国产精品久久人人爱蜜臀 | 激情欧美丁香| 国产日韩欧美夫妻视频在线观看| 欧美日本一区二区高清播放视频| 久久精品观看| 午夜在线一区|