c++ Bresenham ' s line algorithm draw arc und drehen

Ich bin auf der Suche Weg, um arc mit Bresenham ' s line algorithm. Diese algoritm zeichnen perfekter Kreis, aber was ist, wenn ich brauche, draw arc (von 0 bis Pi), und drehen Sie ihn um 30 Grad (zum Beispiel)?

void DrawCircle(HDC hdc,int x0, int y0, int radius) 
{
        int x = 0;
        int y = radius;
        int delta = 2 - 2 * radius;
        int error = 0;

        while(y >= 0) {
                //SetPixel(hdc,x0 + x, y0 + y,pencol);
                SetPixel(hdc,x0 + x, y0 - y,pencol);
                //SetPixel(hdc,x0 - x, y0 + y,pencol);
                SetPixel(hdc,x0 - x, y0 - y,pencol);
                error = 2 * (delta + y) - 1;
                if(delta < 0 && error <= 0) {
                        ++x;
                        delta += 2 * x + 1;
                        continue;
                }
                error = 2 * (delta - x) - 1;
                if(delta > 0 && error > 0) {
                        --y;
                        delta += 1 - 2 * y;
                        continue;
                }
                ++x;
                delta += 2 * (x - y);
                --y;
        }
}

InformationsquelleAutor PePe | 2011-12-09

Schreibe einen Kommentar