private void NormalizationNumberTypes() { EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Tranformation Type:"); normalization = (UnityRandom.Normalization)EditorGUILayout.EnumPopup(normalization, GUILayout.Width(100.0f)); EditorGUILayout.EndHorizontal(); switch (normalization) { case UnityRandom.Normalization.STDNORMAL: temperature = EditorGUILayout.Slider("Temperature", temperature, 0.0f, 10.0f); break; case UnityRandom.Normalization.POWERLAW: temperature = EditorGUILayout.Slider("Power", temperature, 0.0f, 100.0f); break; default: Debug.LogError("Unrecognized Option"); break; } EditorGUILayout.EndVertical(); }
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 Vector3 Volume(ref NPack.MersenneTwister _rand, UnityRandom.Normalization n, float t) { float x, y, z; x = y = z = 0; switch (n) { case UnityRandom.Normalization.STDNORMAL: x = (float)NormalDistribution.Normalize(_rand.NextSingle(true), t); y = (float)NormalDistribution.Normalize(_rand.NextSingle(true), t); z = (float)NormalDistribution.Normalize(_rand.NextSingle(true), t); break; case UnityRandom.Normalization.POWERLAW: x = (float)PowerLaw.Normalize(_rand.NextSingle(true), t, 0, 1); y = (float)PowerLaw.Normalize(_rand.NextSingle(true), t, 0, 1); z = (float)PowerLaw.Normalize(_rand.NextSingle(true), t, 0, 1); break; default: x = _rand.NextSingle(true); y = _rand.NextSingle(true); z = _rand.NextSingle(true); break; } // Move to -1, 1 space as for CIRCLE and SPHERE return(new Vector3((2 * x) - 1, (2 * y) - 1, (2 * z) - 1)); }
/// <summary> /// min < x < max /// </summary> public static float Range(int minValue, int maxValue, UnityRandom.Normalization n, float t) { if (minValue == maxValue) { return(minValue); } if (minValue > maxValue) { var temp = minValue; minValue = maxValue; maxValue = temp; } maxValue--; if (minValue == maxValue) { return(minValue); } return(Urand.Range(minValue, maxValue, n, t)); }
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 Vector2 Disk(ref NPack.MersenneTwister _rand, UnityRandom.Normalization n, float temp) { double t, theta; switch (n) { case UnityRandom.Normalization.STDNORMAL: t = NormalDistribution.Normalize(_rand.NextSingle(true), temp); theta = NormalDistribution.Normalize(_rand.NextSingle(true), temp) * 2 * Math.PI; break; case UnityRandom.Normalization.POWERLAW: t = PowerLaw.Normalize(_rand.NextSingle(true), temp, 0, 1); theta = PowerLaw.Normalize(_rand.NextSingle(true), temp, 0, 1) * 2 * Math.PI; break; default: t = (float)_rand.NextSingle(true); theta = _rand.NextSingle(false) * 2 * Math.PI; break; } return(new Vector2((float)(Math.Sqrt(t) * Math.Cos(theta)), (float)(Math.Sqrt(t) * Math.Sin(theta)))); }
// RANDOM POINT IN A CIRCLE centered at 0 // FROM http://mathworld.wolfram.com/CirclePointPicking.html // Take a number between 0 and 2PI and move to Cartesian Coordinates public Vector2 PointInACircle(Normalization n, float t) => URAND.PointInACircle(n, t);
private void NormalizationNumberTypes() { EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Tranformation Type:"); normalization = (UnityRandom.Normalization) EditorGUILayout.EnumPopup( normalization, GUILayout.Width(100.0f)); EditorGUILayout.EndHorizontal(); switch (normalization) { case UnityRandom.Normalization.STDNORMAL: temperature = EditorGUILayout.Slider ("Temperature", temperature, 0.0f, 10.0f); break; case UnityRandom.Normalization.POWERLAW: temperature = EditorGUILayout.Slider ("Power", temperature, 0.0f, 100.0f); break; default: Debug.LogError("Unrecognized Option"); break; } EditorGUILayout.EndVertical(); }
/// <summary> /// R = 1 のディスクの中のランダムな点を返す /// </summary> public static Vector2 PointInADisk(UnityRandom.Normalization n, float t) { return(Urand.PointInADisk(n, t)); }
public Vector3 PointOnRing(float innerAngle, float outerAngle, Normalization n, float t) => URAND.PointOnRing(innerAngle, outerAngle, n, t);
/// <summary> /// R = 1 の球体の中のランダムな点を返す /// </summary> public static Vector3 PointInASphere(UnityRandom.Normalization n, float t) { return(Urand.PointInASphere(n, t)); }
// RANDOM POINT IN A SPHERE. Return a Vector3 public Vector3 PointInASphere(Normalization n, float t) => URAND.PointInASphere(n, t);
public Vector3 PointOnCap(float spotAngle, Normalization n, float t) => URAND.PointOnCap(spotAngle, n, t);
/// <summary> /// 指定された角度のコーンの表面のランダムな点を返す(多分) /// </summary> public static Vector3 PointOnCone(float spotAngle, UnityRandom.Normalization n, float t) { return(Urand.PointOnCap(spotAngle, n, t)); }
// RANDOM POINT ON A CUBE. Return a Vector3 public Vector3 PointOnACube(Normalization n, float t) => URAND.PointOnACube(n, t);
/// <summary> /// 扇の表面のランダムな点を返す(多分) /// </summary> public static Vector3 PointOnRing(float innerAngle, float outerAngle, UnityRandom.Normalization n, float t) { return(Urand.PointOnRing(innerAngle, outerAngle, n, t)); }
// POINT IN A SQUARE Return a Vector2 public static Vector2 PointInASquare(Normalization n, float t) => URAND.PointInASquare(n, t);
// VALUE Return a Float 0 - 1 public static float Value(Normalization n, float t) => URAND.Value(n, t);
// RANDOM RAINBOW COLOR public Color Rainbow(Normalization n, float t) => URAND.Rainbow(n, t);
/// <summary> /// ランダムな色を返す /// </summary> public static Color Rainbow(UnityRandom.Normalization n, float t) { return(Urand.Rainbow(n, t)); }
// RANDOM POINT in a DISK // FROM http://mathworld.wolfram.com/DiskPointPicking.html public Vector2 PointInADisk(Normalization n, float t) => URAND.PointInADisk(n, t);
/// <summary> /// 0 - 1 /// </summary> public static float Value(UnityRandom.Normalization n, float t) { return(Urand.Value(n, t)); }