public void SumTestV() { var list = new VSArray <Vector3>(); list.Add(new Vector3(0, 0, 0)); list.Add(new Vector3(1, 2, 3)); list.Add(new Vector3(2, 4, 6)); list.Add(new Vector3(3, 6, 9)); list.Add(new Vector3(4, 8, 12)); var value = list.Sum(); Assert.That(value, Is.EqualTo(new Vector3(10, 20, 30))); }
public static VSArray <float> MakeFibonacci(int elementCount) { if (elementCount < 2) { throw new ArgumentException("Element Count must be greater or equal to 2.", nameof(elementCount)); } var fibonacci = new VSArray <float>(elementCount); fibonacci.Add(1); fibonacci.Add(1); for (var i = 2; i < elementCount; i++) { fibonacci.Add(fibonacci[i - 1] + fibonacci[i - 2]); } return(fibonacci); }
public static VSArray <Vector3> MakeNormalized(VSArray <Vector3> array) { var newArray = new VSArray <Vector3>(array.Count); foreach (var element in array) { newArray.Add(element.normalized); } return(newArray); }
public static VSArray <int> MakeStep(int elementCount, int minValue = 0, int step = 1) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } var array = new VSArray <int>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(minValue); minValue += step; } return(array); }
public static VSArray <Quaternion> MakeRandomQuaternion(int elementCount, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } Random.InitState(seed); var array = new VSArray <Quaternion>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(Random.rotationUniform); } return(array); }
public static VSArray <int> MakeRandomInteger(int elementCount, int minRange = 0, int maxRange = 1, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } Random.InitState(seed); var array = new VSArray <int>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(Random.Range(minRange, maxRange)); } return(array); }
public static VSArray <Vector3> MakeRandomVector(int elementCount, Vector3 minRange, Vector3 maxRange, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } Random.InitState(seed); var array = new VSArray <Vector3>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add( new Vector3( Random.Range(minRange.x, maxRange.x), Random.Range(minRange.y, maxRange.y), Random.Range(minRange.z, maxRange.z))); } return(array); }
public static VSArray <bool> MakeRandomBoolean(int elementCount, float probability = 0.5f, int seed = k_DefaultSeed) { if (elementCount < 1) { throw new ArgumentException("Element Count must be greater or equal to 1.", nameof(elementCount)); } if (probability < 0 || probability > 1) { throw new ArgumentException("Probability must be in the range [0,1].", nameof(probability)); } Random.InitState(seed); var array = new VSArray <bool>(elementCount); for (var i = 0; i < elementCount; i++) { array.Add(Random.Range(0.0f, 1.0f) < probability); } return(array); }