Given the following rectangles:
one can map any point $(x, y)$ from the rectangle to a point $P$ on the quadrilateral using the following steps:
- Define linear interpolation as $l(p_0, p_1, t) = p_0 + t(p_1 - p_0)$
- Get the horizontal and vertical ratios of $(x, y)$ to the dimensions of the rectangle: $r_x = \dfrac{x}{||\overline{AB}||}$ and $r_y = \dfrac{y}{||\overline{AD}||}$
- Linearly interpolate up the "vertical" segments of the quadrilateral using the previously calculated vertical ratio $r_y$: $L = l(A, E, r_x)$ and $R = l(G, F, r_x)$
- Linearly interpolate across the "horizontal" segment $\overline{LR}$ using the previously calculated horizontal ratio $r_x$: $P = l(L, R, r_y)$
Is it possible to find the inverse of this process—that being, is it possible to map a point from the quadrilateral to the rectangle instead of from the rectangle to the quadrilateral?
Note: I am looking to use such a process to draw an image file, which is a "rectangular" two-dimensional array of colors, inside a non-rectangular quadrilateral. If such an inverse process is less efficient than a different approach, then feel free to let me know, but I am still interested in whether or not it is possible to find the inverse of this process.