I have a particle at a fixed position X and fixed amplitude AMP that travels on a sin wave.
I'd like to be able to dynamically change the period of the target sine wave WITHOUT moving the particle. (When I change the period, its X position doesn't line up to the same Y position of the graph with a different period, so it jumps all over the place.
I have a solution for this - Find where the graph with the new period intersects with the graph of the old period and create an X-offset, lining these two figures up.
For any given y on a sin wave, there will be 2 corresponding X values per period. I'm trying to get these two values. I'll then compare the derivatives to choose which one I want.
However, I don't know how to get both of these values. Any ideas?
Here's an image of what I'm after: Sin Wave Logic
If you have a sine-wave defined by
y = sin(a*(x+c))+d
then you can reverse it by
x = (arcsin(y-d)-c)/a
for a given a.
This yields the solution in the range of [-pi;pi]
The other solution you are looking for is then 2*pi-x