# How many circles of radius r1 at the border of a cyrcle with radius r2?

This topic is 712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Or a better question would be, how do I distribute circles around another cyrcle?

I have top view towers of varying size, and a smoke animation fx of fixed syze, when the towers are destroyed I want to spawn the smoke animations in a way that covers all the tower border.

I dont know how much I have to rotate the next smoke fx so that its justing touching the previous..whats the relation between radius, angle and distance from the rotation pivot?

Edited by Icebone1000

##### Share on other sites
If "approximate" is good enough, which is likely the case with a smoke sprite (as it's fluffy with unsharp borders), just divide the circumference (2*pi*r2) by the smaller circle's diameter (2*r1). This is not terribly "correct" if the radii are quite similar, but if r2 &gt;&gt; r1, nobody will notice. Besides, you can't add half a sprite anyway...

If you want it precise, you must use the chord length instead, which is much more complicated to calculate, involving inverse trig functions. The half cord length divided by the radius is the sine, so there you can get the (half) angle via arcsin, and divide 2pi by that. But... to what avail, you can still only have a discrete number.

Be sure you really need a precise solution first.

##### Share on other sites

Im dividing by the smoke radius instead of diameter, using diameter it leaves a gap.

To compute the pos between each smoke I made a proportion with the radius of the tower and 180 degrees, not sure if this is entirely correct, but it works.

The logic is, if in 180 degrees the "distance" displaced is 2*r, then how many angle rot is for the smoke radius:

void SpawnTowerDestructionFx(CircleCollider2D coll)
{
float circunf = Mathf.PI * coll.radius * 2.0f;

float fxRadius = 0.8f;// not really at the border, smokes overlap
//float fxDiameter = fxRadius * 2.0f;

int nFxs = (int)(circunf / fxRadius); // this is not precise computation either

Vector2 towerPos = transform.position;

for (int it = 0; it < nFxs; ++it)
{
float angle = it * angleStep;

Quaternion rot = Quaternion.Euler(0.0f, 0.0f, angle);
Vector2 dir = rot * Vector2.right;
Vector2 pos = towerPos + dir * coll.radius;

spriteFxPooling.PoolObject().GetComponent<SpriteFX>().
Launch(pos, rot, SpriteFX.AnimHashes.SMOKE);
}
}

Edited by Icebone1000

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 13
• 70
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009571
• ### Who's Online (See full list)

There are no registered users currently online

×