This is just calculating a 3 x 3 matrix to change the coordinate basis from [(1,0) (0,1)] to [P1, P2]
Edit:
I guess this could be just a 2x2 matrix composed of rotation, scaling, and shearing.
http://www.css.tayloru.edu/~btoll/s99/424/res/mtu/Notes/geometry/geo-tran.htm#affine