VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/d3dvec.inl@ 33876

Last change on this file since 33876 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • Property svn:eol-style set to native
File size: 3.6 KB
Line 
1/*
2 * Copyright (C) 2000 Ove Kaaven
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19/*
20 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
21 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
22 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
23 * a choice of LGPL license versions is made available with the language indicating
24 * that LGPLv2 or any later version may be used, or where a choice of which version
25 * of the LGPL is applied is otherwise unspecified.
26 */
27
28#ifndef __WINE_D3DVEC_INL
29#define __WINE_D3DVEC_INL
30
31/*** constructors ***/
32
33inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
34{
35 x = y = z = f;
36}
37
38inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
39{
40 x = _x; y = _y; z = _z;
41}
42
43/*** assignment operators ***/
44
45inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
46{
47 x += v.x; y += v.y; z += v.z;
48 return *this;
49}
50
51inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
52{
53 x -= v.x; y -= v.y; z -= v.z;
54 return *this;
55}
56
57inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
58{
59 x *= v.x; y *= v.y; z *= v.z;
60 return *this;
61}
62
63inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
64{
65 x /= v.x; y /= v.y; z /= v.z;
66 return *this;
67}
68
69inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
70{
71 x *= s; y *= s; z *= s;
72 return *this;
73}
74
75inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
76{
77 x /= s; y /= s; z /= s;
78 return *this;
79}
80
81/*** unary operators ***/
82
83inline _D3DVECTOR operator + (const _D3DVECTOR& v)
84{
85 return v;
86}
87
88inline _D3DVECTOR operator - (const _D3DVECTOR& v)
89{
90 return _D3DVECTOR(-v.x, -v.y, -v.z);
91}
92
93/*** binary operators ***/
94
95inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
96{
97 return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
98}
99
100inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
101{
102 return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
103}
104
105inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
106{
107 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
108}
109
110inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
111{
112 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
113}
114
115inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
116{
117 return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
118}
119
120inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
121{
122 return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
123}
124
125inline D3DVALUE Magnitude(const _D3DVECTOR& v)
126{
127 return sqrt(SquareMagnitude(v));
128}
129
130inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
131{
132 return v / Magnitude(v);
133}
134
135inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
136{
137 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
138}
139
140inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
141{
142 _D3DVECTOR res;
143 /* this is a left-handed cross product, right? */
144 res.x = v1.y * v2.z - v1.z * v2.y;
145 res.y = v1.z * v2.x - v1.x * v2.z;
146 res.z = v1.x * v2.y - v1.y * v2.x;
147 return res;
148}
149
150#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette