public static Vector2 Sign(this Vector2 v) { Vector3 t = Vector3.zero; t.x = Mathnv.Sign(v.x); t.y = Mathnv.Sign(v.y); return(t); }
// rolling min or max will be rare, but rolling exactly between the two will be common public double GaussianRandom(double min, double max) { if (min > max) { Mathnv.Swap <double>(ref min, ref max); } min /= 3; max /= 3; return(Rand(min, max) + Rand(min, max) + Rand(min, max));; }
// random normalized vector //from [ [min.x,min.y] , [max.x,max.y] ] public Vector3 RandVec3Normalized(float min, float max) { if (min > max) { Mathnv.Swap(ref min, ref max); } Vector3 vec = new Vector3(Rand(min, max), Rand(min, max), Rand(min, max)).normalized; vec.Normalize(); return(vec); }
public double Rand(double a, double b) { if (a > b) { Mathnv.Swap(ref a, ref b); } double c = b - a; return(a + Randd() * c); }
public float Rand(float a, float b) { if (a > b) { Mathnv.Swap(ref a, ref b); } float c = b - a; return(a + Randf() * c); }
public int Rand(int a, int b) { if (a > b) { Mathnv.Swap(ref a, ref b); } int c = b - a; return(a + Randi() % c); }
//random point in an area public Vector2 Rand(Vector2 a, Vector2 b) { if (a.x > b.x) { Mathnv.Swap(ref a.x, ref b.x); } if (a.y > b.y) { Mathnv.Swap(ref a.y, ref b.y); } float cx = b.x - a.x; float cy = b.y - a.y; return(new Vector2(a.x + Randf() * cx, a.y + Randf() * cy)); }
public uint Rand(uint a, uint b) { if (a == 0) { return(Rand(b)); } if (a > b) { Mathnv.Swap(ref a, ref b); } uint n = 2 * b; uint m = a + b; uint c = n % m; return(a + Rand() % c); }
public static void Clamp(this Rect area, Rect min_max) { Mathnv.Clamp(ref area, min_max); }
public static void Clamp(this Rect area, Vector2 pos, Vector2 extents) { Mathnv.Clamp(ref area, pos, extents); }