|
The Sin() function requires radians, not angles!
Radian=Angle*3.14/180
Therefore, the landlord try the following code:
Graphics g=this.CreateGraphics();
Pen redpen=new Pen(Color.Red,2);
float r=100F;
double f=0;
float x=100.0F;
float y=100.0F;
float width=20.0F;
float height=20.0F;
for(int i=0;i<360;i++) //360 degrees is a full circle
{
float a=(float)Math.Sin(i*3.14/180);//radian=angle*3.14/180
float b=(float)Math.Cos(i*3.14/180);//Ibid
g.DrawEllipse(redpen,x+r*a,y+r*b,width,height);
System.Threading.Thread.Sleep(100);//Delay
g.Clear(this.BackColor);
} |
|