VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/shaderlib/wine/include/d3dvec.inl

最後變更 在這個檔案是 69505,由 vboxsync 提交於 7 年 前

More scm updates

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.7 KB
 
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 * Oracle 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, Oracle 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#include <math.h>
32
33/*** constructors ***/
34
35inline _D3DVECTOR::_D3DVECTOR(D3DVALUE f)
36{
37 x = y = z = f;
38}
39
40inline _D3DVECTOR::_D3DVECTOR(D3DVALUE _x, D3DVALUE _y, D3DVALUE _z)
41{
42 x = _x; y = _y; z = _z;
43}
44
45/*** assignment operators ***/
46
47inline _D3DVECTOR& _D3DVECTOR::operator += (const _D3DVECTOR& v)
48{
49 x += v.x; y += v.y; z += v.z;
50 return *this;
51}
52
53inline _D3DVECTOR& _D3DVECTOR::operator -= (const _D3DVECTOR& v)
54{
55 x -= v.x; y -= v.y; z -= v.z;
56 return *this;
57}
58
59inline _D3DVECTOR& _D3DVECTOR::operator *= (const _D3DVECTOR& v)
60{
61 x *= v.x; y *= v.y; z *= v.z;
62 return *this;
63}
64
65inline _D3DVECTOR& _D3DVECTOR::operator /= (const _D3DVECTOR& v)
66{
67 x /= v.x; y /= v.y; z /= v.z;
68 return *this;
69}
70
71inline _D3DVECTOR& _D3DVECTOR::operator *= (D3DVALUE s)
72{
73 x *= s; y *= s; z *= s;
74 return *this;
75}
76
77inline _D3DVECTOR& _D3DVECTOR::operator /= (D3DVALUE s)
78{
79 x /= s; y /= s; z /= s;
80 return *this;
81}
82
83/*** unary operators ***/
84
85inline _D3DVECTOR operator + (const _D3DVECTOR& v)
86{
87 return v;
88}
89
90inline _D3DVECTOR operator - (const _D3DVECTOR& v)
91{
92 return _D3DVECTOR(-v.x, -v.y, -v.z);
93}
94
95/*** binary operators ***/
96
97inline _D3DVECTOR operator + (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
98{
99 return _D3DVECTOR(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z);
100}
101
102inline _D3DVECTOR operator - (const _D3DVECTOR& v1, const _D3DVECTOR& v2)
103{
104 return _D3DVECTOR(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z);
105}
106
107inline _D3DVECTOR operator * (const _D3DVECTOR& v, D3DVALUE s)
108{
109 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
110}
111
112inline _D3DVECTOR operator * (D3DVALUE s, const _D3DVECTOR& v)
113{
114 return _D3DVECTOR(v.x*s, v.y*s, v.z*s);
115}
116
117inline _D3DVECTOR operator / (const _D3DVECTOR& v, D3DVALUE s)
118{
119 return _D3DVECTOR(v.x/s, v.y/s, v.z/s);
120}
121
122inline D3DVALUE SquareMagnitude(const _D3DVECTOR& v)
123{
124 return v.x*v.x + v.y*v.y + v.z*v.z; /* DotProduct(v, v) */
125}
126
127inline D3DVALUE Magnitude(const _D3DVECTOR& v)
128{
129 return sqrt(SquareMagnitude(v));
130}
131
132inline _D3DVECTOR Normalize(const _D3DVECTOR& v)
133{
134 return v / Magnitude(v);
135}
136
137inline D3DVALUE DotProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
138{
139 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
140}
141
142inline _D3DVECTOR CrossProduct(const _D3DVECTOR& v1, const _D3DVECTOR& v2)
143{
144 _D3DVECTOR res;
145 /* this is a left-handed cross product, right? */
146 res.x = v1.y * v2.z - v1.z * v2.y;
147 res.y = v1.z * v2.x - v1.x * v2.z;
148 res.z = v1.x * v2.y - v1.y * v2.x;
149 return res;
150}
151
152#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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