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 /*** binary operators ***/
56 inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
58 return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
61 inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
63 return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
66 inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
68 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
71 inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
73 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
76 inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
78 return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
81 inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
83 return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
86 inline D3DVALUE Magnitude(const _D3DVECTOR& v)
88 return sqrt(SquareMagnitude(v));
91 inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
93 return v / Magnitude(v);
96 inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
98 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
101 inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
104 /* this is a left-handed cross product, right? */
105 res.x = v1.y * v2.z - v1.z * v2.y;
106 res.y = v1.z * v2.x - v1.x * v2.z;
107 res.z = v1.x * v2.y - v1.y * v2.x;