SDC C-Project CF Review 프로그램
LYW
2021-09-14 ffe71aadfdcb4a9ea2ac4d8d320983d42ef3cad5
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
 
//#include "../akvectorT.h"
#define AKINLINE inline
 
 
 
template<typename T> AKINLINE
CakVectorT<T> CakVectorT<T>::operator-( CakVectorT<T> vector ) const throw()
{
    return CakVectorT(x - vector.x, y - vector.y, z - vector.z);
}
 
template<typename T> AKINLINE
CakVectorT<T> CakVectorT<T>::operator+( CakVectorT<T> vector ) const throw()
{
    return CakVectorT(x + vector.x, y + vector.y, z + vector.z);
}
 
template<typename T> AKINLINE
CakVectorT<T> CakVectorT<T>::operator-() const throw()
{
    return CakVectorT(-x,-y,-z);
}
 
template<typename T> AKINLINE
void CakVectorT<T>::operator-=( CakVectorT<T> vector ) throw()
{
    x -= vector.x;
    y -= vector.y;
    z -= vector.z;
}
 
template<typename T> AKINLINE
void CakVectorT<T>::operator+=( CakVectorT<T> vector ) throw()
{
    x += vector.x;
    y += vector.y;
    z += vector.z;
}
 
template<typename T> AKINLINE
bool CakVectorT<T>::operator!=( CakVectorT<T> vector ) const throw()
{
    return (x != vector.x || y != vector.y || z != vector.z);
}
 
template<typename T> AKINLINE
bool CakVectorT<T>::operator==( CakVectorT<T> vector ) const throw()
{
    return (x == vector.x && y == vector.y && z == vector.z);
}
 
template<typename T> AKINLINE
void CakVectorT<T>::set( T X, T Y, T Z ) throw()
{
    x = X; 
    y = Y;
    z = Z;
}
 
template<typename T> AKINLINE
void CakVectorT<T>::Offset( CakVectorT<T> vector ) throw()
{
    x += vector.x;
    y += vector.y;
    z += vector.z;
}
 
template<typename T> AKINLINE
void CakVectorT<T>::Offset( T xOffset, T yOffset, T zOffset) throw()
{
    x += xOffset;
    y += yOffset;
    z += zOffset;
}
 
template<typename T> AKINLINE
CakVectorT<T> CakVectorT<T>::operator*(T& a) const throw()
{
    return CakVectorT(x * a, y * a, z * a);
}
 
 
template<typename T> AKINLINE
CakVectorT<T> CakVectorT<T>::operator*( CakVectorT<T> &vec ) const throw()
{
    CakVectorT<T> vc;
    vc.x = y*vec.z - z*vec.y;
    vc.y = z*vec.x - x*vec.z;
    vc.z = x*vec.y - y*vec.x;
    return vc;
};
 
template<typename T> AKINLINE
void CakVectorT<T>::Normalize()
{
    double length;
 
    //º¤ÅÍÀÇ ±æÀ̸¦ °è»êÇÑ´Ù.
    length = sqrt((x*x) + (y*y) +(z*z));
    // ±æÀ̰¡ 0¿¡ °¡±î¿î º¤ÅÍ¿¡°Ô ÀýÀýÇÑ °ªÀ» Ç×´çÇÏ¿© ÇÁ·Î±×·¥ÀÌ ÆøÁÖÇÏÁö ¾Êµµ·Ï ÇÑ´Ù.
    if(length == 0.0f) length = 1.0f;
 
    // °¢ ¼ººÐÀ» º¤ÅÍÀÇ ±æÀ̷Π³ª´©¸é ´ÜÀ§ º¤ÅͰ¡ µÈ´Ù.
    x = x / length;
    y = y / length;
    z = z / length;
 
}