What would be a clean way to define a function $F : R^2 \rightarrow R^2$ that maps coordinates from one quadrilateral domain to another like the below image? (Assuming we know the coordinates of the 4 points of each quadrilateral)
Does it matter if one of them is non-convex or is it possible to get a single nice function that handles all cases? If non-convex cases complicate the mapping, what would be a nice function assuming that both are convex?

This can be done using range-split operation, $A,B \in (\mathbb{R},\mathbb{R})$, $x \in [0..1]$:
If your original rectangle coordinates are $(x,y), x \in [0..w], y \in [0..h]$, and corners of new quad is $(A..B),(C..D)$, then the final solution would be: