Ellipsen Algo



  • hi Leutz :),

    ich hab hier nen Ellipsen Allgo, das Problem ist, dass er mir nur eine Viertelellipse zeichnet
    😞 !
    Wie kann ich den Code so abändern, dass eine ganze Ellipse angezeigt wird?.
    Der Algo heißt Midpoint Ellipsen Allgo !

    Hoffe, dass Ihr mir helfen könnt ! 😉
    1000 Thx ShadowEater
    Hier der Code :

    MidpointEllipse(int a, int b, myPoint p1, char c)//Ellipse mit Mittelpunkt
    {
    	myPoint dot;
    	int x = 0; int y = b;
    	double d = b*b-a*a*b-(a*a/4); //Initialisierung von d für 1. Oktanten
    	dot.setX(Round(x)); //Setze 4 Punkte
    	dot.setY(Round(y)); 
    	drawPoint(dot,c);
    
    	while( a*a*(y-0.5) > b*b*(x-1)) 
    	{
    		if (d < 0)	// East
    		{
    			d += b*b*(2*x+3);
    		}
    		else		// SouthEast
    		{ 
    			d += (b*b*(2*x+3)+a*a*(-2*y+2));
    			y--;
    		}
    		x++;
    		dot.setX(Round(x)); //Setze 4 Punkte
    		dot.setY(Round(y)); 
    		drawPoint(dot,c);
    	}
    
    	d = b*b*(x+.5)*(x+.5)+a*a*(y-1)*(y-1)-a*a*b*b; // Initialisierung von d
    	while (y > 0) 
    	{
    		if (d < 0) 
    		{ //SouthEast
    			d += b*b*(2*x+2)+a*a*(-2*y+3);
    			x++;
    		}
    		else // South
    		{
    			d += a*a*(-2*y+3);
    			y--;
    			dot.setX(Round(x)); //Setze 4 Punkte
    			dot.setY(Round(y)); 
    			drawPoint(dot,c);
    		}
    	}
    }
    


  • warum nicht polare Ellipsendef?
    x= acos(phi);
    y= b
    sin(phi);


Anmelden zum Antworten