POJ 1329 Circle Through three Points

Source: Internet
Author: User

Circle Through Three Points
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 3678 Accepted: 1542

Description

Your team is to write a program that, given the Cartesian coordinates of three points on a plane, 'll find the equation o f the circle through them all. The three points is not being on a straight line.
The solution is-printed as an equation of the form
(x-h) ^2 + (y-k) ^2 = r^2 (1)

and an equation of the form
x^2 + y^2 + cx + dy-e = 0 (2)

Input

Each line of input to your program would contain the x and Y coordinates of three points, in the order Ax, Ay, Bx, by, Cx, Cy. These coordinates would be the real numbers separated from each other by one or more spaces.

Output

Your program must print the required equations on both lines using the format given in the sample below. Your computed values for h, K, R, C, D, and E in equations 1 and 2 above is to be printed with three digits after the DEC iMAL Point. Plus and minus signs in the equations should is changed as needed to avoid multiple signs before a number. Plus, minus, and equal signs must be separated from the adjacent characters by a single space on each side. No other spaces is to appear in the equations. Print a single blank line after each equation pair.

Sample Input

7.0-5.0-1.0 1.0 0.0-6.01.0 7.0 8.0 6.0 7.0-2.0

Sample Output

(x-3.000) ^2 + (y + 2.000) ^2 = 5.000^2x^2 + y^2-6.000x + 4.000y-12.000 = 0 (x-3.921) ^2 + (y-2.447) ^2 = 5.409^2x^2 + y^2-7.842x-4.895y-7.895 = 0









#include <stdio.h>
#include <math.h>
struct Node
{
Double x, y;
} Center;
void Center (double x1,double y1,double x2,double y2,double x3,double y3)
{
Double t1,t2,t3,temp;
T1=x1*x1+y1*y1;
T2=x2*x2+y2*y2;
T3=x3*x3+y3*y3;
Temp=x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2;
center.x= (t2*y3+t1*y2+t3*y1-t2*y1-t3*y2-t1*y3)/TEMP/2;
Center.y= (t3*x2+t2*x1+t1*x3-t1*x2-t2*x3-t3*x1)/TEMP/2;
}
Double D;
void dis (double x1,double y1,double x2,double y2)
{
D=sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (Y1-y2));
}
int main ()
{
Double x1,y1,x2,y2,x3,y3;
while (scanf ("%lf%lf%lf%lf%lf%lf", &x1,&y1,&x2,&y2,&x3,&y3)!=eof)
{
Center (X1,Y1,X2,Y2,X3,Y3);
printf ("%lf%lf\n", center.x,center.y);
Dis (center.x,center.y,x1,y1);
printf ("%lf\n", D);
(x-3.000) ^2 + (y + 2.000) ^2 = 5.000^2
printf ("(x");
if (center.x<0)
printf ("+");
Else
printf ("-");
printf ("%.3LF") ^2 + (y ", Fabs (center.x));
if (center.y<0)
printf ("+");
Else
printf ("-");
printf ("%.3lf) ^2 =", Fabs (CENTER.Y));
printf ("%.3lf^2\n", D);
x^2 + y^2-6.000x + 4.000y-12.000 = 0
printf ("X^2 + y^2");
if (center.x<0)
printf ("+");
Else
printf ("-");
printf ("%.3lfx", 2*fabs (center.x));
if (center.y<0)
printf ("+");
Else
printf ("-");
printf ("%.3lfy", 2*fabs (CENTER.Y));
D=center.x*center.x+center.y*center.y-d*d;
if (d<0)
printf ("-");
Else
printf ("+");
printf ("%.3lf", Fabs (d));
printf ("= 0\n\n");
}
return 0;
}

POJ 1329 Circle Through three Points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.