using System.Numerics; using Silk.NET.Maths; namespace Nebulix { public static class ArrayExtensions { /// /// Copies the given arrays to the start of this array. The order of is preserved /// /// The arrays copied into this array public static void CopyFrom(this Array array, params Array[] arrays) { int lastIndex = 0; for (int i = 0; i < arrays.Length; i++) { arrays[i].CopyTo(array, lastIndex); lastIndex += arrays[i].Length; } } public static T[] ExtractComponents(this Vector3D[] array) where T : unmanaged, IFormattable, IEquatable, IComparable { T[] result = new T[array.Length * 3]; // * 3 cause a Vector3D has 3 components int resultIdx = 0; for (int i = 0; i < array.Length; i++) { result[resultIdx] = array[i].X; result[resultIdx + 1] = array[i].Y; result[resultIdx + 2] = array[i].Z; } return result; } } }