I've been wrestling with a very similar problem in order to determine gradients in an irregular quad grid and needing to map points within arbitrary quadrilaterals to a unit square. In addition, I require the inverse mapping of the x and y axis at the mapped normalized coordinate location back into the quad so I can determine the orientation of the quad grid at that point. i.e. if [x',y'] are the transformed coordinates, I need to be able to do an inverse transform on [0,y'],[1,y'] and [x',0],[x',1]. Here is what I've come up with:
You can divide the quad into two tris, and use affine maps on these individually. This is not difficult. This will create a noticable effect at the division between the two tris, however.
If you want a smooth mapping from a quad to a square (or rectangle), you need to use a non-affine transform such as a projective transform. There are other transforms other than projective that will also work, and also be colinear (preserve straight lines).
If [x1,y1],[x2,y2],[x3,y3],[x4,y4] are the four points in the quad, then the 4x4 matrix B in the the following will yield a mapping into the square (on the RHS) that seems to work and may be easier to compute than the proper 3x3 projective matrix.
% [x1 y1 x1*y1 1] [0 0 0 1]
% [x2 y2 x2*y2 1] X B = [1 0 0 1]
% [x3 y3 x3*y3 1] [0 1 0 1]
% [x4 y4 x4*y4 1] [1 1 1 1]
The question I have is that if one does this, and then wants to use the inverse of B to do the inverse transform, how do you calculate the third elements of the location vectors for the orthogonal coordinates. (They are no longer x*y.)
NOTE: If you want to map into any other (arbitrary) quadrilateral (such as a rectangle), then just replace the RHS of what I have above with the new coordinates.
% [x1 y1 x1*y1 1] [x1' y1' x1'*y1' 1]
% [x2 y2 x2*y2 1] X B = [x2' y2' x2'*y2' 1]
% [x3 y3 x3*y3 1] [x3' y3' x3'*y3' 1]
% [x4 y4 x4*y4 1] [x4' y4' x4'*y4' 1]