bool pointRotate(int centerX, int centerY, int fromX, int fromY, double dir, int& toX, int& toY)
{
/*
toX = (fromX - centerX) * cos(dir) +
(fromY - centerY) * sin(dir) + centerX;
toY = -(fromX - centerX) * sin(dir) +
(fromY - centerY) * cos(dir) + centerY;
*/
double dSin, dCos;
sincos(dir, &dSin, &dCos);
toX = (fromX - centerX) * dCos +
(fromY - centerY) * dSin + centerX;
toY = -(fromX - centerX) * dSin +
(fromY - centerY) * dCos + centerY;
return true;
}
{
/*
toX = (fromX - centerX) * cos(dir) +
(fromY - centerY) * sin(dir) + centerX;
toY = -(fromX - centerX) * sin(dir) +
(fromY - centerY) * cos(dir) + centerY;
*/
double dSin, dCos;
sincos(dir, &dSin, &dCos);
toX = (fromX - centerX) * dCos +
(fromY - centerY) * dSin + centerX;
toY = -(fromX - centerX) * dSin +
(fromY - centerY) * dCos + centerY;
return true;
}