aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/MonoXnaCompactMaths
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ModifiedBulletX/MonoXnaCompactMaths')
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Matrix.cs690
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/MonoXnaCompactMaths.csproj51
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Properties/AssemblyInfo.cs33
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs431
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector3.cs620
-rw-r--r--libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs630
6 files changed, 0 insertions, 2455 deletions
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Matrix.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Matrix.cs
deleted file mode 100644
index 9b88ab3..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Matrix.cs
+++ /dev/null
@@ -1,690 +0,0 @@
1#region License
2/*
3MIT License
4Copyright © 2006 The Mono.Xna Team
5
6All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25*/
26#endregion License
27
28using System;
29using System.ComponentModel;
30using System.Runtime.InteropServices;
31
32namespace MonoXnaCompactMaths
33{
34 [Serializable]
35 [StructLayout(LayoutKind.Sequential)]
36 //[TypeConverter(typeof(MatrixConverter))]
37 public struct Matrix : IEquatable<Matrix>
38 {
39 #region Public Constructors
40
41 public Matrix(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31,
42 float m32, float m33, float m34, float m41, float m42, float m43, float m44)
43 {
44 this.M11 = m11;
45 this.M12 = m12;
46 this.M13 = m13;
47 this.M14 = m14;
48 this.M21 = m21;
49 this.M22 = m22;
50 this.M23 = m23;
51 this.M24 = m24;
52 this.M31 = m31;
53 this.M32 = m32;
54 this.M33 = m33;
55 this.M34 = m34;
56 this.M41 = m41;
57 this.M42 = m42;
58 this.M43 = m43;
59 this.M44 = m44;
60 }
61
62 #endregion Public Constructors
63
64
65 #region Public Fields
66
67 public float M11;
68 public float M12;
69 public float M13;
70 public float M14;
71 public float M21;
72 public float M22;
73 public float M23;
74 public float M24;
75 public float M31;
76 public float M32;
77 public float M33;
78 public float M34;
79 public float M41;
80 public float M42;
81 public float M43;
82 public float M44;
83
84 #endregion Public Fields
85
86
87 #region Private Members
88 private static Matrix identity = new Matrix(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f);
89 #endregion Private Members
90
91
92 #region Public Properties
93
94 public Vector3 Backward
95 {
96 get
97 {
98 return new Vector3(this.M31, this.M32, this.M33);
99 }
100 set
101 {
102 this.M31 = value.X;
103 this.M32 = value.Y;
104 this.M33 = value.Z;
105 }
106 }
107
108
109 public Vector3 Down
110 {
111 get
112 {
113 return new Vector3(-this.M21, -this.M22, -this.M23);
114 }
115 set
116 {
117 this.M21 = -value.X;
118 this.M22 = -value.Y;
119 this.M23 = -value.Z;
120 }
121 }
122
123
124 public Vector3 Forward
125 {
126 get
127 {
128 return new Vector3(-this.M31, -this.M32, -this.M33);
129 }
130 set
131 {
132 this.M31 = -value.X;
133 this.M32 = -value.Y;
134 this.M33 = -value.Z;
135 }
136 }
137
138
139 public static Matrix Identity
140 {
141 get { return identity; }
142 }
143
144
145 public Vector3 Left
146 {
147 get
148 {
149 return new Vector3(-this.M11, -this.M12, -this.M13);
150 }
151 set
152 {
153 this.M11 = -value.X;
154 this.M12 = -value.Y;
155 this.M13 = -value.Z;
156 }
157 }
158
159
160 public Vector3 Right
161 {
162 get
163 {
164 return new Vector3(this.M11, this.M12, this.M13);
165 }
166 set
167 {
168 this.M11 = value.X;
169 this.M12 = value.Y;
170 this.M13 = value.Z;
171 }
172 }
173
174
175 public Vector3 Translation
176 {
177 get
178 {
179 return new Vector3(this.M41, this.M42, this.M43);
180 }
181 set
182 {
183 this.M41 = value.X;
184 this.M42 = value.Y;
185 this.M43 = value.Z;
186 }
187 }
188
189
190 public Vector3 Up
191 {
192 get
193 {
194 return new Vector3(this.M21, this.M22, this.M23);
195 }
196 set
197 {
198 this.M21 = value.X;
199 this.M22 = value.Y;
200 this.M23 = value.Z;
201 }
202 }
203 #endregion Public Properties
204
205
206 #region Public Methods
207
208 public static Matrix Add(Matrix matrix1, Matrix matrix2)
209 {
210 throw new NotImplementedException();
211 }
212
213
214 public static void Add(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
215 {
216 throw new NotImplementedException();
217 }
218
219
220 public static Matrix CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition,
221 Vector3 cameraUpVector, Nullable<Vector3> cameraForwardVector)
222 {
223 throw new NotImplementedException();
224 }
225
226
227 public static void CreateBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition,
228 ref Vector3 cameraUpVector, Vector3? cameraForwardVector, out Matrix result)
229 {
230 throw new NotImplementedException();
231 }
232
233
234 public static Matrix CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition,
235 Vector3 rotateAxis, Nullable<Vector3> cameraForwardVector, Nullable<Vector3> objectForwardVector)
236 {
237 throw new NotImplementedException();
238 }
239
240
241 public static void CreateConstrainedBillboard(ref Vector3 objectPosition, ref Vector3 cameraPosition,
242 ref Vector3 rotateAxis, Vector3? cameraForwardVector, Vector3? objectForwardVector, out Matrix result)
243 {
244 throw new NotImplementedException();
245 }
246
247
248 public static Matrix CreateFromAxisAngle(Vector3 axis, float angle)
249 {
250 throw new NotImplementedException();
251 }
252
253
254 public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Matrix result)
255 {
256 throw new NotImplementedException();
257 }
258
259
260 public static Matrix CreateFromQuaternion(Quaternion quaternion)
261 {
262 //---
263 //http://lists.ximian.com/pipermail/mono-patches/2006-December/084667.html
264 float xx = quaternion.X * quaternion.X;
265 float xy = quaternion.X * quaternion.Y;
266 float xw = quaternion.X * quaternion.W;
267 float yy = quaternion.Y * quaternion.Y;
268 float yw = quaternion.Y * quaternion.W;
269 float yz = quaternion.Y * quaternion.Z;
270 float zx = quaternion.Z * quaternion.X;
271 float zw = quaternion.Z * quaternion.W;
272 float zz = quaternion.Z * quaternion.Z;
273 return new Matrix(1f - (2f * (yy + zz)), 2f * (xy + zw), 2f * (zx - yw), 0f, 2f * (xy - zw),
274 1f - (2f * (zz + xx)), 2f * (yz + xw), 0f, 2f * (zx + yw), 2f * (yz - xw),
275 1f - (2f * (yy + xx)), 0f, 0f, 0f, 0f, 1f);
276 //throw new NotImplementedException();
277 }
278
279
280 public static void CreateFromQuaternion(ref Quaternion quaternion, out Matrix result)
281 {
282 throw new NotImplementedException();
283 }
284
285
286 public static Matrix CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector)
287 {
288 throw new NotImplementedException();
289 }
290
291
292 public static void CreateLookAt(ref Vector3 cameraPosition, ref Vector3 cameraTarget, ref Vector3 cameraUpVector, out Matrix result)
293 {
294 throw new NotImplementedException();
295 }
296
297
298 public static Matrix CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane)
299 {
300 throw new NotImplementedException();
301 }
302
303
304 public static void CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane, out Matrix result)
305 {
306 throw new NotImplementedException();
307 }
308
309
310 public static Matrix CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
311 {
312 throw new NotImplementedException();
313 }
314
315
316 public static void CreateOrthographicOffCenter(float left, float right, float bottom, float top,
317 float zNearPlane, float zFarPlane, out Matrix result)
318 {
319 throw new NotImplementedException();
320 }
321
322
323 public static Matrix CreatePerspective(float width, float height, float zNearPlane, float zFarPlane)
324 {
325 throw new NotImplementedException();
326 }
327
328
329 public static void CreatePerspective(float width, float height, float zNearPlane, float zFarPlane, out Matrix result)
330 {
331 throw new NotImplementedException();
332 }
333
334
335 public static Matrix CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float zNearPlane, float zFarPlane)
336 {
337 throw new NotImplementedException();
338 }
339
340
341 public static void CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance, out Matrix result)
342 {
343 throw new NotImplementedException();
344 }
345
346
347 public static Matrix CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane)
348 {
349 throw new NotImplementedException();
350 }
351
352
353 public static void CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance, out Matrix result)
354 {
355 throw new NotImplementedException();
356 }
357
358
359 public static Matrix CreateRotationX(float radians)
360 {
361 throw new NotImplementedException();
362 }
363
364
365 public static void CreateRotationX(float radians, out Matrix result)
366 {
367 throw new NotImplementedException();
368 }
369
370
371 public static Matrix CreateRotationY(float radians)
372 {
373 throw new NotImplementedException();
374 }
375
376
377 public static void CreateRotationY(float radians, out Matrix result)
378 {
379 throw new NotImplementedException();
380 }
381
382
383 public static Matrix CreateRotationZ(float radians)
384 {
385 throw new NotImplementedException();
386 }
387
388
389 public static void CreateRotationZ(float radians, out Matrix result)
390 {
391 throw new NotImplementedException();
392 }
393
394
395 public static Matrix CreateScale(float scale)
396 {
397 throw new NotImplementedException();
398 }
399
400
401 public static void CreateScale(float scale, out Matrix result)
402 {
403 throw new NotImplementedException();
404 }
405
406
407 public static Matrix CreateScale(float xScale, float yScale, float zScale)
408 {
409 throw new NotImplementedException();
410 }
411
412
413 public static void CreateScale(float xScale, float yScale, float zScale, out Matrix result)
414 {
415 throw new NotImplementedException();
416 }
417
418
419 public static Matrix CreateScale(Vector3 scales)
420 {
421 throw new NotImplementedException();
422 }
423
424
425 public static void CreateScale(ref Vector3 scales, out Matrix result)
426 {
427 throw new NotImplementedException();
428 }
429
430
431 public static Matrix CreateTranslation(float xPosition, float yPosition, float zPosition)
432 {
433 throw new NotImplementedException();
434 }
435
436
437 public static void CreateTranslation(ref Vector3 position, out Matrix result)
438 {
439 throw new NotImplementedException();
440 }
441
442
443 public static Matrix CreateTranslation(Vector3 position)
444 {
445 throw new NotImplementedException();
446 }
447
448
449 public static void CreateTranslation(float xPosition, float yPosition, float zPosition, out Matrix result)
450 {
451 throw new NotImplementedException();
452 }
453
454
455 public float Determinant()
456 {
457 throw new NotImplementedException();
458 }
459
460
461 public static Matrix Divide(Matrix matrix1, Matrix matrix2)
462 {
463 throw new NotImplementedException();
464 }
465
466
467 public static void Divide(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
468 {
469 throw new NotImplementedException();
470 }
471
472
473 public static Matrix Divide(Matrix matrix1, float divider)
474 {
475 throw new NotImplementedException();
476 }
477
478
479 public static void Divide(ref Matrix matrix1, float divider, out Matrix result)
480 {
481 throw new NotImplementedException();
482 }
483
484
485 public bool Equals(Matrix other)
486 {
487 throw new NotImplementedException();
488 }
489
490
491 public override bool Equals(object obj)
492 {
493 throw new NotImplementedException();
494 }
495
496
497 public override int GetHashCode()
498 {
499 throw new NotImplementedException();
500 }
501
502
503 public static Matrix Invert(Matrix matrix)
504 {
505 throw new NotImplementedException();
506 }
507
508
509 public static void Invert(ref Matrix matrix, out Matrix result)
510 {
511 throw new NotImplementedException();
512 }
513
514
515 public static Matrix Lerp(Matrix matrix1, Matrix matrix2, float amount)
516 {
517 throw new NotImplementedException();
518 }
519
520
521 public static void Lerp(ref Matrix matrix1, ref Matrix matrix2, float amount, out Matrix result)
522 {
523 throw new NotImplementedException();
524 }
525
526 public static Matrix Multiply(Matrix matrix1, Matrix matrix2)
527 {
528 throw new NotImplementedException();
529 }
530
531
532 public static void Multiply(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
533 {
534 throw new NotImplementedException();
535 }
536
537
538 public static Matrix Multiply(Matrix matrix1, float factor)
539 {
540 throw new NotImplementedException();
541 }
542
543
544 public static void Multiply(ref Matrix matrix1, float factor, out Matrix result)
545 {
546 throw new NotImplementedException();
547 }
548
549
550 public static Matrix Negate(Matrix matrix)
551 {
552 throw new NotImplementedException();
553 }
554
555
556 public static void Negate(ref Matrix matrix, out Matrix result)
557 {
558 throw new NotImplementedException();
559 }
560
561
562 public static Matrix operator +(Matrix matrix1, Matrix matrix2)
563 {
564 throw new NotImplementedException();
565 }
566
567
568 public static Matrix operator /(Matrix matrix1, Matrix matrix2)
569 {
570 throw new NotImplementedException();
571 }
572
573
574 public static Matrix operator /(Matrix matrix1, float divider)
575 {
576 return new Matrix(
577 matrix1.M11 / divider, matrix1.M12 / divider, matrix1.M13 / divider, matrix1.M14 / divider,
578 matrix1.M21 / divider, matrix1.M22 / divider, matrix1.M23 / divider, matrix1.M24 / divider,
579 matrix1.M31 / divider, matrix1.M32 / divider, matrix1.M33 / divider, matrix1.M34 / divider,
580 matrix1.M41 / divider, matrix1.M42 / divider, matrix1.M43 / divider, matrix1.M44 / divider);
581 }
582
583
584 public static bool operator ==(Matrix matrix1, Matrix matrix2)
585 {
586 throw new NotImplementedException();
587 }
588
589
590 public static bool operator !=(Matrix matrix1, Matrix matrix2)
591 {
592 throw new NotImplementedException();
593 }
594
595
596 public static Matrix operator *(Matrix matrix1, Matrix matrix2)
597 {
598 //---
599 float[, ] arrayMatrix1 = new float[4, 4];
600 float[, ] arrayMatrix2 = new float[4, 4];
601 float[, ] arrayMatrixProduct = new float[4, 4];
602 arrayMatrix1[0, 0] = matrix1.M11; arrayMatrix1[0, 1] = matrix1.M12; arrayMatrix1[0, 2] = matrix1.M13; arrayMatrix1[0, 3] = matrix1.M14;
603 arrayMatrix1[1, 0] = matrix1.M21; arrayMatrix1[1, 1] = matrix1.M22; arrayMatrix1[1, 2] = matrix1.M23; arrayMatrix1[1, 3] = matrix1.M24;
604 arrayMatrix1[2, 0] = matrix1.M31; arrayMatrix1[2, 1] = matrix1.M32; arrayMatrix1[2, 2] = matrix1.M33; arrayMatrix1[2, 3] = matrix1.M34;
605 arrayMatrix1[3, 0] = matrix1.M41; arrayMatrix1[3, 1] = matrix1.M42; arrayMatrix1[3, 2] = matrix1.M43; arrayMatrix1[3, 3] = matrix1.M44;
606
607 arrayMatrix2[0, 0] = matrix2.M11; arrayMatrix2[0, 1] = matrix2.M12; arrayMatrix2[0, 2] = matrix2.M13; arrayMatrix2[0, 3] = matrix2.M14;
608 arrayMatrix2[1, 0] = matrix2.M21; arrayMatrix2[1, 1] = matrix2.M22; arrayMatrix2[1, 2] = matrix2.M23; arrayMatrix2[1, 3] = matrix2.M24;
609 arrayMatrix2[2, 0] = matrix2.M31; arrayMatrix2[2, 1] = matrix2.M32; arrayMatrix2[2, 2] = matrix2.M33; arrayMatrix2[2, 3] = matrix2.M34;
610 arrayMatrix2[3, 0] = matrix2.M41; arrayMatrix2[3, 1] = matrix2.M42; arrayMatrix2[3, 2] = matrix2.M43; arrayMatrix2[3, 3] = matrix2.M44;
611
612 int n = 4;
613 for (int i = 0; i < n; i++)
614 {
615 for (int j = 0; j < n; j++)
616 {
617 // (AB)[i,j] = Sum(k=0; k < 4; k++) { A[i,k] * B[k, j] }
618 for (int k = 0; k < n; k++)
619 {
620 arrayMatrixProduct[i, j] += arrayMatrix1[i, k] * arrayMatrix2[k, j];
621 }
622 }
623 }
624 return new Matrix( arrayMatrixProduct[0, 0], arrayMatrixProduct[0, 1], arrayMatrixProduct[0, 2], arrayMatrixProduct[0, 3],
625 arrayMatrixProduct[1, 0], arrayMatrixProduct[1, 1], arrayMatrixProduct[1, 2], arrayMatrixProduct[1, 3],
626 arrayMatrixProduct[2, 0], arrayMatrixProduct[2, 1], arrayMatrixProduct[2, 2], arrayMatrixProduct[2, 3],
627 arrayMatrixProduct[3, 1], arrayMatrixProduct[3, 1], arrayMatrixProduct[3, 2], arrayMatrixProduct[3, 3]);
628 //---
629 //throw new NotImplementedException();
630 }
631
632
633 public static Matrix operator *(Matrix matrix, float scaleFactor)
634 {
635 throw new NotImplementedException();
636 }
637
638
639 public static Matrix operator -(Matrix matrix1, Matrix matrix2)
640 {
641 throw new NotImplementedException();
642 }
643
644
645 public static Matrix operator -(Matrix matrix1)
646 {
647 throw new NotImplementedException();
648 }
649
650
651 public static Matrix Subtract(Matrix matrix1, Matrix matrix2)
652 {
653 throw new NotImplementedException();
654 }
655
656
657 public static void Subtract(ref Matrix matrix1, ref Matrix matrix2, out Matrix result)
658 {
659 throw new NotImplementedException();
660 }
661
662
663 public override string ToString()
664 {
665 return "[(" + this.M11 + ", " + this.M12 + ", " + this.M13 + ", " + this.M14 + ")\n ("
666 + this.M21 + ", " + this.M22 + ", " + this.M23 + ", " + this.M24 + ")\n ("
667 + this.M31 + ", " + this.M32 + ", " + this.M33 + ", " + this.M34 + ")\n ("
668 + this.M41 + ", " + this.M42 + ", " + this.M43 + ", " + this.M44 + ")]";
669 }
670
671
672 public static Matrix Transpose(Matrix matrix)
673 {
674 //---
675 return new Matrix( matrix.M11, matrix.M21, matrix.M31, matrix.M41,
676 matrix.M12, matrix.M22, matrix.M32, matrix.M42,
677 matrix.M13, matrix.M23, matrix.M33, matrix.M43,
678 matrix.M14, matrix.M24, matrix.M34, matrix.M44);
679 //---
680 //throw new NotImplementedException();
681 }
682
683
684 public static void Transpose(ref Matrix matrix, out Matrix result)
685 {
686 throw new NotImplementedException();
687 }
688 #endregion Public Methods
689 }
690}
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/MonoXnaCompactMaths.csproj b/libraries/ModifiedBulletX/MonoXnaCompactMaths/MonoXnaCompactMaths.csproj
deleted file mode 100644
index 79c5263..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/MonoXnaCompactMaths.csproj
+++ /dev/null
@@ -1,51 +0,0 @@
1<?xml version="1.0" encoding="utf-8"?>
2<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <PropertyGroup>
4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6 <ProductVersion>8.0.50727</ProductVersion>
7 <SchemaVersion>2.0</SchemaVersion>
8 <ProjectGuid>{121147BC-B06B-406C-84E9-907F268CF0EB}</ProjectGuid>
9 <OutputType>Library</OutputType>
10 <AppDesignerFolder>Properties</AppDesignerFolder>
11 <RootNamespace>MonoXnaCompactMaths</RootNamespace>
12 <AssemblyName>MonoXnaCompactMaths</AssemblyName>
13 <StartupObject>
14 </StartupObject>
15 </PropertyGroup>
16 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17 <DebugSymbols>true</DebugSymbols>
18 <DebugType>full</DebugType>
19 <Optimize>false</Optimize>
20 <OutputPath>bin\Debug\</OutputPath>
21 <DefineConstants>DEBUG;TRACE</DefineConstants>
22 <ErrorReport>prompt</ErrorReport>
23 <WarningLevel>4</WarningLevel>
24 </PropertyGroup>
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26 <DebugType>pdbonly</DebugType>
27 <Optimize>true</Optimize>
28 <OutputPath>bin\Release\</OutputPath>
29 <DefineConstants>TRACE</DefineConstants>
30 <ErrorReport>prompt</ErrorReport>
31 <WarningLevel>4</WarningLevel>
32 </PropertyGroup>
33 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
34 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
35 Other similar extension points exist, see Microsoft.Common.targets.
36 <Target Name="BeforeBuild">
37 </Target>
38 <Target Name="AfterBuild">
39 </Target>
40 -->
41 <ItemGroup>
42 <Compile Include="Matrix.cs" />
43 <Compile Include="Properties\AssemblyInfo.cs" />
44 <Compile Include="Quaternion.cs" />
45 <Compile Include="Vector3.cs" />
46 <Compile Include="Vector4.cs" />
47 </ItemGroup>
48 <ItemGroup>
49 <Reference Include="System" />
50 </ItemGroup>
51</Project> \ No newline at end of file
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Properties/AssemblyInfo.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Properties/AssemblyInfo.cs
deleted file mode 100644
index 366f664..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4
5// La información general sobre un ensamblado se controla mediante el siguiente
6// conjunto de atributos. Cambie estos atributos para modificar la información
7// asociada con un ensamblado.
8[assembly: AssemblyTitle("MonoXnaCompactMaths")]
9[assembly: AssemblyDescription("MonoXnaCompactMaths (Vector3, Vector4, Quaternion and Matrix)")]
10[assembly: AssemblyConfiguration("")]
11[assembly: AssemblyCompany("")]
12[assembly: AssemblyProduct("")]
13[assembly: AssemblyCopyright("Copyright 2006 - 2007 The Mono.Xna Team")]
14[assembly: AssemblyTrademark("")]
15[assembly: AssemblyCulture("")]
16
17// Si establece ComVisible como false hace que los tipos de este ensamblado no sean visibles
18// a los componentes COM. Si necesita obtener acceso a un tipo en este ensamblado desde
19// COM, establezca el atributo ComVisible como true en este tipo.
20[assembly: ComVisible(false)]
21
22// El siguiente GUID sirve como identificador de la biblioteca de tipos si este proyecto se expone a COM
23[assembly: Guid("79f9dfd1-60f8-44b8-ab08-6f6e341976b7")]
24
25// La información de versión de un ensamblado consta de los cuatro valores siguientes:
26//
27// Versión principal
28// Versión secundaria
29// Número de versión de compilación
30// Revisión
31//
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
deleted file mode 100644
index b6d9d34..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Quaternion.cs
+++ /dev/null
@@ -1,431 +0,0 @@
1#region License
2/*
3MIT License
4Copyright © 2006 The Mono.Xna Team
5
6All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25*/
26#endregion License
27
28using System;
29using System.ComponentModel;
30
31namespace MonoXnaCompactMaths
32{
33 [Serializable]
34 //[TypeConverter(typeof(QuaternionConverter))]
35 public struct Quaternion : IEquatable<Quaternion>
36 {
37 public float X;
38 public float Y;
39 public float Z;
40 public float W;
41 static Quaternion identity = new Quaternion(0, 0, 0, 1);
42
43
44 public Quaternion(float x, float y, float z, float w)
45 {
46 this.X = x;
47 this.Y = y;
48 this.Z = z;
49 this.W = w;
50 }
51
52
53 public Quaternion(Vector3 vectorPart, float scalarPart)
54 {
55 this.X = vectorPart.X;
56 this.Y = vectorPart.Y;
57 this.Z = vectorPart.Z;
58 this.W = scalarPart;
59 }
60
61 public static Quaternion Identity
62 {
63 get{ return identity; }
64 }
65
66
67 public static Quaternion Add(Quaternion quaternion1, Quaternion quaternion2)
68 {
69 throw new NotImplementedException();
70 }
71
72
73 public static void Add(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
74 {
75 throw new NotImplementedException();
76 }
77
78
79 public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle)
80 {
81 throw new NotImplementedException();
82 }
83
84
85 public static void CreateFromAxisAngle(ref Vector3 axis, float angle, out Quaternion result)
86 {
87 throw new NotImplementedException();
88 }
89
90
91 public static Quaternion CreateFromRotationMatrix(Matrix matrix)
92 {
93 float Omega2 = matrix.M44;
94 if (!isAprox(Omega2, 1f))
95 {
96 //"Normalize" the Rotation matrix. Norma = M44 = Omega2
97 matrix = matrix / Omega2;
98 }
99 //Deducted from: public static Matrix CreateFromQuaternion(Quaternion quaternion)
100 float lambda1pos, lambda2pos, lambda3pos, lambda1neg, lambda2neg, lambda3neg;
101 lambda1pos = (1f - matrix.M11 + matrix.M23 + matrix.M32) / 2f;
102 lambda2pos = (1f - matrix.M22 + matrix.M13 + matrix.M31) / 2f;
103 lambda3pos = (1f - matrix.M33 + matrix.M12 + matrix.M21) / 2f;
104 lambda1neg = (1f - matrix.M11 - matrix.M23 - matrix.M32) / 2f;
105 lambda2neg = (1f - matrix.M22 - matrix.M13 - matrix.M31) / 2f;
106 lambda3neg = (1f - matrix.M33 - matrix.M12 - matrix.M21) / 2f;
107
108 //lambadIS = (qJ + s*qK)^2
109 //q0 = w | q1 = x | q2 = y, q3 = z
110 //Every value of qI (I=1,2,3) has 4 possible values cause the sqrt
111 float[] x = new float[4]; float[] y = new float[4]; float[] z = new float[4];
112 float[] sig1 = {1f, 1f, -1f, -1f};
113 float[] sig2 = {1f, -1f, 1f, -1f};
114 for (int i = 0; i < 4; i++)
115 {
116 x[i] = (sig1[i] * (float)Math.Sqrt(lambda1pos) + sig2[i] * (float)Math.Sqrt(lambda1neg)) / 2f;
117 y[i] = (sig1[i] * (float)Math.Sqrt(lambda2pos) + sig2[i] * (float)Math.Sqrt(lambda2neg)) / 2f;
118 z[i] = (sig1[i] * (float)Math.Sqrt(lambda3pos) + sig2[i] * (float)Math.Sqrt(lambda3neg)) / 2f;
119 }
120
121 //Only a set of x, y, z are the corrects values. So it requires testing
122 int li_i=0, li_j=0, li_k=0;
123 bool lb_testL1P, lb_testL2P, lb_testL3P, lb_testL1N, lb_testL2N, lb_testL3N;
124 bool lb_superLambda = false;
125 while((li_i<4)&&(!lb_superLambda))
126 {
127 while ((li_j < 4) && (!lb_superLambda))
128 {
129 while ((li_k < 4) && (!lb_superLambda))
130 {
131 lb_testL1P = isAprox((float)(
132 Math.Pow((double)(y[li_j] + z[li_k]), 2.0)), lambda1pos);
133 lb_testL2P = isAprox((float)(
134 Math.Pow((double)(x[li_i] + z[li_k]), 2.0)), lambda2pos);
135 lb_testL3P = isAprox((float)(
136 Math.Pow((double)(x[li_i] + y[li_j]), 2.0)), lambda3pos);
137 lb_testL1N = isAprox((float)(
138 Math.Pow((double)(y[li_j] - z[li_k]), 2.0)), lambda1neg);
139 lb_testL2N = isAprox((float)(
140 Math.Pow((double)(x[li_i] - z[li_k]), 2.0)), lambda2neg);
141 lb_testL3N = isAprox((float)(
142 Math.Pow((double)(x[li_i] - y[li_j]), 2.0)), lambda3neg);
143
144 lb_superLambda = (lb_testL1P && lb_testL2P && lb_testL3P
145 && lb_testL1N && lb_testL2N && lb_testL3N);
146
147 if (!lb_superLambda) li_k++;
148 }
149 if (!lb_superLambda) li_j++;
150 }
151 if (!lb_superLambda) li_i++;
152 }
153
154 Quaternion q = new Quaternion();
155
156 if (lb_superLambda)
157 {
158 q.X = x[li_i]; q.Y = y[li_j]; q.Z = z[li_k];
159 q.W = (matrix.M12 - 2f * q.X * q.Y) / (2f * q.Z);
160
161 if (!isAprox(Omega2, 1f))
162 {
163 if (Omega2 < 0) throw new Exception("Quaternion.CreateFromRotationMatrix: Omega2 is negative!");
164 q = q * (float)Math.Sqrt(Omega2);//2 possibles values (+/-). For now only 1.
165 }
166 }
167 else
168 {
169 q = Quaternion.identity;
170 }
171
172 return q;
173 }
174 private static float floatError = 0.000001f;
175 private static bool isAprox(float test, float realValue)
176 {
177 return (((realValue * (1f - floatError)) <= test) && (test <= (realValue * (1f + floatError))));
178 }
179
180
181 public static void CreateFromRotationMatrix(ref Matrix matrix, out Quaternion result)
182 {
183 throw new NotImplementedException();
184 }
185
186
187 public static Quaternion Divide(Quaternion quaternion1, Quaternion quaternion2)
188 {
189 throw new NotImplementedException();
190 }
191
192
193 public static void Divide(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
194 {
195 throw new NotImplementedException();
196 }
197
198
199 public static float Dot(Quaternion quaternion1, Quaternion quaternion2)
200 {
201 throw new NotImplementedException();
202 }
203
204
205 public static void Dot(ref Quaternion quaternion1, ref Quaternion quaternion2, out float result)
206 {
207 throw new NotImplementedException();
208 }
209
210
211 public override bool Equals(object obj)
212 {
213 throw new NotImplementedException();
214 }
215
216
217 public bool Equals(Quaternion other)
218 {
219 throw new NotImplementedException();
220 }
221
222
223 public override int GetHashCode()
224 {
225 throw new NotImplementedException();
226 }
227
228
229 public static Quaternion Inverse(Quaternion quaternion)
230 {
231 throw new NotImplementedException();
232 }
233
234
235 public static void Inverse(ref Quaternion quaternion, out Quaternion result)
236 {
237 throw new NotImplementedException();
238 }
239
240
241 public float Length()
242 {
243 //---
244 return (float)Math.Sqrt(Math.Pow(this.W, 2.0) + Math.Pow(this.X, 2.0) + Math.Pow(this.Y, 2.0) + Math.Pow(this.Z, 2.0));
245 //---
246 //throw new NotImplementedException();
247 }
248
249
250 public float LengthSquared()
251 {
252 //---
253 return (float)(Math.Pow(this.W, 2.0) + Math.Pow(this.X, 2.0) + Math.Pow(this.Y, 2.0) + Math.Pow(this.Z, 2.0));
254 //---
255 //throw new NotImplementedException();
256 }
257
258
259 public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
260 {
261 throw new NotImplementedException();
262 }
263
264
265 public static void Lerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
266 {
267 throw new NotImplementedException();
268 }
269
270
271 public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount)
272 {
273 throw new NotImplementedException();
274 }
275
276
277 public static void Slerp(ref Quaternion quaternion1, ref Quaternion quaternion2, float amount, out Quaternion result)
278 {
279 throw new NotImplementedException();
280 }
281
282
283 public static Quaternion Subtract(Quaternion quaternion1, Quaternion quaternion2)
284 {
285 throw new NotImplementedException();
286 }
287
288
289 public static void Subtract(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
290 {
291 throw new NotImplementedException();
292 }
293
294
295 public static Quaternion Multiply(Quaternion quaternion1, Quaternion quaternion2)
296 {
297 throw new NotImplementedException();
298 }
299
300
301 public static Quaternion Multiply(Quaternion quaternion1, float scaleFactor)
302 {
303 throw new NotImplementedException();
304 }
305
306
307 public static void Multiply(ref Quaternion quaternion1, float scaleFactor, out Quaternion result)
308 {
309 throw new NotImplementedException();
310 }
311
312
313 public static void Multiply(ref Quaternion quaternion1, ref Quaternion quaternion2, out Quaternion result)
314 {
315 throw new NotImplementedException();
316 }
317
318
319 public static Quaternion Negate(Quaternion quaternion)
320 {
321 throw new NotImplementedException();
322 }
323
324
325 public static void Negate(ref Quaternion quaternion, out Quaternion result)
326 {
327 throw new NotImplementedException();
328 }
329
330
331 public void Normalize()
332 {
333 //---
334 this = Normalize(this);
335 //---
336 //throw new NotImplementedException();
337 }
338
339
340 public static Quaternion Normalize(Quaternion quaternion)
341 {
342 //---
343 return quaternion / quaternion.Length();
344 //---
345 //throw new NotImplementedException();
346 }
347
348
349 public static void Normalize(ref Quaternion quaternion, out Quaternion result)
350 {
351 throw new NotImplementedException();
352 }
353
354
355 public static Quaternion operator +(Quaternion quaternion1, Quaternion quaternion2)
356 {
357 throw new NotImplementedException();
358 }
359
360
361 public static Quaternion operator /(Quaternion quaternion1, Quaternion quaternion2)
362 {
363 throw new NotImplementedException();
364 }
365 public static Quaternion operator /(Quaternion quaternion, float factor)
366 {
367 quaternion.W /= factor;
368 quaternion.X /= factor;
369 quaternion.Y /= factor;
370 quaternion.Z /= factor;
371 return quaternion;
372 }
373
374 public static bool operator ==(Quaternion quaternion1, Quaternion quaternion2)
375 {
376 throw new NotImplementedException();
377 }
378
379
380 public static bool operator !=(Quaternion quaternion1, Quaternion quaternion2)
381 {
382 throw new NotImplementedException();
383 }
384
385
386 public static Quaternion operator *(Quaternion quaternion1, Quaternion quaternion2)
387 {
388 //---
389 //Grassmann product
390 Quaternion quaternionProduct = new Quaternion();
391
392 quaternionProduct.W = quaternion1.W * quaternion2.W - quaternion1.X * quaternion2.X - quaternion1.Y * quaternion2.Y - quaternion1.Z * quaternion2.Z;
393 quaternionProduct.X = quaternion1.W * quaternion2.X + quaternion1.X * quaternion2.W + quaternion1.Y * quaternion2.Z - quaternion1.Z * quaternion2.Y;
394 quaternionProduct.Y = quaternion1.W * quaternion2.Y - quaternion1.X * quaternion2.Z + quaternion1.Y * quaternion2.W + quaternion1.Z * quaternion2.X;
395 quaternionProduct.Z = quaternion1.W * quaternion2.Z + quaternion1.X * quaternion2.Y - quaternion1.Y * quaternion2.X + quaternion1.Z * quaternion2.W;
396 return quaternionProduct;
397 //---
398 //throw new NotImplementedException();
399 }
400
401
402 public static Quaternion operator *(Quaternion quaternion1, float scaleFactor)
403 {
404 return new Quaternion(quaternion1.X / scaleFactor, quaternion1.Y / scaleFactor,
405 quaternion1.Z / scaleFactor, quaternion1.W / scaleFactor);
406 }
407
408
409 public static Quaternion operator -(Quaternion quaternion1, Quaternion quaternion2)
410 {
411 throw new NotImplementedException();
412 }
413
414
415 public static Quaternion operator -(Quaternion quaternion)
416 {
417 throw new NotImplementedException();
418 }
419
420
421 public override string ToString()
422 {
423 return "(" + this.X + ", " + this.Y + ", " + this.Z + ", " + this.W + ")";
424 }
425
426 private static void Conjugate(ref Quaternion quaternion, out Quaternion result)
427 {
428 throw new NotImplementedException();
429 }
430 }
431}
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector3.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector3.cs
deleted file mode 100644
index f246415..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector3.cs
+++ /dev/null
@@ -1,620 +0,0 @@
1#region License
2/*
3MIT License
4Copyright © 2006 The Mono.Xna Team
5
6All rights reserved.
7
8Authors:
9 * Alan McGovern
10
11Permission is hereby granted, free of charge, to any person obtaining a copy
12of this software and associated documentation files (the "Software"), to deal
13in the Software without restriction, including without limitation the rights
14to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15copies of the Software, and to permit persons to whom the Software is
16furnished to do so, subject to the following conditions:
17
18The above copyright notice and this permission notice shall be included in all
19copies or substantial portions of the Software.
20
21THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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
27SOFTWARE.
28*/
29#endregion License
30
31using System;
32using System.ComponentModel;
33using System.Text;
34using System.Runtime.InteropServices;
35
36namespace MonoXnaCompactMaths
37{
38 [Serializable]
39 [StructLayout(LayoutKind.Sequential)]
40 //[TypeConverter(typeof(Vector3Converter))]
41 public struct Vector3 : IEquatable<Vector3>
42 {
43 #region Private Fields
44
45 private static Vector3 zero = new Vector3(0f, 0f, 0f);
46 private static Vector3 one = new Vector3(1f, 1f, 1f);
47 private static Vector3 unitX = new Vector3(1f, 0f, 0f);
48 private static Vector3 unitY = new Vector3(0f, 1f, 0f);
49 private static Vector3 unitZ = new Vector3(0f, 0f, 1f);
50 private static Vector3 up = 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);
53 private static Vector3 left = new Vector3(-1f, 0f, 0f);
54 private static Vector3 forward = new Vector3(0f, 0f, -1f);
55 private static Vector3 backward = new Vector3(0f, 0f, 1f);
56
57 #endregion Private Fields
58
59
60 #region Public Fields
61
62 public float X;
63 public float Y;
64 public float Z;
65
66 #endregion Public Fields
67
68
69 #region Properties
70
71 public static Vector3 Zero
72 {
73 get { return zero; }
74 }
75
76 public static Vector3 One
77 {
78 get { return one; }
79 }
80
81 public static Vector3 UnitX
82 {
83 get { return unitX; }
84 }
85
86 public static Vector3 UnitY
87 {
88 get { return unitY; }
89 }
90
91 public static Vector3 UnitZ
92 {
93 get { return unitZ; }
94 }
95
96 public static Vector3 Up
97 {
98 get { return up; }
99 }
100
101 public static Vector3 Down
102 {
103 get { return down; }
104 }
105
106 public static Vector3 Right
107 {
108 get { return right; }
109 }
110
111 public static Vector3 Left
112 {
113 get { return left; }
114 }
115
116 public static Vector3 Forward
117 {
118 get { return forward; }
119 }
120
121 public static Vector3 Backward
122 {
123 get { return backward; }
124 }
125
126 #endregion Properties
127
128
129 #region Constructors
130
131 public Vector3(float x, float y, float z)
132 {
133 this.X = x;
134 this.Y = y;
135 this.Z = z;
136 }
137
138
139 public Vector3(float value)
140 {
141 this.X = value;
142 this.Y = value;
143 this.Z = value;
144 }
145
146
147 /*public Vector3(Vector2 value, float z)
148 {
149 this.X = value.X;
150 this.Y = value.Y;
151 this.Z = z;
152 }*/
153
154
155 #endregion Constructors
156
157
158 #region Public Methods
159
160 public static Vector3 Add(Vector3 value1, Vector3 value2)
161 {
162 value1.X += value2.X;
163 value1.Y += value2.Y;
164 value1.Z += value2.Z;
165 return value1;
166 }
167
168 public static void Add(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
169 {
170 result.X = value1.X + value2.X;
171 result.Y = value1.Y + value2.Y;
172 result.Z = value1.Z + value2.Z;
173 }
174
175 /*public static Vector3 Barycentric(Vector3 value1, Vector3 value2, Vector3 value3, float amount1, float amount2)
176 {
177 return new Vector3(
178 MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
179 MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
180 MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2));
181 }*/
182
183 /*public static void Barycentric(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, float amount1, float amount2, out Vector3 result)
184 {
185 result = new Vector3(
186 MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
187 MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
188 MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2));
189 }*/
190
191 /*public static Vector3 CatmullRom(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float amount)
192 {
193 return new Vector3(
194 MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, 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));
197 }*/
198
199 /*public static void CatmullRom(ref Vector3 value1, ref Vector3 value2, ref Vector3 value3, ref Vector3 value4, float amount, out Vector3 result)
200 {
201 result = new Vector3(
202 MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, 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));
205 }*/
206
207 /*public static Vector3 Clamp(Vector3 value1, Vector3 min, Vector3 max)
208 {
209 return new Vector3(
210 MathHelper.Clamp(value1.X, min.X, max.X),
211 MathHelper.Clamp(value1.Y, min.Y, max.Y),
212 MathHelper.Clamp(value1.Z, min.Z, max.Z));
213 }*/
214
215 /*public static void Clamp(ref Vector3 value1, ref Vector3 min, ref Vector3 max, out Vector3 result)
216 {
217 result = new Vector3(
218 MathHelper.Clamp(value1.X, min.X, max.X),
219 MathHelper.Clamp(value1.Y, min.Y, max.Y),
220 MathHelper.Clamp(value1.Z, min.Z, max.Z));
221 }*/
222
223 public static Vector3 Cross(Vector3 vector1, Vector3 vector2)
224 {
225 Cross(ref vector1, ref vector2, out vector1);
226 return vector1;
227 }
228
229 public static void Cross(ref Vector3 vector1, ref Vector3 vector2, out Vector3 result)
230 {
231 result = new Vector3(vector1.Y * vector2.Z - vector2.Y * vector1.Z,
232 -(vector1.X * vector2.Z - vector2.X * vector1.Z),
233 vector1.X * vector2.Y - vector2.X * vector1.Y);
234 }
235
236 public static float Distance(Vector3 vector1, Vector3 vector2)
237 {
238 float result;
239 DistanceSquared(ref vector1, ref vector2, out result);
240 return (float)Math.Sqrt(result);
241 }
242
243 public static void Distance(ref Vector3 value1, ref Vector3 value2, out float result)
244 {
245 DistanceSquared(ref value1, ref value2, out result);
246 result = (float)Math.Sqrt(result);
247 }
248
249 public static float DistanceSquared(Vector3 value1, Vector3 value2)
250 {
251 float result;
252 DistanceSquared(ref value1, ref value2, out result);
253 return result;
254 }
255
256 public static void DistanceSquared(ref Vector3 value1, ref Vector3 value2, out float result)
257 {
258 result = (value1.X - value2.X) * (value1.X - value2.X) +
259 (value1.Y - value2.Y) * (value1.Y - value2.Y) +
260 (value1.Z - value2.Z) * (value1.Z - value2.Z);
261 }
262
263 public static Vector3 Divide(Vector3 value1, Vector3 value2)
264 {
265 value1.X /= value2.X;
266 value1.Y /= value2.Y;
267 value1.Z /= value2.Z;
268 return value1;
269 }
270
271 public static Vector3 Divide(Vector3 value1, float value2)
272 {
273 float factor = 1 / value2;
274 value1.X *= factor;
275 value1.Y *= factor;
276 value1.Z *= factor;
277 return value1;
278 }
279
280 public static void Divide(ref Vector3 value1, float divisor, out Vector3 result)
281 {
282 float factor = 1 / divisor;
283 result.X = value1.X * factor;
284 result.Y = value1.Y * factor;
285 result.Z = value1.Z * factor;
286 }
287
288 public static void Divide(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
289 {
290 result.X = value1.X / value2.X;
291 result.Y = value1.Y / value2.Y;
292 result.Z = value1.Z / value2.Z;
293 }
294
295 public static float Dot(Vector3 vector1, Vector3 vector2)
296 {
297 return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z;
298 }
299
300 public static void Dot(ref Vector3 vector1, ref Vector3 vector2, out float result)
301 {
302 result = vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z;
303 }
304
305 public override bool Equals(object obj)
306 {
307 return (obj is Vector3) ? this == (Vector3)obj : false;
308 }
309
310 public bool Equals(Vector3 other)
311 {
312 return this == other;
313 }
314
315 public override int GetHashCode()
316 {
317 return (int)(this.X + this.Y + this.Z);
318 }
319
320 /*public static Vector3 Hermite(Vector3 value1, Vector3 tangent1, Vector3 value2, Vector3 tangent2, float amount)
321 {
322 Vector3 result = new Vector3();
323 Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
324 return result;
325 }*/
326
327 /*public static void Hermite(ref Vector3 value1, ref Vector3 tangent1, ref Vector3 value2, ref Vector3 tangent2, float amount, out Vector3 result)
328 {
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);
331 result.Z = MathHelper.Hermite(value1.Z, tangent1.Z, value2.Z, tangent2.Z, amount);
332 }*/
333
334 public float Length()
335 {
336 float result;
337 DistanceSquared(ref this, ref zero, out result);
338 return (float)Math.Sqrt(result);
339 }
340
341 public float LengthSquared()
342 {
343 float result;
344 DistanceSquared(ref this, ref zero, out result);
345 return result;
346 }
347
348 /*public static Vector3 Lerp(Vector3 value1, Vector3 value2, float amount)
349 {
350 return new Vector3(
351 MathHelper.Lerp(value1.X, value2.X, amount),
352 MathHelper.Lerp(value1.Y, value2.Y, amount),
353 MathHelper.Lerp(value1.Z, value2.Z, amount));
354 }*/
355
356 /*public static void Lerp(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
357 {
358 result = new Vector3(
359 MathHelper.Lerp(value1.X, value2.X, amount),
360 MathHelper.Lerp(value1.Y, value2.Y, amount),
361 MathHelper.Lerp(value1.Z, value2.Z, amount));
362 }*/
363
364 /*public static Vector3 Max(Vector3 value1, Vector3 value2)
365 {
366 return new Vector3(
367 MathHelper.Max(value1.X, value2.X),
368 MathHelper.Max(value1.Y, value2.Y),
369 MathHelper.Max(value1.Z, value2.Z));
370 }*/
371
372 /*public static void Max(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
373 {
374 result = new Vector3(
375 MathHelper.Max(value1.X, value2.X),
376 MathHelper.Max(value1.Y, value2.Y),
377 MathHelper.Max(value1.Z, value2.Z));
378 }*/
379
380 /*public static Vector3 Min(Vector3 value1, Vector3 value2)
381 {
382 return new Vector3(
383 MathHelper.Min(value1.X, value2.X),
384 MathHelper.Min(value1.Y, value2.Y),
385 MathHelper.Min(value1.Z, value2.Z));
386 }*/
387
388 /*public static void Min(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
389 {
390 result = new Vector3(
391 MathHelper.Min(value1.X, value2.X),
392 MathHelper.Min(value1.Y, value2.Y),
393 MathHelper.Min(value1.Z, value2.Z));
394 }*/
395
396 public static Vector3 Multiply(Vector3 value1, Vector3 value2)
397 {
398 value1.X *= value2.X;
399 value1.Y *= value2.Y;
400 value1.Z *= value2.Z;
401 return value1;
402 }
403
404 public static Vector3 Multiply(Vector3 value1, float scaleFactor)
405 {
406 value1.X *= scaleFactor;
407 value1.Y *= scaleFactor;
408 value1.Z *= scaleFactor;
409 return value1;
410 }
411
412 public static void Multiply(ref Vector3 value1, float scaleFactor, out Vector3 result)
413 {
414 result.X = value1.X * scaleFactor;
415 result.Y = value1.Y * scaleFactor;
416 result.Z = value1.Z * scaleFactor;
417 }
418
419 public static void Multiply(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
420 {
421 result.X = value1.X * value2.X;
422 result.Y = value1.Y * value2.Y;
423 result.Z = value1.Z * value2.Z;
424 }
425
426 public static Vector3 Negate(Vector3 value)
427 {
428 value = new Vector3(-value.X, -value.Y, -value.Z);
429 return value;
430 }
431
432 public static void Negate(ref Vector3 value, out Vector3 result)
433 {
434 result = new Vector3(-value.X, -value.Y, -value.Z);
435 }
436
437 public void Normalize()
438 {
439 Normalize(ref this, out this);
440 }
441
442 public static Vector3 Normalize(Vector3 vector)
443 {
444 Normalize(ref vector, out vector);
445 return vector;
446 }
447
448 public static void Normalize(ref Vector3 value, out Vector3 result)
449 {
450 float factor;
451 Distance(ref value, ref zero, out factor);
452 factor = 1f / factor;
453 result.X = value.X * factor;
454 result.Y = value.Y * factor;
455 result.Z = value.Z * factor;
456 }
457
458 public static Vector3 Reflect(Vector3 vector, Vector3 normal)
459 {
460 throw new NotImplementedException();
461 }
462
463 public static void Reflect(ref Vector3 vector, ref Vector3 normal, out Vector3 result)
464 {
465 throw new NotImplementedException();
466 }
467
468 /*public static Vector3 SmoothStep(Vector3 value1, Vector3 value2, float amount)
469 {
470 return new Vector3(
471 MathHelper.SmoothStep(value1.X, value2.X, amount),
472 MathHelper.SmoothStep(value1.Y, value2.Y, amount),
473 MathHelper.SmoothStep(value1.Z, value2.Z, amount));
474 }*/
475
476 /*public static void SmoothStep(ref Vector3 value1, ref Vector3 value2, float amount, out Vector3 result)
477 {
478 result = new Vector3(
479 MathHelper.SmoothStep(value1.X, value2.X, amount),
480 MathHelper.SmoothStep(value1.Y, value2.Y, amount),
481 MathHelper.SmoothStep(value1.Z, value2.Z, amount));
482 }*/
483
484 public static Vector3 Subtract(Vector3 value1, Vector3 value2)
485 {
486 value1.X -= value2.X;
487 value1.Y -= value2.Y;
488 value1.Z -= value2.Z;
489 return value1;
490 }
491
492 public static void Subtract(ref Vector3 value1, ref Vector3 value2, out Vector3 result)
493 {
494 result.X = value1.X - value2.X;
495 result.Y = value1.Y - value2.Y;
496 result.Z = value1.Z - value2.Z;
497 }
498
499 public override string ToString()
500 {
501 StringBuilder sb = new StringBuilder(32);
502 sb.Append("{X:");
503 sb.Append(this.X);
504 sb.Append(" Y:");
505 sb.Append(this.Y);
506 sb.Append(" Z:");
507 sb.Append(this.Z);
508 sb.Append("}");
509 return sb.ToString();
510 }
511
512 public static Vector3 Transform(Vector3 position, Matrix matrix)
513 {
514 Transform(ref position, ref matrix, out position);
515 return position;
516 }
517
518 public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector3 result)
519 {
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,
522 (position.X * matrix.M13) + (position.Y * matrix.M23) + (position.Z * matrix.M33) + matrix.M43);
523 }
524
525 public static Vector3 TransformNormal(Vector3 normal, Matrix matrix)
526 {
527 TransformNormal(ref normal, ref matrix, out normal);
528 return normal;
529 }
530
531 public static void TransformNormal(ref Vector3 normal, ref Matrix matrix, out Vector3 result)
532 {
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),
535 (normal.X * matrix.M13) + (normal.Y * matrix.M23) + (normal.Z * matrix.M33));
536 }
537
538 #endregion Public methods
539
540
541 #region Operators
542
543 public static bool operator ==(Vector3 value1, Vector3 value2)
544 {
545 return value1.X == value2.X
546 && value1.Y == value2.Y
547 && value1.Z == value2.Z;
548 }
549
550 public static bool operator !=(Vector3 value1, Vector3 value2)
551 {
552 return !(value1 == value2);
553 }
554
555 public static Vector3 operator +(Vector3 value1, Vector3 value2)
556 {
557 value1.X += value2.X;
558 value1.Y += value2.Y;
559 value1.Z += value2.Z;
560 return value1;
561 }
562
563 public static Vector3 operator -(Vector3 value)
564 {
565 value = new Vector3(-value.X, -value.Y, -value.Z);
566 return value;
567 }
568
569 public static Vector3 operator -(Vector3 value1, Vector3 value2)
570 {
571 value1.X -= value2.X;
572 value1.Y -= value2.Y;
573 value1.Z -= value2.Z;
574 return value1;
575 }
576
577 public static Vector3 operator *(Vector3 value1, Vector3 value2)
578 {
579 value1.X *= value2.X;
580 value1.Y *= value2.Y;
581 value1.Z *= value2.Z;
582 return value1;
583 }
584
585 public static Vector3 operator *(Vector3 value, float scaleFactor)
586 {
587 value.X *= scaleFactor;
588 value.Y *= scaleFactor;
589 value.Z *= scaleFactor;
590 return value;
591 }
592
593 public static Vector3 operator *(float scaleFactor, Vector3 value)
594 {
595 value.X *= scaleFactor;
596 value.Y *= scaleFactor;
597 value.Z *= scaleFactor;
598 return value;
599 }
600
601 public static Vector3 operator /(Vector3 value1, Vector3 value2)
602 {
603 value1.X /= value2.X;
604 value1.Y /= value2.Y;
605 value1.Z /= value2.Z;
606 return value1;
607 }
608
609 public static Vector3 operator /(Vector3 value, float divider)
610 {
611 float factor = 1 / divider;
612 value.X *= factor;
613 value.Y *= factor;
614 value.Z *= factor;
615 return value;
616 }
617
618 #endregion
619 }
620}
diff --git a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs b/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs
deleted file mode 100644
index abb30a8..0000000
--- a/libraries/ModifiedBulletX/MonoXnaCompactMaths/Vector4.cs
+++ /dev/null
@@ -1,630 +0,0 @@
1#region License
2/*
3MIT License
4Copyright © 2006 The Mono.Xna Team
5
6All rights reserved.
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in all
16copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24SOFTWARE.
25*/
26#endregion License
27
28using System;
29using System.ComponentModel;
30using System.Text;
31using System.Runtime.InteropServices;
32
33namespace MonoXnaCompactMaths
34{
35 [Serializable]
36 [StructLayout(LayoutKind.Sequential)]
37 //[TypeConverter(typeof(Vector4Converter))]
38 public struct Vector4 : IEquatable<Vector4>
39 {
40 #region Private Fields
41
42 private static Vector4 zeroVector = new Vector4();
43 private static Vector4 unitVector = new Vector4(1f, 1f, 1f, 1f);
44 private static Vector4 unitXVector = new Vector4(1f, 0f, 0f, 0f);
45 private static Vector4 unitYVector = new Vector4(0f, 1f, 0f, 0f);
46 private static Vector4 unitZVector = new Vector4(0f, 0f, 1f, 0f);
47 private static Vector4 unitWVector = new Vector4(0f, 0f, 0f, 1f);
48
49 #endregion Private Fields
50
51
52 #region Public Fields
53
54 public float X;
55 public float Y;
56 public float Z;
57 public float W;
58
59 #endregion Public Fields
60
61
62 #region Properties
63
64 public static Vector4 Zero
65 {
66 get { return zeroVector; }
67 }
68
69 public static Vector4 One
70 {
71 get { return unitVector; }
72 }
73
74 public static Vector4 UnitX
75 {
76 get { return unitXVector; }
77 }
78
79 public static Vector4 UnitY
80 {
81 get { return unitYVector; }
82 }
83
84 public static Vector4 UnitZ
85 {
86 get { return unitZVector; }
87 }
88
89 public static Vector4 UnitW
90 {
91 get { return unitWVector; }
92 }
93
94 #endregion Properties
95
96
97 #region Constructors
98
99 public Vector4(float x, float y, float z, float w)
100 {
101 this.X = x;
102 this.Y = y;
103 this.Z = z;
104 this.W = w;
105 }
106
107 /*public Vector4(Vector2 value, float z, float w)
108 {
109 this.X = value.X;
110 this.Y = value.Y;
111 this.Z = z;
112 this.W = w;
113 }*/
114
115 public Vector4(Vector3 value, float w)
116 {
117 this.X = value.X;
118 this.Y = value.Y;
119 this.Z = value.Z;
120 this.W = w;
121 }
122
123 public Vector4(float value)
124 {
125 this.X = value;
126 this.Y = value;
127 this.Z = value;
128 this.W = value;
129 }
130
131 #endregion
132
133
134 #region Public Methods
135
136 public static Vector4 Add(Vector4 value1, Vector4 value2)
137 {
138 value1.W += value2.W;
139 value1.X += value2.X;
140 value1.Y += value2.Y;
141 value1.Z += value2.Z;
142 return value1;
143 }
144
145 public static void Add(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
146 {
147 result.W = value1.W + value2.W;
148 result.X = value1.X + value2.X;
149 result.Y = value1.Y + value2.Y;
150 result.Z = value1.Z + value2.Z;
151 }
152
153 /*public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2)
154 {
155 return new Vector4(
156 MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
157 MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
158 MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2),
159 MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2));
160 }*/
161
162 /*public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result)
163 {
164 result = new Vector4(
165 MathHelper.Barycentric(value1.X, value2.X, value3.X, amount1, amount2),
166 MathHelper.Barycentric(value1.Y, value2.Y, value3.Y, amount1, amount2),
167 MathHelper.Barycentric(value1.Z, value2.Z, value3.Z, amount1, amount2),
168 MathHelper.Barycentric(value1.W, value2.W, value3.W, amount1, amount2));
169 }*/
170
171 /*public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
172 {
173 return new Vector4(
174 MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, 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),
177 MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount));
178 }*/
179
180 /*public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result)
181 {
182 result = new Vector4(
183 MathHelper.CatmullRom(value1.X, value2.X, value3.X, value4.X, 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),
186 MathHelper.CatmullRom(value1.W, value2.W, value3.W, value4.W, amount));
187 }*/
188
189 /*public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max)
190 {
191 return new Vector4(
192 MathHelper.Clamp(value1.X, min.X, max.X),
193 MathHelper.Clamp(value1.Y, min.Y, max.Y),
194 MathHelper.Clamp(value1.Z, min.Z, max.Z),
195 MathHelper.Clamp(value1.W, min.W, max.W));
196 }*/
197
198 /*public static void Clamp(ref Vector4 value1, ref Vector4 min, ref Vector4 max, out Vector4 result)
199 {
200 result = new Vector4(
201 MathHelper.Clamp(value1.X, min.X, max.X),
202 MathHelper.Clamp(value1.Y, min.Y, max.Y),
203 MathHelper.Clamp(value1.Z, min.Z, max.Z),
204 MathHelper.Clamp(value1.W, min.W, max.W));
205 }*/
206
207 public static float Distance(Vector4 value1, Vector4 value2)
208 {
209 return (float)Math.Sqrt(DistanceSquared(value1, value2));
210 }
211
212 public static void Distance(ref Vector4 value1, ref Vector4 value2, out float result)
213 {
214 result = (float)Math.Sqrt(DistanceSquared(value1, value2));
215 }
216
217 public static float DistanceSquared(Vector4 value1, Vector4 value2)
218 {
219 float result;
220 DistanceSquared(ref value1, ref value2, out result);
221 return result;
222 }
223
224 public static void DistanceSquared(ref Vector4 value1, ref Vector4 value2, out float result)
225 {
226 result = (value1.W - value2.W) * (value1.W - value2.W) +
227 (value1.X - value2.X) * (value1.X - value2.X) +
228 (value1.Y - value2.Y) * (value1.Y - value2.Y) +
229 (value1.Z - value2.Z) * (value1.Z - value2.Z);
230 }
231
232 public static Vector4 Divide(Vector4 value1, Vector4 value2)
233 {
234 value1.W /= value2.W;
235 value1.X /= value2.X;
236 value1.Y /= value2.Y;
237 value1.Z /= value2.Z;
238 return value1;
239 }
240
241 public static Vector4 Divide(Vector4 value1, float divider)
242 {
243 float factor = 1f / divider;
244 value1.W *= factor;
245 value1.X *= factor;
246 value1.Y *= factor;
247 value1.Z *= factor;
248 return value1;
249 }
250
251 public static void Divide(ref Vector4 value1, float divider, out Vector4 result)
252 {
253 float factor = 1f / divider;
254 result.W = value1.W * factor;
255 result.X = value1.X * factor;
256 result.Y = value1.Y * factor;
257 result.Z = value1.Z * factor;
258 }
259
260 public static void Divide(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
261 {
262 result.W = value1.W / value2.W;
263 result.X = value1.X / value2.X;
264 result.Y = value1.Y / value2.Y;
265 result.Z = value1.Z / value2.Z;
266 }
267
268 public static float Dot(Vector4 vector1, Vector4 vector2)
269 {
270 return vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W;
271 }
272
273 public static void Dot(ref Vector4 vector1, ref Vector4 vector2, out float result)
274 {
275 result = vector1.X * vector2.X + vector1.Y * vector2.Y + vector1.Z * vector2.Z + vector1.W * vector2.W;
276 }
277
278 public override bool Equals(object obj)
279 {
280 return (obj is Vector4) ? this == (Vector4)obj : false;
281 }
282
283 public bool Equals(Vector4 other)
284 {
285 return this.W == other.W
286 && this.X == other.X
287 && this.Y == other.Y
288 && this.Z == other.Z;
289 }
290
291 public override int GetHashCode()
292 {
293 return (int)(this.W + this.X + this.Y + this.Y);
294 }
295
296 /*public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
297 {
298 Vector4 result = new Vector4();
299 Hermite(ref value1, ref tangent1, ref value2, ref tangent2, amount, out result);
300 return result;
301 }*/
302
303 /*public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result)
304 {
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);
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);
309 }*/
310
311 public float Length()
312 {
313 float result;
314 DistanceSquared(ref this, ref zeroVector, out result);
315 return (float)Math.Sqrt(result);
316 }
317
318 public float LengthSquared()
319 {
320 float result;
321 DistanceSquared(ref this, ref zeroVector, out result);
322 return result;
323 }
324
325 /*public static Vector4 Lerp(Vector4 value1, Vector4 value2, float amount)
326 {
327 return new Vector4(
328 MathHelper.Lerp(value1.X, value2.X, amount),
329 MathHelper.Lerp(value1.Y, value2.Y, amount),
330 MathHelper.Lerp(value1.Z, value2.Z, amount),
331 MathHelper.Lerp(value1.W, value2.W, amount));
332 }*/
333
334 /*public static void Lerp(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result)
335 {
336 result = new Vector4(
337 MathHelper.Lerp(value1.X, value2.X, amount),
338 MathHelper.Lerp(value1.Y, value2.Y, amount),
339 MathHelper.Lerp(value1.Z, value2.Z, amount),
340 MathHelper.Lerp(value1.W, value2.W, amount));
341 }*/
342
343 /*public static Vector4 Max(Vector4 value1, Vector4 value2)
344 {
345 return new Vector4(
346 MathHelper.Max(value1.X, value2.X),
347 MathHelper.Max(value1.Y, value2.Y),
348 MathHelper.Max(value1.Z, value2.Z),
349 MathHelper.Max(value1.W, value2.W));
350 }*/
351
352 /*public static void Max(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
353 {
354 result = new Vector4(
355 MathHelper.Max(value1.X, value2.X),
356 MathHelper.Max(value1.Y, value2.Y),
357 MathHelper.Max(value1.Z, value2.Z),
358 MathHelper.Max(value1.W, value2.W));
359 }*/
360
361 /*public static Vector4 Min(Vector4 value1, Vector4 value2)
362 {
363 return new Vector4(
364 MathHelper.Min(value1.X, value2.X),
365 MathHelper.Min(value1.Y, value2.Y),
366 MathHelper.Min(value1.Z, value2.Z),
367 MathHelper.Min(value1.W, value2.W));
368 }*/
369
370 /*public static void Min(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
371 {
372 result = new Vector4(
373 MathHelper.Min(value1.X, value2.X),
374 MathHelper.Min(value1.Y, value2.Y),
375 MathHelper.Min(value1.Z, value2.Z),
376 MathHelper.Min(value1.W, value2.W));
377 }*/
378
379 public static Vector4 Multiply(Vector4 value1, Vector4 value2)
380 {
381 value1.W *= value2.W;
382 value1.X *= value2.X;
383 value1.Y *= value2.Y;
384 value1.Z *= value2.Z;
385 return value1;
386 }
387
388 public static Vector4 Multiply(Vector4 value1, float scaleFactor)
389 {
390 value1.W *= scaleFactor;
391 value1.X *= scaleFactor;
392 value1.Y *= scaleFactor;
393 value1.Z *= scaleFactor;
394 return value1;
395 }
396
397 public static void Multiply(ref Vector4 value1, float scaleFactor, out Vector4 result)
398 {
399 result.W = value1.W * scaleFactor;
400 result.X = value1.X * scaleFactor;
401 result.Y = value1.Y * scaleFactor;
402 result.Z = value1.Z * scaleFactor;
403 }
404
405 public static void Multiply(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
406 {
407 result.W = value1.W * value2.W;
408 result.X = value1.X * value2.X;
409 result.Y = value1.Y * value2.Y;
410 result.Z = value1.Z * value2.Z;
411 }
412
413 public static Vector4 Negate(Vector4 value)
414 {
415 value = new Vector4(-value.X, -value.Y, -value.Z, -value.W);
416 return value;
417 }
418
419 public static void Negate(ref Vector4 value, out Vector4 result)
420 {
421 result = new Vector4(-value.X, -value.Y, -value.Z,-value.W);
422 }
423
424 public void Normalize()
425 {
426 Normalize(ref this, out this);
427 }
428
429 public static Vector4 Normalize(Vector4 vector)
430 {
431 Normalize(ref vector, out vector);
432 return vector;
433 }
434
435 public static void Normalize(ref Vector4 vector, out Vector4 result)
436 {
437 float factor;
438 DistanceSquared(ref vector, ref zeroVector, out factor);
439 factor = 1f / (float)Math.Sqrt(factor);
440
441 result.W = vector.W * factor;
442 result.X = vector.X * factor;
443 result.Y = vector.Y * factor;
444 result.Z = vector.Z * factor;
445 }
446
447 /*public static Vector4 SmoothStep(Vector4 value1, Vector4 value2, float amount)
448 {
449 return new Vector4(
450 MathHelper.SmoothStep(value1.X, value2.X, amount),
451 MathHelper.SmoothStep(value1.Y, value2.Y, amount),
452 MathHelper.SmoothStep(value1.Z, value2.Z, amount),
453 MathHelper.SmoothStep(value1.W, value2.W, amount));
454 }*/
455
456 /*public static void SmoothStep(ref Vector4 value1, ref Vector4 value2, float amount, out Vector4 result)
457 {
458 result = new Vector4(
459 MathHelper.SmoothStep(value1.X, value2.X, amount),
460 MathHelper.SmoothStep(value1.Y, value2.Y, amount),
461 MathHelper.SmoothStep(value1.Z, value2.Z, amount),
462 MathHelper.SmoothStep(value1.W, value2.W, amount));
463 }*/
464
465 public static Vector4 Subtract(Vector4 value1, Vector4 value2)
466 {
467 value1.W -= value2.W;
468 value1.X -= value2.X;
469 value1.Y -= value2.Y;
470 value1.Z -= value2.Z;
471 return value1;
472 }
473
474 public static void Subtract(ref Vector4 value1, ref Vector4 value2, out Vector4 result)
475 {
476 result.W = value1.W - value2.W;
477 result.X = value1.X - value2.X;
478 result.Y = value1.Y - value2.Y;
479 result.Z = value1.Z - value2.Z;
480 }
481
482 /*public static Vector4 Transform(Vector2 position, Matrix matrix)
483 {
484 Vector4 result;
485 Transform(ref position, ref matrix, out result);
486 return result;
487 }*/
488
489 public static Vector4 Transform(Vector3 position, Matrix matrix)
490 {
491 Vector4 result;
492 Transform(ref position, ref matrix, out result);
493 return result;
494 }
495
496 public static Vector4 Transform(Vector4 vector, Matrix matrix)
497 {
498 Transform(ref vector, ref matrix, out vector);
499 return vector;
500 }
501
502 /*public static void Transform(ref Vector2 position, ref Matrix matrix, out Vector4 result)
503 {
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,
506 (position.X * matrix.M13) + (position.Y * matrix.M23) + matrix.M43,
507 (position.X * matrix.M14) + (position.Y * matrix.M24) + matrix.M44);
508 }*/
509
510 public static void Transform(ref Vector3 position, ref Matrix matrix, out Vector4 result)
511 {
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,
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);
516 }
517
518 public static void Transform(ref Vector4 vector, ref Matrix matrix, out Vector4 result)
519 {
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),
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));
524 }
525
526 public override string ToString()
527 {
528 StringBuilder sb = new StringBuilder(32);
529 sb.Append("{X:");
530 sb.Append(this.X);
531 sb.Append(" Y:");
532 sb.Append(this.Y);
533 sb.Append(" Z:");
534 sb.Append(this.Z);
535 sb.Append(" W:");
536 sb.Append(this.W);
537 sb.Append("}");
538 return sb.ToString();
539 }
540
541 #endregion Public Methods
542
543
544 #region Operators
545
546 public static Vector4 operator -(Vector4 value)
547 {
548 return new Vector4(-value.X, -value.Y, -value.Z, -value.W);
549 }
550
551 public static bool operator ==(Vector4 value1, Vector4 value2)
552 {
553 return value1.W == value2.W
554 && value1.X == value2.X
555 && value1.Y == value2.Y
556 && value1.Z == value2.Z;
557 }
558
559 public static bool operator !=(Vector4 value1, Vector4 value2)
560 {
561 return !(value1 == value2);
562 }
563
564 public static Vector4 operator +(Vector4 value1, Vector4 value2)
565 {
566 value1.W += value2.W;
567 value1.X += value2.X;
568 value1.Y += value2.Y;
569 value1.Z += value2.Z;
570 return value1;
571 }
572
573 public static Vector4 operator -(Vector4 value1, Vector4 value2)
574 {
575 value1.W -= value2.W;
576 value1.X -= value2.X;
577 value1.Y -= value2.Y;
578 value1.Z -= value2.Z;
579 return value1;
580 }
581
582 public static Vector4 operator *(Vector4 value1, Vector4 value2)
583 {
584 value1.W *= value2.W;
585 value1.X *= value2.X;
586 value1.Y *= value2.Y;
587 value1.Z *= value2.Z;
588 return value1;
589 }
590
591 public static Vector4 operator *(Vector4 value1, float scaleFactor)
592 {
593 value1.W *= scaleFactor;
594 value1.X *= scaleFactor;
595 value1.Y *= scaleFactor;
596 value1.Z *= scaleFactor;
597 return value1;
598 }
599
600 public static Vector4 operator *(float scaleFactor, Vector4 value1)
601 {
602 value1.W *= scaleFactor;
603 value1.X *= scaleFactor;
604 value1.Y *= scaleFactor;
605 value1.Z *= scaleFactor;
606 return value1;
607 }
608
609 public static Vector4 operator /(Vector4 value1, Vector4 value2)
610 {
611 value1.W /= value2.W;
612 value1.X /= value2.X;
613 value1.Y /= value2.Y;
614 value1.Z /= value2.Z;
615 return value1;
616 }
617
618 public static Vector4 operator /(Vector4 value1, float divider)
619 {
620 float factor = 1f / divider;
621 value1.W *= factor;
622 value1.X *= factor;
623 value1.Y *= factor;
624 value1.Z *= factor;
625 return value1;
626 }
627
628 #endregion Operators
629 }
630}