Utility functions which convert between VectorN (double) and XNAs Vector2/Vector3(float) formats. More...
Static Public Member Functions | |
| static Vector2[] | VectorNToVector2 (VectorN[] vectors) |
| Convert an array of 2-dimensional VectorN's to Vector2[]. | |
| static Vector3[] | VectorNToVector3 (VectorN[] vectors) |
| Convert an array of 3-dimensional VectorN's to Vector3[]. | |
Utility functions which convert between VectorN (double) and XNAs Vector2/Vector3(float) formats.
Definition at line 17 of file VectorFormatConverter.cs.
| static Vector2 [] NewGamePhysics.Utilities.VectorFormatConverter.VectorNToVector2 | ( | VectorN[] | vectors | ) | [static] |
Convert an array of 2-dimensional VectorN's to Vector2[].
| vectors | Input vectors. |
Definition at line 24 of file VectorFormatConverter.cs.
00025 { 00026 if (null == vectors) 00027 { 00028 throw new ArgumentNullException("vectors"); 00029 } 00030 00031 int size = vectors.Length; 00032 00033 if (size == 0) 00034 { 00035 throw new ArgumentOutOfRangeException( 00036 "vectors", 00037 "Input array must contain 1 or more elements"); 00038 } 00039 00040 Vector2[] result = new Vector2[size]; 00041 for (int i = 0; i < size; i++) 00042 { 00043 if (vectors[i].N != 2) 00044 { 00045 throw new ArgumentException( 00046 "All input vectors must be 2 dimensional.", 00047 "vectors"); 00048 } 00049 00050 result[i].X = Convert.ToSingle(vectors[i][0]); 00051 result[i].Y = Convert.ToSingle(vectors[i][1]); 00052 } 00053 00054 return result; 00055 }
| static Vector3 [] NewGamePhysics.Utilities.VectorFormatConverter.VectorNToVector3 | ( | VectorN[] | vectors | ) | [static] |
Convert an array of 3-dimensional VectorN's to Vector3[].
| vectors | Input vectors. |
Definition at line 62 of file VectorFormatConverter.cs.
00063 { 00064 if (null == vectors) 00065 { 00066 throw new ArgumentNullException("vectors"); 00067 } 00068 00069 int size = vectors.Length; 00070 00071 if (size == 0) 00072 { 00073 throw new ArgumentOutOfRangeException( 00074 "vectors", 00075 "Input array must contain 1 or more elements"); 00076 } 00077 00078 Vector3[] result = new Vector3[size]; 00079 for (int i = 0; i < size; i++) 00080 { 00081 if (vectors[i].N != 3) 00082 { 00083 throw new ArgumentException( 00084 "All input vectors must be 3 dimensional.", 00085 "vectors"); 00086 } 00087 00088 result[i].X = Convert.ToSingle(vectors[i][0]); 00089 result[i].Y = Convert.ToSingle(vectors[i][1]); 00090 result[i].Z = Convert.ToSingle(vectors[i][2]); 00091 } 00092 00093 return result; 00094 }
1.6.2