C++ Rotating 2D Shape List -


i having bit of issue rotating shape given degrees.

void shape::rotate(double degrees) {     // rotates vertices of shape 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)); } 

but output this:

messed rhombus

any ideas i'm going wrong?


Comments