// CIRCLE with R=1 public static Vector2 Circle( ref NPack.MersenneTwister _rand ) { float t = (float) _rand.Next(); float _2pi = (float) Math.PI * 2; float a = SpecialFunctions.ScaleFloatToRange(t, 0, _2pi, 0, Int32.MaxValue); return new Vector2( (float) Math.Cos(a) , (float) Math.Sin(a)); }
// INIT private void init(int size, DiceType type, ref NPack.MersenneTwister _rand) { _result = new int[size]; _dice_type = type; _size = size; for (int i = 0; i < _size; i++) { // Cast enum to int to get the value _result[i] = _rand.Next( 1, (int) type); } }
public static Vector3 Surface(ref NPack.MersenneTwister _rand, UnityRandom.Normalization n, float t) { Vector3 pos = new Vector3(); switch (n) { case UnityRandom.Normalization.STDNORMAL: pos = GetPointOnCubeSurface( (float) NormalDistribution.Normalize(_rand.NextSingle(true), t), (float) NormalDistribution.Normalize(_rand.NextSingle(true), t), _rand.Next(5)); break; case UnityRandom.Normalization.POWERLAW: pos = GetPointOnCubeSurface( (float) PowerLaw.Normalize(_rand.NextSingle(true), t, 0, 1), (float) PowerLaw.Normalize(_rand.NextSingle(true), t, 0, 1), _rand.Next(5)); break; default: pos = GetPointOnCubeSurface(_rand.NextSingle(true),_rand.NextSingle(true),_rand.Next(5)); break; } // Move to -1, 1 space as for CIRCLE and SPHERE return new Vector3((2*pos.x)-1, (2*pos.y)-1, (2*pos.z)-1); }
public static Vector2 Circle( ref NPack.MersenneTwister _rand, UnityRandom.Normalization n, float t ) { float r; switch (n) { case UnityRandom.Normalization.STDNORMAL: r = SpecialFunctions.ScaleFloatToRange( (float) NormalDistribution.Normalize(_rand.NextSingle(true), t), 0, Int32.MaxValue, 0, 1); break; case UnityRandom.Normalization.POWERLAW: r = (float) PowerLaw.Normalize(_rand.NextSingle(true), t, 0, Int32.MaxValue); break; default: r = (float) _rand.Next(); break; } float _2pi = (float) Math.PI * 2; float a = SpecialFunctions.ScaleFloatToRange(r, 0, _2pi, 0, Int32.MaxValue); return new Vector2( (float) Math.Cos(a) , (float) Math.Sin(a)); }
public static Vector3 Surface(ref NPack.MersenneTwister _rand) { // Move to -1, 1 space as for CIRCLE and SPHERE Vector3 pos = GetPointOnCubeSurface(_rand.NextSingle(true),_rand.NextSingle(true),_rand.Next(5)); return new Vector3((2*pos.x)-1, (2*pos.y)-1, (2*pos.z)-1); }