#include #include void MidPoint_Ellipse(double Xc, double Yc, double Rx, double Ry); void Draw_Ellipse (double P, double Xc, double Yc, double X, double Y); int main () { double Xc, Yc, Rx, Ry; printf("Please Enter an ellipse center point coordinates, x-axis radius, y-axis radius\n"); scanf ("%lf %lf %lf %lf\n", &Xc, &Yc, &Rx, &Ry); printf ("Calculating Ellipse border points for center (%lf, %lf) and x-axis radius %lf, y-axis radius %lf\n", Xc, Yc, Rx, Ry); MidPoint_Ellipse (Xc, Yc, Rx, Ry); return 0; } void MidPoint_Ellipse(double Xc, double Yc, double Rx, double Ry) { /* Xc and Yc here denotes the x coordinate and y coordinate of the center of the ellipse and Rx and Ry are the x-radius and y-radius of the ellipse respectively */ double Sx = Rx * Rx; double Sy = Ry * Ry; double X = 0; double Y = Ry; double Px = 0; double Py = 2 * Sx * Y; double P = Sy - (Sx * Ry) + (0.25 * Sx); /* First Region*/ Draw_Ellipse (P, Xc, Yc, X, Y); while (Px 0) { Y = Y - 1; Py = Py - 2 * Sx; if (P > 0) { P = P + Sx - Py; } else { X = X + 1; Px = Px + 2 * Sy; P = P + Sx - Py + Px; } Draw_Ellipse (P, Xc, Yc, X, Y); } } void Draw_Ellipse (double P, double Xc, double Yc, double X, double Y) { printf ("Decision Parameter P %lf\n", P); printf ("%lf %lf\n", Xc + X, Yc + Y); printf ("%lf %lf\n", Xc - X, Yc + Y); printf ("%lf %lf\n", Xc + X, Yc - Y); printf ("%lf %lf\n\n", Xc - X, Yc - Y); }