Answers for "What's the easiest way to see if a sphere intersects with another using insideUnitSphere"
http://answers.unity.com/questions/1603582/whats-the-easiest-way-to-see-if-a-sphere-intersect.html
The latest answers for the question "What's the easiest way to see if a sphere intersects with another using insideUnitSphere"Answer by Bunny83
http://answers.unity.com/answers/1603598/view.html
From your code and your image it's not clear what radius your "clusters" have. Your method is called "GetCircleRadius" but it doesn't seem to return any radius. Actually the method doesn't make much sense to me. You add a random vector to the center and then you scale the result by maxDistance. This doesn't make much sense. Maybe you wanted to do something like this:
public Vector3 GetPointInSphere(Vector3 center, float sphereRadius)
{
return center + Random.insideUnitSphere * sphereRadius;
}
It's still not clear what you want to check. This method will produce positions which are inside the sphere defined by the center and the sphereRadius. A single position doesn't have any size and therefore can't overlap with another position. Maybe your positions have some sort of size?
<br>
Or was the question how to ensure that your coosen center / radius does not overlap with another center / radius? In this case you should first clear up if this is a 2d or a 3d issue. So do we talk about circles or spheres? Currently your code does represent a sphere (3d).
<br>
If this is about 2d circles (like your drawing) you shouldn't use "Random.insideUnitSphere". If you flatten / project the vector you get from insideUnitSphere down to 2d the distribution would be biased. You get a higher density near the center than the perimeter. You should use [Random.insideUnitCircle][1] for 2d.
<br>
To test if two circles or spheres overlap you just have to calculate the distance between the center points of those circles / spheres and compare it to the sum of their radii. If the distance between the centers is smaller than the sum, they overlap, otherwise they don't.
<br>
It's still not fully clear what you want to do. You should be more clear about what you actually want to do. Also if this is 2d or 3d.
[1]: https://docs.unity3d.com/ScriptReference/Random-insideUnitCircle.htmlTue, 19 Feb 2019 11:38:03 GMTBunny83