# Math God needed

Go to solution Solved by Barand,

## Recommended Posts

Every year I run into some math that is over my head lol.

Say I have a circle with a radius of 600 and I want to place 20 objects around the circle perfectly spaced.

I need to figure out what the x and y would be for each object.

##### Share on other sites

"Perfectly" spaced how? 20 isn't a nice number like 19 (hexagonal) or 25 (square).

##### Share on other sites

• Solution

If you want them spaced around the circumference then the attached diagram will tell you what you need to know

##### Share on other sites

Thanks for thee responses guys.

Ya I meant spaced around its circumference. So together all 20 objects forms a circle.

I think this is the formula I saw when I was trying to google it Barand.

I'm confused about the theta part

Do I use pie for that?

Also not sure how this would give me 20 spaced out. But I guess the theta would determine that.

so really I need 20 slices of pie and a object in the middle of each slice on the circumference.

Maybe I need to find the circumference first then divide it out by 20.

Then find what each one would be spaced out on the circumference.

Then some how use that number with a formula to find my x and y?

##### Share on other sites

All you need is theta. You have 20 objects so theta will start at zero and increase by 2*PI/20 for each one. Then, as in the diagram, if the circle has radius R and its centre is at cx,cy the x,y coordinates for each object are

```x = cx + R * cos(theta)
y = cy - R * sin(theta)```
##### Share on other sites

Ahh OK. Thanks now I know how to find theta.

I can just ignore cy and CX right since that's always going to be 0,0?

##### Share on other sites

0,0 is usually at the top left corner of the image.

##### Share on other sites

Actually this is for unity game engine. Atm center is 0,0

So I'm dealing with negative numbers

##### Share on other sites

Actually the zero probably affects if the vakue is negative or not

##### Share on other sites

Here's an example

```<?php
\$width = 140;
\$height = 140;
\$dtheta = M_PI/10;

\$im = "<svg width=\"\$width\" height=\"\$height\" viewBox=\"0 0 \$width \$height\" >\n
<rect x='1' y='1' width='\$width' height='\$height' fill='black' />\n
<g transform='translate(70,70)'>\n
<circle cx='0' cy='0' r='\$rad' stroke='white' fill='none' />\n";
for  (\$theta=0; \$theta<2*M_PI; \$theta+=\$dtheta) {
\$im .= "<circle cx='\$x' cy='\$y' r='5' fill='cyan' />\n";
}
\$im .= "</g></svg>\n";

echo \$im;
?>
```

##### Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.