# Efficient way to recompute weights when shifting range of Legendre polynomial bases

I am storing a 2D (Cartesian) density function as a 2D patch with known X/Y limits and a set of 11 coefficients of the third order 2D Legendre polynomial basis functions over that patch. This works really well for my application which tends to have local soft "blobs" of intensity in limited regions. The Legendre basis weights are defined over a local coordinate system which spans -1 to 1 over the patch, even though the patch itself is offset (and stretched) by the known X Y limits of the patch.

Now the question: I have two patches with different X Y limits. They intersect.. for simplicity let's say one patch is entirely within the other patch. I want to merge the two patches to combine their effect into a single patch. This loses some information but that's OK for my purpose.

If the two patches both had the exact same XY limits, I could just add the Legendre basis coefficients term by term and I'd be done. But this isn't possible when their domains don't match, so I need to "stretch" the smaller domain to fit the bigger one, which changes its basis function values.

I could do this in an ugly and straightforward way by converting the XY patch density into a big expanded polynomial representation (ugh), applying an affine transformation to each power of X and Y (ugh). Then I'd take the polynomial expansion of each of the Legendre basis function definitions, expand THOSE into a polynomial, then integrate the product of the two polynomials in the large patch's domain (over the range covered by the small patch) to find the coefficient for that basis in the second patch. (ugh ugh ugh!) While straightforward, This is an enormous amount of bookeeping, especially when you have higher order terms.

Surely there's a better way of doing this, but it's not clear to me.

This may be related to the similar problem of splitting such a patch.. if I split the patch into two at a known slice line, how can I compute the basis weights of each of the two subpatches?

-