The problem
I set out to create a polar graph of a spiral with the following properties: (Listed in order of priority)
- It should be performant to calculate (A household computer should be able to easily calculate 12k points per second)
- At all times the spiral should be "smooth" with no bumps or sudden turns
- It should be expressed in closed form
- The radius should start near 1 and descend slowly at first
- Near to $\pi$ it should descend more quickly, arriving at $\theta = \pi, r \approx 0.5$ (Arriving later is better than sooner)
- After that, the rate of descent should slow down again and the spiral should make a few more ($\approx3$) revolutions before reaching 0 (If it ever does, it doesn't have to)
- Nice to have: Be able to adjust the "inner radius" (currently 0.5) by changing a variable
My solution
After a lot of tweaking I managed to come up with this: $^\$$
$$\begin{align} F(\theta) &= \frac{\sin(\theta^3\pi - \frac \pi2) + 1}{2}\\ G(\theta) &= \frac{\sin(\theta\pi - \frac \pi2)+1.1}{2.2}\\ H(\theta) &= \frac{\sin(2\pi\theta^2)}{40 G(\theta)} \end{align} $$
and finally:
$$r = F(\frac {\theta}{5\pi}) + H(\frac {\theta}{5\pi})$$
This produces the following graph:
It's not perfect, but it is the closest I've been able to come to meeting all of the requirements.
I am happy with the fact that at the outermost point the tangent is almost straight up and it hits $r = 0.5$ right when I wanted it to.
The question
What I would like help with:
- Make the function more elegant, as it stands coding this would be a mess and I only arrived at it by clumsily stumbling around
- It would be nice (though not required) for the inner revolutions to be slightly flatter, with my solution the innermost revolution is about half the size it should be
$^\$$ I am aware these functions are "backwards" but it's trivial to resolve that so I'm not concerned
