9
\$\begingroup\$

I'd like to generate galaxy using seed , with shape changing a bit and positioning X number of stars.

I'd like to make it realistic (as possible). But i have absolutely no idea how i should do that. I'm not talking about procedural content generation , i know a bit about and i can search for it if i need, i talking about formulas to use to generate galaxy and then placing dots (stars) so it can look real.

In my mind i see it this way:

1) place a center

2) generate tentacles (don't know the exact term) (i'd like to set the number of tentacles)

3) place dots randomly around those tentacles.

bonus question : i'd like to move the galaxy ingame (like it move in real) , and i don't get if a rotating would be enough and if the movement is more complex)

\$\endgroup\$
5
  • 4
    \$\begingroup\$ They're called Spiral Arms, while most galaxies are spirals (about 3/4) there are other shapes to consider. \$\endgroup\$
    – House
    Jan 19, 2013 at 17:52
  • \$\begingroup\$ Regarding "realistic", keep in mind that a spiral galaxy can have more than 200 billion stars, as the milky way has about 200-400 billion stars, our neighbor the andromeda galaxy has 1000 billion stars. If you were to pretend it is a flat galaxy and floats were precise enough, you could get away with 2D coordinates, 2 floats, so 8 byte per star for 200 billion stars needs 1.6 Terrabyte. So focus on good looking, rather than realistic :) Depending on what you actually need, a texture would do the job much better \$\endgroup\$ Jan 19, 2013 at 18:35
  • \$\begingroup\$ Somewhat related and certainly inspiring: google's awesome "100,000 stars" visualisation of our milky way galaxy (needs webGL) \$\endgroup\$ Jan 19, 2013 at 18:45
  • \$\begingroup\$ @Maik yes of course I should have said it, I want it look realistic in a graphic way. I do not plan to insert the real number of stars. Just enough to look nice (considering that each stars generated could have planets that I'll use too).a texture is not possible since this will become a interactive map. \$\endgroup\$
    – eephyne
    Jan 19, 2013 at 18:52
  • 2
    \$\begingroup\$ Keep in mind that even astrophysicists haven't fully understood the physics behind galaxy formation and rotation yet. \$\endgroup\$
    – Philipp
    Jan 20, 2013 at 14:10

2 Answers 2

11
\$\begingroup\$

Similar to your algorithm, this is the algorithm I would suggest.

Set your variables. Choose armCount arms, radius radius, spinFactor for spin factor, armR for arm radius, starCount for star count and point center point.

  1. Place the armCount arms pointing straight away from a central point point. These should be roughly equidistant around the circumference of the circle (with a radius of radius entered on point) that makes up the galaxy.
  2. Divide starCount into roughly equal armCount portions.
  3. For each arm place starCount/armCount stars randomly inside the cylinder that follows the arm with a radius of armR. Star placement should be weighted in the following way:
    1. More likely to be placed towards the core than towards the arm tip.
    2. More likely to be placed closer to the center of the cylinder than the outside of the cylinder.
  4. Now you have a galaxy shaped like a star with armCount arms. With more stars at the core and the arms somewhat distinct. Time to rotate. For each star, take its distance from the center and multiply that by spinFactor to get a rotationAmount.
  5. Rotate each star by the rotation amount clockwise or counter clockwise around the center point.
  6. Marvel at the resulting spiral galaxy.

You could probably combine the rotation and placement steps and just place the start initially at their rotated position. I'd do it in separate steps to start with, just so you can see how things form up without being all twisted up.

Bonus answer: Humans haven't really had the star viewing technology long enough to watch a galaxy rotate, so we don't know exactly how it looks. However, from viewing simulations, it looks like it's spinning at higher speed in the center than the outside. You can try applying the same rotation to each star as you do in step 5. Or you can just slowly rotate the entire galaxy and see how it looks.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Actually we have observational evidence, that the rotational velocity inside and far outside of the galaxy is pretty much the same, also known as the Galaxy rotation problem. The most accepted explanation right now for the huge discrepancy between the expected and the observed result is Dark Matter. \$\endgroup\$ Jan 19, 2013 at 18:59
  • \$\begingroup\$ OK I just saw the years count in the link you provided. I though it was moving a lot faster! Considering that I'll not simulate rotation. \$\endgroup\$
    – eephyne
    Jan 19, 2013 at 19:07
  • \$\begingroup\$ @eephyne Yes, it takes a very long time to rotate. The galactic year of the Milky Way is something like 230 million years. It does spin very fast, it has a very, very long way to go. \$\endgroup\$
    – House
    Jan 19, 2013 at 19:10
  • \$\begingroup\$ @MaikSemder Thanks, I'd read that the speeds were not what was expected, but didn't know they were nearly the same. Interesting. \$\endgroup\$
    – House
    Jan 19, 2013 at 19:11
10
\$\begingroup\$

Here are two articles that may give you some more ideas.

How Frontier: Elite 2 generated The Milky Way with 513,982,470 unique stars. (archived)

Point cloud galaxy generation in Infinity. (broken link)

\$\endgroup\$
1
  • \$\begingroup\$ I think the second link has become defunct in the past 3 years. \$\endgroup\$
    – Pharap
    Apr 12, 2016 at 7:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .