I want the source code for calculating the radius of the circle with three coordinate points by using C#.net
I have to come out wwith the formula
Formula
Used :
ya= - 1/ma (x- (x1-x2)/2) + (y1+y2)/2)
yb = - 1/mb(x- (x2+x3)/2) + (y2+y3)/2)
where m is the slope of the line given by
ma= y2-y1/x2-x1 and mb= y3-y2/x3-x2
I have only these ponts, i dont knw how to proceed....
Plz help me out...

Posted Jan 26, 2012, 9:53 PM
namespace center_radius__circle_given_only_three_points
{
class Program
{
static void Main(string[] args)
{
double x1=0, x2=0, x3=0, y1=0, y2=0, y3=0;
Console.WriteLine("Finding RADIUS & CENTRE of the circle that goes through the given three points");
Points[] points = new Points[3];
for (int i = 0; i <= 2; ++i)
{
points[i] = new Points();
Console.Write("\nx{0} = ", i+1);
double x = Convert.ToDouble(Console.ReadLine());
points[i].setX(x);
Console.Write("y{0} = ", i+1);
double y = Convert.ToDouble(Console.ReadLine());
points[i].setY(y);
}
Console.WriteLine();
for (int i = 0; i <= 2; ++i)
{
x1 = points[0].getX();
y1 = points[0].getY();
x2 = points[1].getX();
y2 = points[1].getY();
x3 = points[2].getX();
y3 = points[2].getY();
}
double mr = (double)((y2 - y1) / (x2 - x1));
double mt = (double)((y3 - y2) / (x3 - x2));
double xc = (double)((mr*mt*(y3 - y1) + mr*(x2 + x3) - mt*(x1 + x2)) / (2*(mr - mt)));
double yc = (double) ((-1 / mr)* (xc - (x1 + x2)/2) + (y1 + y2)/2);
Console.WriteLine("Center Points xc = {0} yc = {1}", xc, yc);
double d = (xc - x1) * (xc - x1) + (yc - y1) * (yc - y1);
double r = Math.Sqrt(d);
Console.WriteLine("\nRadius = {0}", r);
Console.ReadKey();
}
}
}
class Points
{
double x;
double y;
public double getX()
{
return this.x;
}
public void setX(double x)
{
this.x = x;
}
public double getY()
{
return this.y;
}
public void setY(double y)
{
this.y = y;
}
}
Alireza RadPosted Jan 26, 2012, 2:49 PM
http://regentsprep.org/Regents/math/geometry/GCG6/RCir.htm
Karthi RamarPosted Jan 25, 2012, 4:32 AM
Jignesh TrivediPosted Jan 25, 2012, 4:14 AM
Karthi RamarPosted Jan 25, 2012, 3:54 AM
Jignesh TrivediPosted Jan 25, 2012, 3:27 AM
In ur formula, but we can not find radus,
can u please about requirment why u required this?
Alok UniyalPosted Jan 25, 2012, 2:44 AM
i m sure that this link will help you-
http://paulbourke.net/geometry/circlefrom3/