added calculateAffineMat