The Nintendo Wii has a feature called Virtual Console that allows you to play games for older consoles. A specific instance of the Virtual Console for the Nintendo 64 applies a custom "mapping" from GameCube controller inputs that makes controlling the game feel different than on the original console. I've extracted this mapping as a 256 x 256 Lookup Table, and now I'm trying to invert it so that I can make controlling the game feel original again.
$$\operatorname{VC}\colon {\text{GC}}^2 \to {\text{N64}}^2$$ $$\text{GC} \in \mathbb{Z} \cap [0, 255]$$ $$\text{N64} \in \mathbb{Z} \cap [-127, 127]$$ s.t. $\operatorname{VC}$ is defined for all ${\text{GC}}^2$.
However, I would like the mapping to be a function $f\colon {\text{GC}}^2 \to {\text{N64}}^2$ I choose instead.
Overall, this means I want to find a function ${\operatorname{VC}}^{-1}\colon {\text{N64}}^2 \to {\text{GC}}^2$ s.t. $\operatorname{VC}({\operatorname{VC}}^{-1}(f(p)) = f(p), \forall p \in {\text{GC}}^2$.
The problem I'm facing is that $\operatorname{VC}$ is not bijective and also there are elements in ${\text{N64}}^2$ that aren't in the $\operatorname{VC}$ output space. I have taken vector calculus but I'm unsure how to go about finding the inverse for a discrete function with multiple inputs. What is the best way to go about finding ${\operatorname{VC}}^{-1}$?
Shift the GC values by $-127$ to obtain signed values, and work only in the first quadrant (you will symmetrize after the fact).
Initialize the "antiLUT" with a reserved value. Then scan the LUT and assign the GC coordinates to the N64 entry. You will meet two problems:
some N64 entries will be assigned a GC entry several times. There is little you can do to overcome this (you might consider computing the average of the GC entries, but this will be of little help).
some N64 entries will remain unfilled. You will have to interpolate between the known neighboring values (for instance solving the Laplacian equation numerically), and possibly extrapolate near the edges of the domain. Anyway, it the coordinates that are passed to you always come from the direct LUT, there is no need to fill the unfilled entries.