/* Algoritmo MidPointCircle */ int midPointCircle(int radius, int puntos[]) { int x = 0, y = radius; double p = 5.0/4.0-radius; int i = 0; i = circlePoints(x, y, puntos, i); while(y>x) { if(p < 0) p += 2.0 * x + 1.0; else { p += 2.0 * (x - y) + 1.0; y--; } x++; i = circlePoints(x, y, puntos, i); } return i; }
void ofApp::circleMidpoint(int xCenter, int yCenter, int radius, ofColor pix) { int x = 0; int y = radius; int p = (5 - radius*4)/4; circlePoints(xCenter, yCenter, x, y, pix); while (x < y) { x++; if (p < 0) { p += 2*x+1; } else { y--; p += 2*(x-y)+1; } circlePoints(xCenter, yCenter, x, y, pix); } // cout << "TotalPoints: " << xEquals0 + xEqualsY + xLessThanY << endl; // cout << "Horizon Radius attempt: " << (int)(1.802 * 3.142 * horizonRadius) << endl; xLessThanY = 0; xEqualsY = 0; xEquals0 = 0; }
/* Algoritmo MidPointCircle */ void midPointCircle(int radius, int angle){ int x = 0, y = radius; double p = 5.0/4.0-radius; circlePoints(x, y, angle); while(y > x) //tan((90.0 - angle) * PI / 180.0) * x){ if(p < 0) p += 2.0 * x + 3.0; else{ p += 2.0 * (x - y) + 5.0; y--; } x++; circlePoints(x, y, angle); }
void Draw :: drawCircle(int xCenter, int yCenter, int radius , COLORREF selcolor){ int x = 0; int y = radius; int p = 1 - radius; circlePoints(xCenter, yCenter, x, y , selcolor ); while(x < y){ x++; if (p < 0) p += 2 * x + 1; else{ y-- , p += 2 * (x - 0 - y) + 1; } circlePoints(xCenter, yCenter, x, y , selcolor); } }
/*! * Based on code by Leonard McMillan. * * \param xCenter The x position of the circle's center (0 to 319). * \param yCenter The y position of the circle's center (0 to 199). * \param radius The radius of the circle. * \param color The color of the circle. */ void circle( int xCenter, int yCenter, int radius, byte color ) { int x = 0; int y = radius; int p = (5 - radius * 4) / 4; circlePoints( xCenter, yCenter, x, y, color ); while( x < y ) { x++; if( p < 0 ) { p += 2*x+1; } else { y--; p += 2*(x - y) + 1; } circlePoints( xCenter, yCenter, x, y, color ); } }
void Circle2D::Draw(SDLApplication* const app, const Vector& base) const { app->Lock(); Vector2D center = base + Center; int r = static_cast<int>(R); int x = 0; int y = r; int d = 1 - r; int delta1 = 3; int delta2 = - 2 * r + 5; circlePoints(app, center, x, y, color); while(y > x) { if(d < 0) { d += delta1; delta1 += 2; delta2 += 2; ++x; } else { d += delta2; delta1 += 2; delta2 += 4; ++x; --y; } circlePoints(app, center, x, y, color); } app->Unlock(); }
void Draw :: MIDPOINT_CARTISIEAN(int x , int y , int radios, COLORREF selcolor){ for(int X = 0 ; X <= radios ; X++){ int Y = sqrt((double(radios*radios)) - (X*X)); circlePoints(x, y, X, Y , selcolor ); } }