using mid point algorithm
but ellipse is not complete
this is the code
please i want to know what is problem?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace prof
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
float rx = 90;
float ry = 70;
float xc = 200;
float yc = 200;
float x = 0;
float y = ry;
float m;
float s;
while (x < y)
{
plot(x, y, xc, yc);
m = fellipse(x + 1, y + (1 / 2), rx, ry);
s = fellipse(x + (1 / 2), y - 1, rx, ry);
if (m < 0)
{
x++;
}
else if (m >= 0)
{
x++;
y--;
}
else if (s <= 0)
{
x++;
y--;
}
else if (s > 0)
{
y--;
}
}
}
public float fellipse(float x, float y, float rx, float ry)
{
return (ry * ry) * (x * x) + (rx * rx) * (y * y) - (rx * rx) * (ry * ry);
}
public void plot(float x, float y, float xc, float yc)
{
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 4);
g.DrawRectangle(p, x + xc, y + yc, 1, 1);
g.DrawRectangle(p, -x + xc, y + yc, 1, 1);
g.DrawRectangle(p, -x + xc, -y + yc, 1, 1);
g.DrawRectangle(p, x + xc, -y + yc, 1, 1);
}
}
}


Sign In
Create Account

Back to top









