setToQuadToUnitSquareHomography

Set this matrix to the ground-to-image homography that maps four arbitrary corners ((0,0), (p1x,p1y), (p2x,p2y), (p3x,p3y), in counter-clockwise order: bottom-left, bottom-right, top-right, top-left) to the unit square (0,0), (1,0), (1,1), (0,1).

Approach: build the image-to-ground square-to-quad homography Hi via Heckbert's closed-form (Fundamentals of Texture Mapping and Image Warping), then invert 3x3 to get the direction the fragment shader needs. The corners are passed relative to the bottom-left (so it's treated as the origin), which drops the third column of Hi to (0, 0, 1) and roughly halves the cofactor terms.

Inputs are 2D coordinates in any consistent linear frame (e.g. lon/lat in degrees, or local-tangent meters); for sub-km footprints the planar approximation is well under a metre even on a curved Earth.

Parameters

p1x

x of bottom-right relative to bottom-left

p1y

y of bottom-right relative to bottom-left

p2x

x of top-right relative to bottom-left

p2y

y of top-right relative to bottom-left

p3x

x of top-left relative to bottom-left

p3y

y of top-left relative to bottom-left