public static double NextDouble() { lock (InnerOne) { return(InnerOne.NextDouble()); } }
public static Coord OnUnitShape(this Radius r, double distance, IRNG rng) { if (rng is null) { throw new ArgumentNullException($"rng"); } int x = 0, y = 0; switch (r) { case SquidGrid.Radius.Square: case SquidGrid.Radius.Cube: x = rng.NextInt((int)-distance, (int)distance + 1); y = rng.NextInt((int)-distance, (int)distance + 1); break; case SquidGrid.Radius.Diamond: case SquidGrid.Radius.Octahedron: x = rng.NextInt((int)-distance, (int)distance + 1); y = rng.NextInt((int)-distance, (int)distance + 1); if (Radius(r, x, y) > distance) { if (x > 0) { if (y > 0) { x = (int)(distance - x); y = (int)(distance - y); } else { x = (int)(distance - x); y = (int)(-distance - y); } } else { if (y > 0) { x = (int)(-distance - x); y = (int)(distance - y); } else { x = (int)(-distance - x); y = (int)(-distance - y); } } } break; default: // includes CIRCLE, SPHERE, and ROUGH_CIRCLE double result = distance * Math.Sqrt(rng.NextDouble()); double theta = rng.NextDouble(0, pi2); x = Convert.ToInt32(Math.Cos(theta) * result); y = Convert.ToInt32(Math.Sin(theta) * result); break; } return(Coord.Get(x, y)); }