对于如下从(xx,yy)到(X,Y)的仿射变换:
X = xx + ax * xx + bx * yy + cx
Y = yy + ay * xx + by * yy + cy
已知(ax,bx,cx),(ay,by,cy)为其仿射变换系数,则(X,Y)到(xx,yy)必然也存在仿射变换关系:
xx = X + axp* X + bxp * Y + cxp
yy = Y + ayp * X + byp * Y + cyp
求其对应的反向系数(axp,bxp,cxp),(ayp,byp,cyp)。
int main()
{
double ax = -0.00012457722524773310000000000;
double bx = -0.00026952578840466643000000000;
double cx = -40.53236981248609500000000000000;
double ay = 0.00088450690917435935000000000;
double by = -0.00006127575130507561900000000;
double cy = -210.50907546352857000000000000000;
double tt = ax * by + ax + by + 1 - bx * ay;
double axp = (by+1) / tt - 1;
double bxp = -bx / tt;
double cxp = (bx * cy - cx - by * cx) / tt;
double ayp = -ay / tt;
double byp = (ax + 1) / tt - 1;
double cyp = (ay * cx - cy - ax * cy) / tt;
printf("%.10lf\t%.10lf\t%.10lf\n", axp, bxp, cxp);
printf("%.10lf\t%.10lf\t%.10lf\n", ayp, byp, cyp);
double xx = 500;
double yy = 600;
double X = xx + ax* xx + bx* yy + cx;
double Y = yy + ay * xx + by * yy + cy;
printf("原始:%.10lf\t%.10lf\n", xx, yy);
printf("正运算:%.10lf\t%.10lf\n", X, Y);
//axp = 0.00012480028850991864000000000;
//bxp = 0.00026947569230899039000000000;
//cxp = 40.47053059568900600000000000000;
//ayp = -0.00088529760825697967000000000;
//byp = 0.00006131347116844487700000000;
//cyp = 210.73126518749581000000000000000;
xx = X + axp* X + bxp * Y + cxp;
yy = Y + ayp * X + byp * Y + cyp;
printf("逆运算:%.10lf\t%.10lf\n", xx, yy);
return 0;
}