Point Object::rotate(const Point &p) { /* We need to: * 1) translate the rotation center to the origin * 2) rotate rAngle degrees around rVec * 3) translate back (undo #1) */ Point c = getRotationCenter(); return r*(p - c) + c; }
void FlowBox::rotate(float da) { if (ROTATION_OFFSET) { cv::Point2f mean = cv::Point2f(x, y); cv::Point2f COR = getRotationCenter(); mean = rotateVector(mean - COR, da) + COR; x = mean.x; y = mean.y; } phi = static_cast<float>(fmod(phi + da + 720, 360)); }
Point Object::unRotate(const Point &p) { Point c = getRotationCenter(); return rInv*(p - c) + c; }