   Rotating a Polygon.
  I'm trying to set up a new, more advanced Physics engine for my next game. I've stumbled at the very first hurdle...! I'm using SDL with the SDL_gfx library to draw graphics primatives.I've got a Brick class, the vertices of which are declared thusly: short s[5] = { Brick::x, Brick::x, Brick::x + Brick::width, Brick::x + Brick::width, Brick::x }; short t[5] = { Brick::y, Brick::y + Brick::height, Brick::y + Brick::height , Brick::y, Brick::y };And drawing the polygon works fine:filledPolygonRGBA(screen,    s, t,    5,    Brick::colourR, Brick::colourG, Brick::colourB, Brick::colourA);I now want to rotate this polygon, which is where I've become unstuck. I know from my friend Google that I need to onvert everything to Radians, like this:double radians = 6.283185308 / (360.0 / Brick::angle);  double c = cos(radians);  double s = sin(radians);But I have no idea how to translate the arrays of points for my Polygon.Any advice would be much appreciated!Dan   
  The first thing you need is a function to rotate a vector about the origin. You can find the equation and derivation for this online (google '2d rotation' or 'vector rotation'), but here it is off the top of my head (using shorts, like your example):void rotatePoint(short x, short y, short& newx, short& newy, float angle){    float s = std::sin(angle);    float c = std::cos(angle);    newx = short(c*float(x)-s*float(y));    newy = short(s*float(x)+c*float(y));}Next, IMO it's best to define your shapes relative to the origin and then transform them for rendering, but we'll assume for now that your polygons are arbitrarily positioned. I'm also assuming you wish to rotate them about their center, which requires the following steps:1. Translate the polygon so that it's centered at the origin2. Apply rotation to each vertex using the above function3. Translate the polygon back its original positionNote that the rotation in this case is relative to the polygon's current orientation.Again though, for various reasons this really isn't the best way to do it. You should really keep a copy of your polygons stored in local space (centered at the origin), in which case only steps 2 and 3 are required. Also, in this case the rotation will be absolute rather than relative.Let me know if anything is unclear.   