Equation used to represent a disc galaxy

550 Views Asked by At

I'm trying to create a solid which looks something like a disc galaxy:

enter image description here

Key features are:

  • Bulge in the middle
  • Tapered "width" as it extends to a disc shape

The end goal would be to use Python to generate a bunch of "points" (ie, stars) within this galaxy shape randomly and use that to create a galactic model for a game.

I've tried describing the galaxy using spherical coordinates broken up into sections but am failing pretty hard. That's driven to try and find a single equation for the whole solid and then give random values to one of the free variables to find points within the solid.

Any ideas?

2

There are 2 best solutions below

4
On BEST ANSWER

Is this good enough?

$$ (y - e^{-x^2}-0.1)(y + e^{-x^2}+0.1) = 0 $$

galaxy

For 3D case, just replace $y \to z,\ x^2 \to x^2 + y^2$, so $$ (z - e^{-x^2-y^2}-0.1)(z + e^{-x^2-y^2} + 0.1) = 0 $$

enter image description here

but make sure, you restrict your $x$ and $y$ to be in $x^2+y^2 \le r^2$ for some given $r$, to get circular base.

0
On

It looks to me the top boundary in cylindrical coordinates is close to $z=\frac a{r^2+b}$ where $b$ sets the radius of the bulge and $a/b$ is the height at the center.