This came from https://www.cs.cmu.edu/~ph/src/texfund/ with more detail at http://graphics.cs.cmu.edu/courses/15-463/2006_fall/www/Papers/proj.pdf An explanation of the transform maths is at: https://paulbourke.net/geometry/transformationprojection/ under the section headed "Correction of Planar (Stretch) Distortion" I have some code somewhere to do this on the Pitrex that I need to find and upload.