1原地旋转90度
2中心旋转90度
3中心旋转180度
4中心旋转其他角度
double cx = (bBox.top + bBox.bottom) * 0.5;;
double cy = bBox.left + fabs(bBox.bottom - bBox.top) * 0.5;;
double dRotateRadian = -90.0 / 360.0 * TWO_PI;
double dCos = cos(dRotateRadian);
double dSin = sin(dRotateRadian);
double dtx = -dCos * cx + dSin * cy + cx;
double dty = -dSin * cx - dCos * cy + cy;
CBTransformer rotato(dCos, -dSin, dtx, dSin, dCos, dty);
2中心旋转90度
double cx = (bBox.left + bBox.right) * 0.5;
double cy = (bBox.top + bBox.bottom) * 0.5;
double dRotateRadian = -90.0 / 360.0 * TWO_PI;
double dCos = cos(dRotateRadian);
double dSin = sin(dRotateRadian);
double dtx = -dCos * cx + dSin * cy + cx;
double dty = -dSin * cx - dCos * cy + cy;
CBTransformer rotato(dCos, -dSin, dtx, dSin, dCos, dty);
emptyTransformer.transformedBy(&rotato);
3中心旋转180度
CBTransformer rotateTranf(-1, 0, boxRect.left + boxRect.right, 0, -1, boxRect.top + boxRect.bottom);
4中心旋转其他角度
CBRect bbox = pDoc->getSelectionBBox();
double cx = (bbox.left + bbox.right) * 0.5;
double cy = (bbox.top + bbox.bottom) * 0.5;
double dRotateRadian = m_dAngle / 360.0 * TWO_PI;
double dCos = cos(dRotateRadian);
double dSin = sin(dRotateRadian);
double dtx = -dCos * cx + dSin * cy + cx;
double dty = -dSin * cx - dCos * cy + cy;
CBTransformer rotateTranf(dCos, -dSin, dtx, dSin, dCos, dty);