I would like to be able to generate a cluster of points in 3D space that would create a majority of the points within a specified sphere radius (in this case, 4) from the starting point (in this case, 0,0,0). I'd also like it to generate the occasional outlier too.
It would be similar to this:
But I'd like to be able to tweak some of the settings. I will be generating this in C# and I'm familiar with the Random class, and have some familiarity with spheres. I'm not sure how I can piece it all together.
I have this which can generate a point in a sphere, but I want it to cluster around that center point:
// elsewhere in code
private static readonly Random Random = new Random();
private static double NextDouble(double minValue, double maxValue)
{
double next = Random.NextDouble();
return minValue + (next * (maxValue - minValue));
}
// generates random points in sphere
const int r = 6;
double x;
double y;
double z;
do
{
x = NextDouble(-r, 1 + r);
y = NextDouble(-r, 1 + r);
z = NextDouble(-r, 1 + r);
} while (Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2) > Math.Pow(r, 2));