diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to '')
-rw-r--r-- | libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs | 1260 |
1 files changed, 630 insertions, 630 deletions
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs index c75b7c8..abb30a8 100644 --- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs +++ b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs | |||
@@ -1,630 +1,630 @@ | |||
1 | #region License | 1 | #region License |
2 | /* | 2 | /* |
3 | MIT License | 3 | MIT License |
4 | Copyright © 2006 The Mono.Xna Team | 4 | Copyright © 2006 The Mono.Xna Team |
5 | 5 | ||
6 | All rights reserved. | 6 | All rights reserved. |
7 | 7 | ||
8 | Permission is hereby granted, free of charge, to any person obtaining a copy | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy |
9 | of this software and associated documentation files (the "Software"), to deal | 9 | of this software and associated documentation files (the "Software"), to deal |
10 | in the Software without restriction, including without limitation the rights | 10 | in the Software without restriction, including without limitation the rights |
11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12 | copies of the Software, and to permit persons to whom the Software is | 12 | copies of the Software, and to permit persons to whom the Software is |
13 | furnished to do so, subject to the following conditions: | 13 | furnished to do so, subject to the following conditions: |
14 | 14 | ||
15 | The above copyright notice and this permission notice shall be included in all | 15 | The above copyright notice and this permission notice shall be included in all |
16 | copies or substantial portions of the Software. | 16 | copies or substantial portions of the Software. |
17 | 17 | ||
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
24 | SOFTWARE. | 24 | SOFTWARE. |
25 | */ | 25 | */ |
26 | #endregion License | 26 | #endregion License |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.ComponentModel; | 29 | using System.ComponentModel; |
30 | using System.Text; | 30 | using System.Text; |
31 | using System.Runtime.InteropServices; | 31 | using System.Runtime.InteropServices; |
32 | 32 | ||
33 | namespace MonoXnaCompactMaths | 33 | namespace MonoXnaCompactMaths |
34 | { | 34 | { |
35 | [Serializable] | 35 | [Serializable] |
36 | [StructLayout(LayoutKind.Sequential)] | 36 | [StructLayout(LayoutKind.Sequential)] |
37 | //[TypeConverter(typeof(Vector4Converter))] | 37 | //[TypeConverter(typeof(Vector4Converter))] |
38 | public struct Vector4 : IEquatable<Vector4> | 38 | public struct Vector4 : IEquatable<Vector4> |
39 | { | 39 | { |
40 | #region Private Fields | 40 | #region Private Fields |
41 | 41 | ||
42 | private static Vector4 zeroVector = new Vector4(); | 42 | private static Vector4 zeroVector = new Vector4(); |
43 | private static Vector4 unitVector = new Vector4(1f, 1f, 1f, 1f); | 43 | private static Vector4 unitVector = new Vector4(1f, 1f, 1f, 1f); |
44 | private static Vector4 unitXVector = new Vector4(1f, 0f, 0f, 0f); | 44 | private static Vector4 unitXVector = new Vector4(1f, 0f, 0f, 0f); |
45 | private static Vector4 unitYVector = new Vector4(0f, 1f, 0f, 0f); | 45 | private static Vector4 unitYVector = new Vector4(0f, 1f, 0f, 0f); |
46 | private static Vector4 unitZVector = new Vector4(0f, 0f, 1f, 0f); | 46 | private static Vector4 unitZVector = new Vector4(0f, 0f, 1f, 0f); |
47 | private static Vector4 unitWVector = new Vector4(0f, 0f, 0f, 1f); | 47 | private static Vector4 unitWVector = new Vector4(0f, 0f, 0f, 1f); |
48 | 48 | ||
49 | #endregion Private Fields | 49 | #endregion Private Fields |
50 | 50 | ||
51 | 51 | ||
52 | #region Public Fields | 52 | #region Public Fields |
53 | 53 | ||
54 | public float X; | 54 | public float X; |
55 | public float Y; | 55 | public float Y; |
56 | public float Z; | 56 | public float Z; |
57 | public float W; | 57 | public float W; |
58 | 58 | ||
59 | #endregion Public Fields | 59 | #endregion Public Fields |
60 | 60 | ||
61 | 61 | ||
62 | #region Properties | 62 | #region Properties |
63 | 63 | ||
64 | public static Vector4 Zero | 64 | public static Vector4 Zero |
65 | { | 65 | { |
66 | get { return zeroVector; } | 66 | get { return zeroVector; } |
67 | } | 67 | } |
68 | 68 | ||
69 | public static Vector4 One | 69 | public static Vector4 One |
70 | { | 70 | { |
71 | get { return unitVector; } | 71 | get { return unitVector; } |
72 | } | 72 | } |
73 | 73 | ||
74 | public static Vector4 UnitX | 74 | public static Vector4 UnitX |
75 | { | 75 | { |
76 | get { return unitXVector; } | 76 | get { return unitXVector; } |
77 | } | 77 | } |
78 | 78 | ||
79 | public static Vector4 UnitY | 79 | public static Vector4 UnitY |
80 | { | 80 | { |
81 | get { return unitYVector; } | 81 | get { return unitYVector; } |
82 | } | 82 | } |
83 | 83 | ||
84 | public static Vector4 UnitZ | 84 | public static Vector4 UnitZ |
85 | { | 85 | { |
86 | get { return unitZVector; } | 86 | get { return unitZVector; } |
87 | } | 87 | } |
88 | 88 | ||
89 | public static Vector4 UnitW | 89 | public static Vector4 UnitW |
90 | { | 90 | { |
91 | get { return unitWVector; } | 91 | get { return unitWVector; } |
92 | } | 92 | } |
93 | 93 | ||
94 | #endregion Properties | 94 | #endregion Properties |
95 | 95 | ||
96 | 96 | ||
97 | #region Constructors | 97 | #region Constructors |
98 | 98 | ||
99 | public Vector4(float x, float y, float z, float w) | 99 | public Vector4(float x, float y, float z, float w) |
100 | { | 100 | { |
101 | this.X = x; | 101 | this.X = x; |
102 | this.Y = y; | 102 | this.Y = y; |
103 | this.Z = z; | 103 | this.Z = z; |
104 | this.W = w; | 104 | this.W = w; |
105 | } | 105 | } |
106 | 106 | ||
107 | /*public Vector4(Vector2 value, float z, float w) | 107 | /*public Vector4(Vector2 value, float z, float w) |
108 | { | 108 | { |
109 | this.X = value.X; | 109 | this.X = value.X; |
110 | this.Y = value.Y; | 110 | this.Y = value.Y; |
111 | this.Z = z; | 111 | this.Z = z; |
112 | this.W = w; | 112 | this.W = w; |
113 | }*/ | 113 | }*/ |
114 | 114 | ||
115 | public Vector4(Vector3 value, float w) | 115 | public Vector4(Vector3 value, float w) |
116 | { | 116 | { |
117 | this.X = value.X; | 117 | this.X = value.X; |
118 | this.Y = value.Y; | 118 | this.Y = value.Y; |
119 | this.Z = value.Z; | 119 | this.Z = value.Z; |
120 | this.W = w; | 120 | this.W = w; |
121 | } | 121 | } |
122 | 122 | ||
123 | public Vector4(float value) | 123 | public Vector4(float value) |
124 | { | 124 | { |
125 | this.X = value; | 125 | this.X = value; |
126 | this.Y = value; | 126 | this.Y = value; |
127 | this.Z = value; | 127 | this.Z = value; |
128 | this.W = value; | 128 | this.W = value; |
129 | } | 129 | } |
130 | 130 | ||
131 | #endregion | 131 | #endregion |
132 | 132 | ||
133 | 133 | ||
134 | #region Public Methods | 134 | #region Public Methods |
135 | 135 | ||
136 | public static Vector4 Add(Vector4 value1, Vector4 value2) | 136 | public static Vector4 Add(Vector4 value1, Vector4 value2) |
137 | { | 137 | { |
138 | value1.W += value2.W; | 138 | value1.W += value2.W; |
139 | value1.X += value2.X; | 139 | value1.X += value2.X; |
140 | value1.Y += value2.Y; | 140 | value1.Y += value2.Y; |
141 | value1.Z += value2.Z; | 141 | value1.Z += value2.Z; |
142 | return value1; | 142 | return value1; |
143 | } | 143 | } |
144 | 144 | ||
145 | public static void Add(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 145 | public static void Add(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
146 | { | 146 | { |
147 | result.W = value1.W + value2.W; | 147 | result.W = value1.W + value2.W; |
148 | result.X = value1.X + value2.X; | 148 | result.X = value1.X + value2.X; |
149 | result.Y = value1.Y + value2.Y; | 149 | result.Y = value1.Y + value2.Y; |
150 | result.Z = value1.Z + value2.Z; | 150 | result.Z = value1.Z + value2.Z; |
151 | } | 151 | } |
152 | 152 | ||
153 | /*public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2) | 153 | /*public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2) |
154 | { | 154 | { |
155 | return new Vector4( | 155 | return new Vector4( |
156 | MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2), | 156 | MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2), |
157 | MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2), | 157 | MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2), |
158 | MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2), | 158 | MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2), |
159 | MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2)); | 159 | MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2)); |
160 | }*/ | 160 | }*/ |
161 | 161 | ||
162 | /*public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result) | 162 | /*public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result) |
163 | { | 163 | { |
164 | result = new Vector4( | 164 | result = new Vector4( |
165 | MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2), | 165 | MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2), |
166 | MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2), | 166 | MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2), |
167 | MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2), | 167 | MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2), |
168 | MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2)); | 168 | MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2)); |
169 | }*/ | 169 | }*/ |
170 | 170 | ||
171 | /*public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount) | 171 | /*public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount) |
172 | { | 172 | { |
173 | return new Vector4( | 173 | return new Vector4( |
174 | MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount), | 174 | MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount), |
175 | MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount), | 175 | MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount), |
176 | MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount), | 176 | MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount), |
177 | MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount)); | 177 | MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount)); |
178 | }*/ | 178 | }*/ |
179 | 179 | ||
180 | /*public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result) | 180 | /*public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result) |
181 | { | 181 | { |
182 | result = new Vector4( | 182 | result = new Vector4( |
183 | MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount), | 183 | MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, amount), |
184 | MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount), | 184 | MathHelper.CatmullRom(value1.Y, value2.Y, value3.Y, value4.Y, amount), |
185 | MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount), | 185 | MathHelper.CatmullRom(value1.Z, value2.Z, value3.Z, value4.Z, amount), |
186 | MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount)); | 186 | MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount)); |
187 | }*/ | 187 | }*/ |
188 | 188 | ||
189 | /*public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max) | 189 | /*public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max) |
190 | { | 190 | { |
191 | return new Vector4( | 191 | return new Vector4( |
192 | MathHelper.Clamp(value1.X, min.X, max.X), | 192 | MathHelper.Clamp(value1.X, min.X, max.X), |
193 | MathHelper.Clamp(value1.Y, min.Y, max.Y), | 193 | MathHelper.Clamp(value1.Y, min.Y, max.Y), |
194 | MathHelper.Clamp(value1.Z, min.Z, max.Z), | 194 | MathHelper.Clamp(value1.Z, min.Z, max.Z), |
195 | MathHelper.Clamp(value1.W, min.W, max.W)); | 195 | MathHelper.Clamp(value1.W, min.W, max.W)); |
196 | }*/ | 196 | }*/ |
197 | 197 | ||
198 | /*public static void Clamp(ref Vector4 value1, ref Vector4 min, ref Vector4 max, out Vector4 result) | 198 | /*public static void Clamp(ref Vector4 value1, ref Vector4 min, ref Vector4 max, out Vector4 result) |
199 | { | 199 | { |
200 | result = new Vector4( | 200 | result = new Vector4( |
201 | MathHelper.Clamp(value1.X, min.X, max.X), | 201 | MathHelper.Clamp(value1.X, min.X, max.X), |
202 | MathHelper.Clamp(value1.Y, min.Y, max.Y), | 202 | MathHelper.Clamp(value1.Y, min.Y, max.Y), |
203 | MathHelper.Clamp(value1.Z, min.Z, max.Z), | 203 | MathHelper.Clamp(value1.Z, min.Z, max.Z), |
204 | MathHelper.Clamp(value1.W, min.W, max.W)); | 204 | MathHelper.Clamp(value1.W, min.W, max.W)); |
205 | }*/ | 205 | }*/ |
206 | 206 | ||
207 | public static float Distance(Vector4 value1, Vector4 value2) | 207 | public static float Distance(Vector4 value1, Vector4 value2) |
208 | { | 208 | { |
209 | return (float)Math.Sqrt(DistanceSquared(value1, value2)); | 209 | return (float)Math.Sqrt(DistanceSquared(value1, value2)); |
210 | } | 210 | } |
211 | 211 | ||
212 | public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result) | 212 | public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result) |
213 | { | 213 | { |
214 | result = (float)Math.Sqrt(DistanceSquared(value1, value2)); | 214 | result = (float)Math.Sqrt(DistanceSquared(value1, value2)); |
215 | } | 215 | } |
216 | 216 | ||
217 | public static float DistanceSquared(Vector4 value1, Vector4 value2) | 217 | public static float DistanceSquared(Vector4 value1, Vector4 value2) |
218 | { | 218 | { |
219 | float result; | 219 | float result; |
220 | DistanceSquared(ref value1, ref value2, out result); | 220 | DistanceSquared(ref value1, ref value2, out result); |
221 | return result; | 221 | return result; |
222 | } | 222 | } |
223 | 223 | ||
224 | public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result) | 224 | public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result) |
225 | { | 225 | { |
226 | result = (value1.W - value2.W) * (value1.W - value2.W) + | 226 | result = (value1.W - value2.W) * (value1.W - value2.W) + |
227 | (value1.X - value2.X) * (value1.X - value2.X) + | 227 | (value1.X - value2.X) * (value1.X - value2.X) + |
228 | (value1.Y - value2.Y) * (value1.Y - value2.Y) + | 228 | (value1.Y - value2.Y) * (value1.Y - value2.Y) + |
229 | (value1.Z - value2.Z) * (value1.Z - value2.Z); | 229 | (value1.Z - value2.Z) * (value1.Z - value2.Z); |
230 | } | 230 | } |
231 | 231 | ||
232 | public static Vector4 Divide(Vector4 value1, Vector4 value2) | 232 | public static Vector4 Divide(Vector4 value1, Vector4 value2) |
233 | { | 233 | { |
234 | value1.W /= value2.W; | 234 | value1.W /= value2.W; |
235 | value1.X /= value2.X; | 235 | value1.X /= value2.X; |
236 | value1.Y /= value2.Y; | 236 | value1.Y /= value2.Y; |
237 | value1.Z /= value2.Z; | 237 | value1.Z /= value2.Z; |
238 | return value1; | 238 | return value1; |
239 | } | 239 | } |
240 | 240 | ||
241 | public static Vector4 Divide(Vector4 value1, float divider) | 241 | public static Vector4 Divide(Vector4 value1, float divider) |
242 | { | 242 | { |
243 | float factor = 1f / divider; | 243 | float factor = 1f / divider; |
244 | value1.W *= factor; | 244 | value1.W *= factor; |
245 | value1.X *= factor; | 245 | value1.X *= factor; |
246 | value1.Y *= factor; | 246 | value1.Y *= factor; |
247 | value1.Z *= factor; | 247 | value1.Z *= factor; |
248 | return value1; | 248 | return value1; |
249 | } | 249 | } |
250 | 250 | ||
251 | public static void Divide(ref Vector4 value1, float divider, out Vector4 result) | 251 | public static void Divide(ref Vector4 value1, float divider, out Vector4 result) |
252 | { | 252 | { |
253 | float factor = 1f / divider; | 253 | float factor = 1f / divider; |
254 | result.W = value1.W * factor; | 254 | result.W = value1.W * factor; |
255 | result.X = value1.X * factor; | 255 | result.X = value1.X * factor; |
256 | result.Y = value1.Y * factor; | 256 | result.Y = value1.Y * factor; |
257 | result.Z = value1.Z * factor; | 257 | result.Z = value1.Z * factor; |
258 | } | 258 | } |
259 | 259 | ||
260 | public static void Divide(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 260 | public static void Divide(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
261 | { | 261 | { |
262 | result.W = value1.W / value2.W; | 262 | result.W = value1.W / value2.W; |
263 | result.X = value1.X / value2.X; | 263 | result.X = value1.X / value2.X; |
264 | result.Y = value1.Y / value2.Y; | 264 | result.Y = value1.Y / value2.Y; |
265 | result.Z = value1.Z / value2.Z; | 265 | result.Z = value1.Z / value2.Z; |
266 | } | 266 | } |
267 | 267 | ||
268 | public static float Dot(Vector4 vector1, Vector4 vector2) | 268 | public static float Dot(Vector4 vector1, Vector4 vector2) |
269 | { | 269 | { |
270 | return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W; | 270 | return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W; |
271 | } | 271 | } |
272 | 272 | ||
273 | public static void Dot(ref Vector4 vector1, ref Vector4 vector2, out float result) | 273 | public static void Dot(ref Vector4 vector1, ref Vector4 vector2, out float result) |
274 | { | 274 | { |
275 | result = vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W; | 275 | result = vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W; |
276 | } | 276 | } |
277 | 277 | ||
278 | public override bool Equals(object obj) | 278 | public override bool Equals(object obj) |
279 | { | 279 | { |
280 | return (obj is Vector4) ? this == (Vector4)obj : false; | 280 | return (obj is Vector4) ? this == (Vector4)obj : false; |
281 | } | 281 | } |
282 | 282 | ||
283 | public bool Equals(Vector4 other) | 283 | public bool Equals(Vector4 other) |
284 | { | 284 | { |
285 | return this.W == other.W | 285 | return this.W == other.W |
286 | && this.X == other.X | 286 | && this.X == other.X |
287 | && this.Y == other.Y | 287 | && this.Y == other.Y |
288 | && this.Z == other.Z; | 288 | && this.Z == other.Z; |
289 | } | 289 | } |
290 | 290 | ||
291 | public override int GetHashCode() | 291 | public override int GetHashCode() |
292 | { | 292 | { |
293 | return (int)(this.W + this.X + this.Y + this.Y); | 293 | return (int)(this.W + this.X + this.Y + this.Y); |
294 | } | 294 | } |
295 | 295 | ||
296 | /*public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount) | 296 | /*public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount) |
297 | { | 297 | { |
298 | Vector4 result = new Vector4(); | 298 | Vector4 result = new Vector4(); |
299 | Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result); | 299 | Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result); |
300 | return result; | 300 | return result; |
301 | }*/ | 301 | }*/ |
302 | 302 | ||
303 | /*public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result) | 303 | /*public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result) |
304 | { | 304 | { |
305 | result.W = MathHelper.Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount); | 305 | result.W = MathHelper.Hermite(value1.W, tangent1.W, value2.W, tangent2.W, amount); |
306 | result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); | 306 | result.X = MathHelper.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); |
307 | result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount); | 307 | result.Y = MathHelper.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount); |
308 | result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount); | 308 | result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount); |
309 | }*/ | 309 | }*/ |
310 | 310 | ||
311 | public float Length() | 311 | public float Length() |
312 | { | 312 | { |
313 | float result; | 313 | float result; |
314 | DistanceSquared(ref this, ref zeroVector, out result); | 314 | DistanceSquared(ref this, ref zeroVector, out result); |
315 | return (float)Math.Sqrt(result); | 315 | return (float)Math.Sqrt(result); |
316 | } | 316 | } |
317 | 317 | ||
318 | public float LengthSquared() | 318 | public float LengthSquared() |
319 | { | 319 | { |
320 | float result; | 320 | float result; |
321 | DistanceSquared(ref this, ref zeroVector, out result); | 321 | DistanceSquared(ref this, ref zeroVector, out result); |
322 | return result; | 322 | return result; |
323 | } | 323 | } |
324 | 324 | ||
325 | /*public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount) | 325 | /*public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount) |
326 | { | 326 | { |
327 | return new Vector4( | 327 | return new Vector4( |
328 | MathHelper.Lerp(value1.X, value2.X, amount), | 328 | MathHelper.Lerp(value1.X, value2.X, amount), |
329 | MathHelper.Lerp(value1.Y, value2.Y, amount), | 329 | MathHelper.Lerp(value1.Y, value2.Y, amount), |
330 | MathHelper.Lerp(value1.Z, value2.Z, amount), | 330 | MathHelper.Lerp(value1.Z, value2.Z, amount), |
331 | MathHelper.Lerp(value1.W, value2.W, amount)); | 331 | MathHelper.Lerp(value1.W, value2.W, amount)); |
332 | }*/ | 332 | }*/ |
333 | 333 | ||
334 | /*public static void Lerp(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result) | 334 | /*public static void Lerp(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result) |
335 | { | 335 | { |
336 | result = new Vector4( | 336 | result = new Vector4( |
337 | MathHelper.Lerp(value1.X, value2.X, amount), | 337 | MathHelper.Lerp(value1.X, value2.X, amount), |
338 | MathHelper.Lerp(value1.Y, value2.Y, amount), | 338 | MathHelper.Lerp(value1.Y, value2.Y, amount), |
339 | MathHelper.Lerp(value1.Z, value2.Z, amount), | 339 | MathHelper.Lerp(value1.Z, value2.Z, amount), |
340 | MathHelper.Lerp(value1.W, value2.W, amount)); | 340 | MathHelper.Lerp(value1.W, value2.W, amount)); |
341 | }*/ | 341 | }*/ |
342 | 342 | ||
343 | /*public static Vector4 Max(Vector4 value1, Vector4 value2) | 343 | /*public static Vector4 Max(Vector4 value1, Vector4 value2) |
344 | { | 344 | { |
345 | return new Vector4( | 345 | return new Vector4( |
346 | MathHelper.Max(value1.X, value2.X), | 346 | MathHelper.Max(value1.X, value2.X), |
347 | MathHelper.Max(value1.Y, value2.Y), | 347 | MathHelper.Max(value1.Y, value2.Y), |
348 | MathHelper.Max(value1.Z, value2.Z), | 348 | MathHelper.Max(value1.Z, value2.Z), |
349 | MathHelper.Max(value1.W, value2.W)); | 349 | MathHelper.Max(value1.W, value2.W)); |
350 | }*/ | 350 | }*/ |
351 | 351 | ||
352 | /*public static void Max(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 352 | /*public static void Max(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
353 | { | 353 | { |
354 | result = new Vector4( | 354 | result = new Vector4( |
355 | MathHelper.Max(value1.X, value2.X), | 355 | MathHelper.Max(value1.X, value2.X), |
356 | MathHelper.Max(value1.Y, value2.Y), | 356 | MathHelper.Max(value1.Y, value2.Y), |
357 | MathHelper.Max(value1.Z, value2.Z), | 357 | MathHelper.Max(value1.Z, value2.Z), |
358 | MathHelper.Max(value1.W, value2.W)); | 358 | MathHelper.Max(value1.W, value2.W)); |
359 | }*/ | 359 | }*/ |
360 | 360 | ||
361 | /*public static Vector4 Min(Vector4 value1, Vector4 value2) | 361 | /*public static Vector4 Min(Vector4 value1, Vector4 value2) |
362 | { | 362 | { |
363 | return new Vector4( | 363 | return new Vector4( |
364 | MathHelper.Min(value1.X, value2.X), | 364 | MathHelper.Min(value1.X, value2.X), |
365 | MathHelper.Min(value1.Y, value2.Y), | 365 | MathHelper.Min(value1.Y, value2.Y), |
366 | MathHelper.Min(value1.Z, value2.Z), | 366 | MathHelper.Min(value1.Z, value2.Z), |
367 | MathHelper.Min(value1.W, value2.W)); | 367 | MathHelper.Min(value1.W, value2.W)); |
368 | }*/ | 368 | }*/ |
369 | 369 | ||
370 | /*public static void Min(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 370 | /*public static void Min(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
371 | { | 371 | { |
372 | result = new Vector4( | 372 | result = new Vector4( |
373 | MathHelper.Min(value1.X, value2.X), | 373 | MathHelper.Min(value1.X, value2.X), |
374 | MathHelper.Min(value1.Y, value2.Y), | 374 | MathHelper.Min(value1.Y, value2.Y), |
375 | MathHelper.Min(value1.Z, value2.Z), | 375 | MathHelper.Min(value1.Z, value2.Z), |
376 | MathHelper.Min(value1.W, value2.W)); | 376 | MathHelper.Min(value1.W, value2.W)); |
377 | }*/ | 377 | }*/ |
378 | 378 | ||
379 | public static Vector4 Multiply(Vector4 value1, Vector4 value2) | 379 | public static Vector4 Multiply(Vector4 value1, Vector4 value2) |
380 | { | 380 | { |
381 | value1.W *= value2.W; | 381 | value1.W *= value2.W; |
382 | value1.X *= value2.X; | 382 | value1.X *= value2.X; |
383 | value1.Y *= value2.Y; | 383 | value1.Y *= value2.Y; |
384 | value1.Z *= value2.Z; | 384 | value1.Z *= value2.Z; |
385 | return value1; | 385 | return value1; |
386 | } | 386 | } |
387 | 387 | ||
388 | public static Vector4 Multiply(Vector4 value1, float scaleFactor) | 388 | public static Vector4 Multiply(Vector4 value1, float scaleFactor) |
389 | { | 389 | { |
390 | value1.W *= scaleFactor; | 390 | value1.W *= scaleFactor; |
391 | value1.X *= scaleFactor; | 391 | value1.X *= scaleFactor; |
392 | value1.Y *= scaleFactor; | 392 | value1.Y *= scaleFactor; |
393 | value1.Z *= scaleFactor; | 393 | value1.Z *= scaleFactor; |
394 | return value1; | 394 | return value1; |
395 | } | 395 | } |
396 | 396 | ||
397 | public static void Multiply(ref Vector4 value1, float scaleFactor, out Vector4 result) | 397 | public static void Multiply(ref Vector4 value1, float scaleFactor, out Vector4 result) |
398 | { | 398 | { |
399 | result.W = value1.W * scaleFactor; | 399 | result.W = value1.W * scaleFactor; |
400 | result.X = value1.X * scaleFactor; | 400 | result.X = value1.X * scaleFactor; |
401 | result.Y = value1.Y * scaleFactor; | 401 | result.Y = value1.Y * scaleFactor; |
402 | result.Z = value1.Z * scaleFactor; | 402 | result.Z = value1.Z * scaleFactor; |
403 | } | 403 | } |
404 | 404 | ||
405 | public static void Multiply(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 405 | public static void Multiply(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
406 | { | 406 | { |
407 | result.W = value1.W * value2.W; | 407 | result.W = value1.W * value2.W; |
408 | result.X = value1.X * value2.X; | 408 | result.X = value1.X * value2.X; |
409 | result.Y = value1.Y * value2.Y; | 409 | result.Y = value1.Y * value2.Y; |
410 | result.Z = value1.Z * value2.Z; | 410 | result.Z = value1.Z * value2.Z; |
411 | } | 411 | } |
412 | 412 | ||
413 | public static Vector4 Negate(Vector4 value) | 413 | public static Vector4 Negate(Vector4 value) |
414 | { | 414 | { |
415 | value = new Vector4(-value.X, -value.Y, -value.Z, -value.W); | 415 | value = new Vector4(-value.X, -value.Y, -value.Z, -value.W); |
416 | return value; | 416 | return value; |
417 | } | 417 | } |
418 | 418 | ||
419 | public static void Negate(ref Vector4 value, out Vector4 result) | 419 | public static void Negate(ref Vector4 value, out Vector4 result) |
420 | { | 420 | { |
421 | result = new Vector4(-value.X, -value.Y, -value.Z,-value.W); | 421 | result = new Vector4(-value.X, -value.Y, -value.Z,-value.W); |
422 | } | 422 | } |
423 | 423 | ||
424 | public void Normalize() | 424 | public void Normalize() |
425 | { | 425 | { |
426 | Normalize(ref this, out this); | 426 | Normalize(ref this, out this); |
427 | } | 427 | } |
428 | 428 | ||
429 | public static Vector4 Normalize(Vector4 vector) | 429 | public static Vector4 Normalize(Vector4 vector) |
430 | { | 430 | { |
431 | Normalize(ref vector, out vector); | 431 | Normalize(ref vector, out vector); |
432 | return vector; | 432 | return vector; |
433 | } | 433 | } |
434 | 434 | ||
435 | public static void Normalize(ref Vector4 vector, out Vector4 result) | 435 | public static void Normalize(ref Vector4 vector, out Vector4 result) |
436 | { | 436 | { |
437 | float factor; | 437 | float factor; |
438 | DistanceSquared(ref vector, ref zeroVector, out factor); | 438 | DistanceSquared(ref vector, ref zeroVector, out factor); |
439 | factor = 1f / (float)Math.Sqrt(factor); | 439 | factor = 1f / (float)Math.Sqrt(factor); |
440 | 440 | ||
441 | result.W = vector.W * factor; | 441 | result.W = vector.W * factor; |
442 | result.X = vector.X * factor; | 442 | result.X = vector.X * factor; |
443 | result.Y = vector.Y * factor; | 443 | result.Y = vector.Y * factor; |
444 | result.Z = vector.Z * factor; | 444 | result.Z = vector.Z * factor; |
445 | } | 445 | } |
446 | 446 | ||
447 | /*public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount) | 447 | /*public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount) |
448 | { | 448 | { |
449 | return new Vector4( | 449 | return new Vector4( |
450 | MathHelper.SmoothStep(value1.X, value2.X, amount), | 450 | MathHelper.SmoothStep(value1.X, value2.X, amount), |
451 | MathHelper.SmoothStep(value1.Y, value2.Y, amount), | 451 | MathHelper.SmoothStep(value1.Y, value2.Y, amount), |
452 | MathHelper.SmoothStep(value1.Z, value2.Z, amount), | 452 | MathHelper.SmoothStep(value1.Z, value2.Z, amount), |
453 | MathHelper.SmoothStep(value1.W, value2.W, amount)); | 453 | MathHelper.SmoothStep(value1.W, value2.W, amount)); |
454 | }*/ | 454 | }*/ |
455 | 455 | ||
456 | /*public static void SmoothStep(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result) | 456 | /*public static void SmoothStep(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result) |
457 | { | 457 | { |
458 | result = new Vector4( | 458 | result = new Vector4( |
459 | MathHelper.SmoothStep(value1.X, value2.X, amount), | 459 | MathHelper.SmoothStep(value1.X, value2.X, amount), |
460 | MathHelper.SmoothStep(value1.Y, value2.Y, amount), | 460 | MathHelper.SmoothStep(value1.Y, value2.Y, amount), |
461 | MathHelper.SmoothStep(value1.Z, value2.Z, amount), | 461 | MathHelper.SmoothStep(value1.Z, value2.Z, amount), |
462 | MathHelper.SmoothStep(value1.W, value2.W, amount)); | 462 | MathHelper.SmoothStep(value1.W, value2.W, amount)); |
463 | }*/ | 463 | }*/ |
464 | 464 | ||
465 | public static Vector4 Subtract(Vector4 value1, Vector4 value2) | 465 | public static Vector4 Subtract(Vector4 value1, Vector4 value2) |
466 | { | 466 | { |
467 | value1.W -= value2.W; | 467 | value1.W -= value2.W; |
468 | value1.X -= value2.X; | 468 | value1.X -= value2.X; |
469 | value1.Y -= value2.Y; | 469 | value1.Y -= value2.Y; |
470 | value1.Z -= value2.Z; | 470 | value1.Z -= value2.Z; |
471 | return value1; | 471 | return value1; |
472 | } | 472 | } |
473 | 473 | ||
474 | public static void Subtract(ref Vector4 value1, ref Vector4 value2, out Vector4 result) | 474 | public static void Subtract(ref Vector4 value1, ref Vector4 value2, out Vector4 result) |
475 | { | 475 | { |
476 | result.W = value1.W - value2.W; | 476 | result.W = value1.W - value2.W; |
477 | result.X = value1.X - value2.X; | 477 | result.X = value1.X - value2.X; |
478 | result.Y = value1.Y - value2.Y; | 478 | result.Y = value1.Y - value2.Y; |
479 | result.Z = value1.Z - value2.Z; | 479 | result.Z = value1.Z - value2.Z; |
480 | } | 480 | } |
481 | 481 | ||
482 | /*public static Vector4 Transform(Vector2 position, Matrix matrix) | 482 | /*public static Vector4 Transform(Vector2 position, Matrix matrix) |
483 | { | 483 | { |
484 | Vector4 result; | 484 | Vector4 result; |
485 | Transform(ref position, ref matrix, out result); | 485 | Transform(ref position, ref matrix, out result); |
486 | return result; | 486 | return result; |
487 | }*/ | 487 | }*/ |
488 | 488 | ||
489 | public static Vector4 Transform(Vector3 position, Matrix matrix) | 489 | public static Vector4 Transform(Vector3 position, Matrix matrix) |
490 | { | 490 | { |
491 | Vector4 result; | 491 | Vector4 result; |
492 | Transform(ref position, ref matrix, out result); | 492 | Transform(ref position, ref matrix, out result); |
493 | return result; | 493 | return result; |
494 | } | 494 | } |
495 | 495 | ||
496 | public static Vector4 Transform(Vector4 vector, Matrix matrix) | 496 | public static Vector4 Transform(Vector4 vector, Matrix matrix) |
497 | { | 497 | { |
498 | Transform(ref vector, ref matrix, out vector); | 498 | Transform(ref vector, ref matrix, out vector); |
499 | return vector; | 499 | return vector; |
500 | } | 500 | } |
501 | 501 | ||
502 | /*public static void Transform(ref Vector2 position, ref Matrix matrix, out Vector4 result) | 502 | /*public static void Transform(ref Vector2 position, ref Matrix matrix, out Vector4 result) |
503 | { | 503 | { |
504 | result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41, | 504 | result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + matrix.M41, |
505 | (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42, | 505 | (position.X * matrix.M12) + (position.Y * matrix.M22) + matrix.M42, |
506 | (position.X * matrix.M13) + (position.Y * matrix.M23) + matrix.M43, | 506 | (position.X * matrix.M13) + (position.Y * matrix.M23) + matrix.M43, |
507 | (position.X * matrix.M14) + (position.Y * matrix.M24) + matrix.M44); | 507 | (position.X * matrix.M14) + (position.Y * matrix.M24) + matrix.M44); |
508 | }*/ | 508 | }*/ |
509 | 509 | ||
510 | public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector4 result) | 510 | public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector4 result) |
511 | { | 511 | { |
512 | result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + (position.Z * matrix.M31) + matrix.M41, | 512 | result = new Vector4((position.X * matrix.M11) + (position.Y * matrix.M21) + (position.Z * matrix.M31) + matrix.M41, |
513 | (position.X * matrix.M12) + (position.Y * matrix.M22) + (position.Z * matrix.M32) + matrix.M42, | 513 | (position.X * matrix.M12) + (position.Y * matrix.M22) + (position.Z * matrix.M32) + matrix.M42, |
514 | (position.X * matrix.M13) + (position.Y * matrix.M23) + (position.Z * matrix.M33) + matrix.M43, | 514 | (position.X * matrix.M13) + (position.Y * matrix.M23) + (position.Z * matrix.M33) + matrix.M43, |
515 | (position.X * matrix.M14) + (position.Y * matrix.M24) + (position.Z * matrix.M34) + matrix.M44); | 515 | (position.X * matrix.M14) + (position.Y * matrix.M24) + (position.Z * matrix.M34) + matrix.M44); |
516 | } | 516 | } |
517 | 517 | ||
518 | public static void Transform(ref Vector4 vector, ref Matrix matrix, out Vector4 result) | 518 | public static void Transform(ref Vector4 vector, ref Matrix matrix, out Vector4 result) |
519 | { | 519 | { |
520 | result = new Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + (vector.W * matrix.M41), | 520 | result = new Vector4((vector.X * matrix.M11) + (vector.Y * matrix.M21) + (vector.Z * matrix.M31) + (vector.W * matrix.M41), |
521 | (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + (vector.W * matrix.M42), | 521 | (vector.X * matrix.M12) + (vector.Y * matrix.M22) + (vector.Z * matrix.M32) + (vector.W * matrix.M42), |
522 | (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + (vector.W * matrix.M43), | 522 | (vector.X * matrix.M13) + (vector.Y * matrix.M23) + (vector.Z * matrix.M33) + (vector.W * matrix.M43), |
523 | (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + (vector.W * matrix.M44)); | 523 | (vector.X * matrix.M14) + (vector.Y * matrix.M24) + (vector.Z * matrix.M34) + (vector.W * matrix.M44)); |
524 | } | 524 | } |
525 | 525 | ||
526 | public override string ToString() | 526 | public override string ToString() |
527 | { | 527 | { |
528 | StringBuilder sb = new StringBuilder(32); | 528 | StringBuilder sb = new StringBuilder(32); |
529 | sb.Append("{X:"); | 529 | sb.Append("{X:"); |
530 | sb.Append(this.X); | 530 | sb.Append(this.X); |
531 | sb.Append(" Y:"); | 531 | sb.Append(" Y:"); |
532 | sb.Append(this.Y); | 532 | sb.Append(this.Y); |
533 | sb.Append(" Z:"); | 533 | sb.Append(" Z:"); |
534 | sb.Append(this.Z); | 534 | sb.Append(this.Z); |
535 | sb.Append(" W:"); | 535 | sb.Append(" W:"); |
536 | sb.Append(this.W); | 536 | sb.Append(this.W); |
537 | sb.Append("}"); | 537 | sb.Append("}"); |
538 | return sb.ToString(); | 538 | return sb.ToString(); |
539 | } | 539 | } |
540 | 540 | ||
541 | #endregion Public Methods | 541 | #endregion Public Methods |
542 | 542 | ||
543 | 543 | ||
544 | #region Operators | 544 | #region Operators |
545 | 545 | ||
546 | public static Vector4 operator -(Vector4 value) | 546 | public static Vector4 operator -(Vector4 value) |
547 | { | 547 | { |
548 | return new Vector4(-value.X, -value.Y, -value.Z, -value.W); | 548 | return new Vector4(-value.X, -value.Y, -value.Z, -value.W); |
549 | } | 549 | } |
550 | 550 | ||
551 | public static bool operator ==(Vector4 value1, Vector4 value2) | 551 | public static bool operator ==(Vector4 value1, Vector4 value2) |
552 | { | 552 | { |
553 | return value1.W == value2.W | 553 | return value1.W == value2.W |
554 | && value1.X == value2.X | 554 | && value1.X == value2.X |
555 | && value1.Y == value2.Y | 555 | && value1.Y == value2.Y |
556 | && value1.Z == value2.Z; | 556 | && value1.Z == value2.Z; |
557 | } | 557 | } |
558 | 558 | ||
559 | public static bool operator !=(Vector4 value1, Vector4 value2) | 559 | public static bool operator !=(Vector4 value1, Vector4 value2) |
560 | { | 560 | { |
561 | return !(value1 == value2); | 561 | return !(value1 == value2); |
562 | } | 562 | } |
563 | 563 | ||
564 | public static Vector4 operator +(Vector4 value1, Vector4 value2) | 564 | public static Vector4 operator +(Vector4 value1, Vector4 value2) |
565 | { | 565 | { |
566 | value1.W += value2.W; | 566 | value1.W += value2.W; |
567 | value1.X += value2.X; | 567 | value1.X += value2.X; |
568 | value1.Y += value2.Y; | 568 | value1.Y += value2.Y; |
569 | value1.Z += value2.Z; | 569 | value1.Z += value2.Z; |
570 | return value1; | 570 | return value1; |
571 | } | 571 | } |
572 | 572 | ||
573 | public static Vector4 operator -(Vector4 value1, Vector4 value2) | 573 | public static Vector4 operator -(Vector4 value1, Vector4 value2) |
574 | { | 574 | { |
575 | value1.W -= value2.W; | 575 | value1.W -= value2.W; |
576 | value1.X -= value2.X; | 576 | value1.X -= value2.X; |
577 | value1.Y -= value2.Y; | 577 | value1.Y -= value2.Y; |
578 | value1.Z -= value2.Z; | 578 | value1.Z -= value2.Z; |
579 | return value1; | 579 | return value1; |
580 | } | 580 | } |
581 | 581 | ||
582 | public static Vector4 operator *(Vector4 value1, Vector4 value2) | 582 | public static Vector4 operator *(Vector4 value1, Vector4 value2) |
583 | { | 583 | { |
584 | value1.W *= value2.W; | 584 | value1.W *= value2.W; |
585 | value1.X *= value2.X; | 585 | value1.X *= value2.X; |
586 | value1.Y *= value2.Y; | 586 | value1.Y *= value2.Y; |
587 | value1.Z *= value2.Z; | 587 | value1.Z *= value2.Z; |
588 | return value1; | 588 | return value1; |
589 | } | 589 | } |
590 | 590 | ||
591 | public static Vector4 operator *(Vector4 value1, float scaleFactor) | 591 | public static Vector4 operator *(Vector4 value1, float scaleFactor) |
592 | { | 592 | { |
593 | value1.W *= scaleFactor; | 593 | value1.W *= scaleFactor; |
594 | value1.X *= scaleFactor; | 594 | value1.X *= scaleFactor; |
595 | value1.Y *= scaleFactor; | 595 | value1.Y *= scaleFactor; |
596 | value1.Z *= scaleFactor; | 596 | value1.Z *= scaleFactor; |
597 | return value1; | 597 | return value1; |
598 | } | 598 | } |
599 | 599 | ||
600 | public static Vector4 operator *(float scaleFactor, Vector4 value1) | 600 | public static Vector4 operator *(float scaleFactor, Vector4 value1) |
601 | { | 601 | { |
602 | value1.W *= scaleFactor; | 602 | value1.W *= scaleFactor; |
603 | value1.X *= scaleFactor; | 603 | value1.X *= scaleFactor; |
604 | value1.Y *= scaleFactor; | 604 | value1.Y *= scaleFactor; |
605 | value1.Z *= scaleFactor; | 605 | value1.Z *= scaleFactor; |
606 | return value1; | 606 | return value1; |
607 | } | 607 | } |
608 | 608 | ||
609 | public static Vector4 operator /(Vector4 value1, Vector4 value2) | 609 | public static Vector4 operator /(Vector4 value1, Vector4 value2) |
610 | { | 610 | { |
611 | value1.W /= value2.W; | 611 | value1.W /= value2.W; |
612 | value1.X /= value2.X; | 612 | value1.X /= value2.X; |
613 | value1.Y /= value2.Y; | 613 | value1.Y /= value2.Y; |
614 | value1.Z /= value2.Z; | 614 | value1.Z /= value2.Z; |
615 | return value1; | 615 | return value1; |
616 | } | 616 | } |
617 | 617 | ||
618 | public static Vector4 operator /(Vector4 value1, float divider) | 618 | public static Vector4 operator /(Vector4 value1, float divider) |
619 | { | 619 | { |
620 | float factor = 1f / divider; | 620 | float factor = 1f / divider; |
621 | value1.W *= factor; | 621 | value1.W *= factor; |
622 | value1.X *= factor; | 622 | value1.X *= factor; |
623 | value1.Y *= factor; | 623 | value1.Y *= factor; |
624 | value1.Z *= factor; | 624 | value1.Z *= factor; |
625 | return value1; | 625 | return value1; |
626 | } | 626 | } |
627 | 627 | ||
628 | #endregion Operators | 628 | #endregion Operators |
629 | } | 629 | } |
630 | } | 630 | } |