- Home /
Proceduraly generated concentric circle sectors
Hi all! Im trying to create a procedurally generated galaxy and subdivide the area in concentric sectors generated the following way:
Id like this to be dynamically and randomly generated.
Bonus points: Sectors should grow in a spiral-like way
Whats a good formula to achieve this? i tried using a pair coordinate system but it fails the further away from the center i am, since the further i am from the center, the bigger each tile is.
Thanks!
Answer by Bunny83 · May 07 at 04:23 PM
a spiral-like way
Well that's a quite vague definition. Though given your example image we could imagine what you had in mind.
Also you need to think of some kind of limiting factors. To how many rings a sector could reach out? How many actual sectors (of the 24 sectors) should one region spread at max / min? Should the limit be per ring or for the region as a whole?. Should there be an area limit per region? Since the sectors grow the further out you go, does that matter regarding the area?
Anyways, what concrete issues do you have implementing your algorithm? You would just start at any cell in the inner ring and follow the above mentioned rules. Roll some random numbers to define how many cells on the first ring you may occupy. Roll another random number to decide how many rings to go out. For each ring, roll another random number to decide how many cells it should be offset compared to the first Once one region is finished, just start again at the first ring at the end of the last one. Since you probably don't want any gaps, each ring would simply start at the end of the previous ring. The outer rings should always have at least as many cells as the next inner ring. This ensures that you don't move backwards like you did in the yellow region, second ring.
Since you have a fix sector count, the whole thing can be stored in a single flattened array where 24 elements represent one ring and the next 24 elements the second ring and so on.
Hi, thanks for your reply. I working on the algorithm and the limiting factors are variables I'm playing with.
The I have two current issues: I currently have 24 elements per ring, but this has the mentioned issue that as the ring number increases, so does the size of each element. I'm thinking that maybe I could have 48 elements after the 5th ring, 96 after the 10nth, etc. So the first issue is: I don't know if this is a good idea and if it scales well.
The second issue I have is that I don't know how I can create a mesh representing each sector.
Thanks again!