1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <d3d9.h>
#include <d3dx9.h>
#include <algorithm>
#include <iostream>
 
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")
 
using namespace std;
 
float myVec3Length(D3DXVECTOR3* pSrcVec)
{
    float TempLength = 0.0f;
    //pSrcVec->
 
    TempLength = sqrt(pSrcVec->x * pSrcVec->x + pSrcVec->y * pSrcVec->y + pSrcVec->z * pSrcVec->z);
 
    return TempLength;
}
 
int _tmain(int argc, _TCHAR* argv[])
{
    D3DXVECTOR3 LenVector = D3DXVECTOR3(1, 2, 3);
 
    cout << LenVector.x << LenVector.y << LenVector.z << endl;
    cout << D3DXVec3Length(&LenVector) << endl;
    cout << myVec3Length(&LenVector) << endl;
 
    return 0;
}

 

벡터계산중 길이와 정규화 함수를 만들어 보았다.

 

 

Posted by JJOREG