Better way to implement:
Use matrix algebra!
lConstruct basis matrix
B = [
W1(:)'
W2(:)'
W3(:)'
W4(:)']
lFlatten the test area:
CRf = CR(:)
l
lCompute coordinate change:
l  NewCoord = B*CRf
% = (10,0,0,0)’
l
lTest2: Step edge:
SE = [
-1 1
-1 1]
SEf = SE(:)

NewCoordSE = B*SEf
% =(0,1.41,-1.41,0)’
lVerify that we can transform back:
SEtestf =B'*NewCoordSE

reshape(SEtestf, 2, 2)
% SEtest =
%   -1.0000    1.0000
%   -1.0000    1.0000
l