旋转具有给定度数的形状时,我遇到了一些问题。
void Shape::rotate(double degrees)
{
// rotates the vertices of a shape by a specified angle in degrees
int x, y, xx, yy;
double radians;
x = centroid.getX();
y = centroid.getY();
vertices.push_back(Vertex(x, y));
x = vertices.back().getX() - centroid.getX();
y = vertices.back().getY() - centroid.getY();
radians = (degrees * PI) / 180;
xx = round(x * cos(radians) - y * sin(radians));
yy = round(y * cos(radians) + x * sin(radians));
xx = xx + centroid.getX();
yy = yy + centroid.getY();
vertices.push_back(Vertex(xx, yy));
radians = (degrees * PI) / 180;
xx = round(x * cos(radians) - y * sin(radians));
yy = round(y * cos(radians) + x * sin(radians));
xx = xx + centroid.getX();
yy = yy + centroid.getY();
vertices.push_back(Vertex(xx, yy));
radians = (degrees * PI) / 180;
xx = round(x * cos(radians) - y * sin(radians));
yy = round(y * cos(radians) + x * sin(radians));
xx = xx + centroid.getX();
yy = yy + centroid.getY();
vertices.push_back(Vertex(xx, yy));
}
但我得到的输出是:
我出错的任何想法?