Rotate Point Around Origin

//----------------------------------------------------------------------------
void RotatePointAroundOrigin(&Point, Point origin, double angle)
{
    float s = sin(angle);
    float c = cos(angle);

    // Translate point back to origin:
    point.X -= origin.X;
    point.Y -= origin.Y;

    // Rotate point
    float xnew = point.X * c - point.Y * s;
    float ynew = point.X * s + point.Y * c;

    // Translate point back:
    point.X = xnew + origin.X;
    point.Y = ynew + origin.Y;
}

Commenti

Post popolari in questo blog

Indovinello: Soluzioni!!!