Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Drawing an arc with three points ..??
Help me to find this..



private void Form1_MouseDown(object sender, MouseEventArgs e)
{
Graphics gs = this.CreateGraphics();

if (pt[0].X == 0 && pt[0].Y == 0)
{

pt[0].X = e.X;
pt[0].Y = e.Y;
}
else if (pt[1].X == 0 && pt[1].Y == 0)
{

pt[1].X = e.X;
pt[1].Y = e.Y;
}
else if (pt[2].X == 0 && pt[2].Y == 0)
{

pt[2].X = e.X;
pt[2].Y = e.Y;

double dstart = Math.Atan2(pt[0].Y - pt[1].Y, pt[0].X - pt[1].X) * Rad2Deg;



double dEnd = Math.Atan2(pt[0].Y - pt[2].Y, pt[0].X - pt[2].X) * Rad2Deg;

double dSweep = dEnd - dstart;

PointF pMid = new PointF((pt[0].X + pt[2].X) / 2, (pt[0].Y + pt[2].Y) / 2);

double a = pMid.X - pt[0].X;
double b = pMid.Y - pt[0].Y;
double radius = Math.Sqrt(a * a + b * b);

double a1 = pMid.X - pt[1].X;
double b1 = pMid.Y - pt[1].Y;
double radius1 = Math.Sqrt(a1 * a1 + b1 * b1);



gs.DrawArc(Pens.Black, pt[0].X, pt[0].Y, Convert.ToInt32(radius * 2), Convert.ToInt32(radius1), Convert.ToInt32(dstart), Convert.ToInt32(dSweep));


}
}
Posted
Updated 5-Nov-14 21:55pm
v2
Comments
Mehdi Gholam 6-Nov-14 1:12am    
What have you done so far ?
Thanks7872 6-Nov-14 1:41am    
Why? Don't you have access to Google.com?
Sinisa Hajnal 6-Nov-14 2:24am    
Google it.
Bernhard Hiller 6-Nov-14 2:32am    
Can you do it on paper with a pencil, a pair of compasses, and a ruler?
Then translate it.
BillWoodruff 6-Nov-14 6:47am    
How do you know that a (circular) arc CAN be drawn given the three points you have: in other words, how do you know there is a circle that could be drawn such that all three points are on the circumference of the circle ?

 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900