Make dinput a properly separated dll.
[wine] / include / d3dvec.inl
1 #ifndef __WINE_D3DVEC_INL
2 #define __WINE_D3DVEC_INL
3
4 /*** constructors ***/
5
6 inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
7 {
8   x = y = z = f;
9 }
10
11 inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
12 {
13   x = _x; y = _y; z = _z;
14 }
15
16 /*** assignment operators ***/
17
18 inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
19 {
20   x += v.x; y += v.y; z += v.z;
21   return *this;
22 }
23
24 inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
25 {
26   x -= v.x; y -= v.y; z -= v.z;
27   return *this;
28 }
29
30 inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
31 {
32   x *= v.x; y *= v.y; z *= v.z;
33   return *this;
34 }
35
36 inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
37 {
38   x /= v.x; y /= v.y; z /= v.z;
39   return *this;
40 }
41
42 inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
43 {
44   x *= s; y *= s; z *= s;
45   return *this;
46 }
47
48 inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
49 {
50   x /= s; y /= s; z /= s;
51   return *this;
52 }
53
54 /*** unary operators ***/
55
56 inline _D3DVECTOR operator + (const _D3DVECTOR& v)
57 {
58   return v;
59 }
60
61 inline _D3DVECTOR operator - (const _D3DVECTOR& v)
62 {
63   return _D3DVECTOR(-v.x, -v.y, -v.z);
64 }
65
66 /*** binary operators ***/
67
68 inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
69 {
70   return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
71 }
72
73 inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
74 {
75   return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
76 }
77
78 inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
79 {
80   return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
81 }
82
83 inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
84 {
85   return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
86 }
87
88 inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
89 {
90   return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
91 }
92
93 inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
94 {
95   return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
96 }
97
98 inline D3DVALUE Magnitude(const _D3DVECTOR& v)
99 {
100   return sqrt(SquareMagnitude(v));
101 }
102
103 inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
104 {
105   return v / Magnitude(v);
106 }
107
108 inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
109 {
110   return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
111 }
112
113 inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
114 {
115   _D3DVECTOR res;
116   /* this is a left-handed cross product, right? */
117   res.x = v1.y * v2.z - v1.z * v2.y;
118   res.y = v1.z * v2.x - v1.x * v2.z;
119   res.z = v1.x * v2.y - v1.y * v2.x;
120   return res;
121 }
122
123 #endif