1 #ifndef __WINE_D3DVEC_INL
2 #define __WINE_D3DVEC_INL
6 inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
11 inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
13 x = _x; y = _y; z = _z;
16 /*** assignment operators ***/
18 inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
20 x += v.x; y += v.y; z += v.z;
24 inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
26 x -= v.x; y -= v.y; z -= v.z;
30 inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
32 x *= v.x; y *= v.y; z *= v.z;
36 inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
38 x /= v.x; y /= v.y; z /= v.z;
42 inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
44 x *= s; y *= s; z *= s;
48 inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
50 x /= s; y /= s; z /= s;
54 /*** unary operators ***/
56 inline _D3DVECTOR operator + (const _D3DVECTOR& v)
61 inline _D3DVECTOR operator - (const _D3DVECTOR& v)
63 return _D3DVECTOR(-v.x, -v.y, -v.z);
66 /*** binary operators ***/
68 inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
70 return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
73 inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
75 return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
78 inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
80 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
83 inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
85 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
88 inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
90 return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
93 inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
95 return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
98 inline D3DVALUE Magnitude(const _D3DVECTOR& v)
100 return sqrt(SquareMagnitude(v));
103 inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
105 return v / Magnitude(v);
108 inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
110 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
113 inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
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;