对给定向量旋转
顺时针:
逆时针:
源码:
QPointF rotateVector(const QPointF& dir, double angle, bool flag){double rad = (angle * M_PI) / 180;QPointF res;if (flag){float x = static_cast<float>(dir.x() * std::cos(rad) + dir.y() * std::sin(rad));float y = static_cast<float>(-dir.x() * std::sin(rad) + dir.y() * std::cos(rad));res = QPointF(x, y);}else{float x = static_cast<float>(dir.x() * std::cos(rad) - dir.y() * std::sin(rad));float y = static_cast<float>(dir.x() * std::sin(rad) + dir.y() * std::cos(rad));res = QPointF(x, y);}res /= normQPointF(res);return res;}