So like, a Very Long Time Ago I made these cool swirly curves while working on aerobat vfx stuff
Conceptually it's really simple:
Imagine a car driving at a constant speed. As it drives, the steering wheel is turned left/right according to some function. In this case it's just a cosine wave, i.e. you just smoothly wobble the wheel back and forth. By simply changing how fast the steering wheel oscillates, and how far from the center it's allowed to turn, the path of the car plots these different curves.
This is really easy to plot over time in a game, or in a single for-loop. It's a basic Turtle Graphics situation [turtles are operated by steering wheels]
OKAY BUT
What if you don't want a for loop. What if you just want to ask "at time t, where is the car" and just calculate the answer directly.
It's just a cosine function; it SEEMS like someone would have dug into this before. I asked around on twitter but nobody could answer so instead I ended up Doing Math.
tl;dr: haha you can't
You're welcome to stop reading now but I did all that math so I might as well explain it. There is, as Math Dorks like to say, No Closed-Form Solution.
Here's a desmos graph where I figured out the actual math and made a bunch of sliders you can play with
.png)
Basically: If you have a function that describes the movement of a steering wheel, the direction of travel at an arbitrary time depends on all previous movements of the wheel. So "What direction is the car moving" is just the definite integral of your steering-wheel function.
Since the speed is constant and we can exactly calculate the direction, we now know the velocity at any point in time, so we can get the position of the car by summing all previous velocities, which is.... ahhh right shit that's another integral
now we're into second-order integrals. we have been hurled into The Math Zone
Well I mean, it's literally just a cosine and some constants. How bad can it be
hm
well
fuck
yeah so apparently integrals involving nested sin/cos functions have "no closed-form solution" which sounds very clever to say but what it actually means is I threw this at a bunch of different computer programs that are supposed to solve integrals and they all broke and then I found a mathoverflow post where people were like "yeah you can't, except a really special case around exactly pi/2" and then I started seeing references to The Method of Frobenius and look man if Stephen "Wolfram" Alpha can't solve your integral I really don't think fucking Doctor Seuss is gonna help here
In Conclusion:
Given that there's no closed form, the remaining option is to estimate the answer using Unicode Math Bold Fraktur Voice Numerical Integration. There's all kinds of crazy elaborate iterative solvers you could throw at this or like sick-ass importance-sampled temporal-reprojected monte-carlo methods but like.
You know what's a really fast highly-accurate algorithm for performing Numerical Integration? A for-loop with a turtle in it.