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