I'm trying to generate a spiral galaxy in the form of xy (2D) coordinates -- but math is not my strong suit.
I've gleaned the following from an excellent source on spirals:
The radius r(t) and the angle t are proportional for the simpliest spiral, the spiral of Archimedes. Therefore the equation is:
(3) Polar equation: r(t) = at [a is constant].
From this follows
(2) Parameter form: x(t) = at cos(t), y(t) = at sin(t),
(1) Central equation: x²+y² = a²[arc tan (y/x)]².
This question sort of touched upon galaxy generation, but the responses were scattered and still overly complex for what I need (aka, my math-dumb mind can't understand them).
Essentially, what I need to do is loop through a spiral formula in PHP ~5000 times to generate points on a 513x513 XY grid. The size of the grid and the number of points needed may change in the future. Even better would be to weigh those points towards the origin of the spirals both in frequency and how far they can stray from the exact mathematical formula, similarly to how a galaxy actually looks.
This mathematical paper talks about a formula that describes the structure of spiral galaxies.
What completely loses me is how to translate a mathematical formula to something I can loop through in PHP!