Finding the inverse of this spatial transform

38 Views Asked by At

I have a 2D spatial transform that intuitively is 1:1 (bijective), but I am having a hard time coming up with the formula for the inverse.

Given a point $(x,y)$, the forward transform is like so:

$ y' = f(x,y) = y + A_y \cdot sin(f_y\cdot x + P_y)\\ x' = g(x,y) = x + A_x \cdot sin(f_x\cdot y + P_x)$

Where $A$, $f$, and $P$ are constants representing amplitude, frequency, and phase, respectively. They can be different for the $x$ and $y$ components.

Note, importantly, $y'$ is a function of both $x$ and $y$, and the same with $x'$.

Visually, if you start with space like this:

enter image description here

And apply the transform only for one of $x$ or $y$, you might get this:

enter image description here enter image description here

Or if you have nonzero contribution in both components, you might get:

enter image description here

So, just eyeballing it, and generally considering cases where $A\ne0, f\ne0$, it seems like this transform should be invertible. But so far, I've failed to come up with a good formula for it.

Some basic progress I've made, trying to "solve for x" (the x and y cases are essentially the same):

We can rearrange the $y' = \dots$ formula to:

$y = y' - A_y\cdot sin(f_y\cdot x + P_y)$

Or, likewise, we can rearrange the $x' = \dots$ formula to get $y$

$y = \frac{sin^{-1}(\frac{x' - x}{A_x}) - P_x}{f_x}$

And the obvious thing to attempt is to set these equal, and solve for $x$:

$y' - A_y\cdot sin(f_y\cdot x + P_y) = \frac{sin^{-1}(\frac{x' - x}{A_x}) - P_x}{f_x}$

Okay, great... Now how to turn that into $x = \dots$ ?

Or maybe there's some superior approach I'm not thinking of?

Even just ignoring $A$, $f$, and $P$, it boils down to:

$y' - sin(x) = sin^{-1}(x' - x)$

which doesn't seem clear how to solve, to me.

1

There are 1 best solutions below

0
On BEST ANSWER

This is not invertible in general. For instance, you can choose the parameters so that both $(0,1)$ and $(1,0)$ get mapped to $(1,1)$. For $(0,1)$ to get mapped to $(1,1)$, you need $$A_y\sin(P_y)=0$$ and $$A_x\sin(f_x+P_x)=1.$$ For $(1,0)$ to get mapped to $(1,1)$, you need $$A_y\sin(f_y+P_y)=1$$ and $$A_x\sin(P_x)=0.$$ So, you can just choose $P_x$ and $P_y$ such that their sines are $0$, then choose $f_x$ and $P_y$ such that $\sin(f_x+P_x)$ and $\sin(f_y+P_y)$ are nonzero, then choose $A_x$ and $A_y$ to be the reciprocals of these sines.

Intuitively, looking at your picture, if the amplitudes were a bit higher then the horizontal and vertical oscillations on the two axes could "crash" into each other, making the transformation fail to be injective.