Note that there are some explanatory texts on larger screens.

plurals
  1. POfind center of circle when three points are given
    primarykey
    data
    text
    <p>I studied <a href="http://mathforum.org/library/drmath/view/55239.html" rel="nofollow noreferrer">this link</a> and coded accordingly but getting Wrong Answer for the example explained in the link, During solving the equation, I subtracted equation 2 from equation 1 and equation 3 from equation 2 and then proceed further. Please check link for clarification.</p> <p>My code is:</p> <pre><code>include&lt;stdio.h&gt; int is_formCircle(float a1,float b1,float a2,float b2,float a3,float b3) { float p1=a2-a1; float p2=a3-a2; float p3=b2-b1; float p4=b3-b2; float alpha=(a1+a2)*(a1-a2) + (b1+b2)*(b1-b2); float beta =(a2+a3)*(a2-a3) + (b2+b3)*(b2-b3); float y1=p1*beta - p2*alpha; float y2=p2*p3 - p1*p4; if(y2==0 || y1==0) return 1; float y=y1/y2; float x1 = 2*p4*y + beta; float x2 = 2*p2; float x = x1/x2; printf("x=%f y=%f\n",x,y); return 0; } int main() { float a1,a2,a3,a4,b1,b2,b3,b4; a1=4.0; b1=1.0; a2=-3.0; b2=7.0; a3=5.0; b3=-2.0; is_formCircle(a1,b1,a2,b2,a3,b3); return 0; } </code></pre> <p>MY another Code:</p> <pre><code>#include&lt;stdio.h&gt; int is_formCircle(float a1,float b1,float a2,float b2,float a3,float b3) { float mid1,mid2,mid3,mid4,m1,m2,D,Dx,Dy,x,y; mid1 = a1+(a2-a1)/2; mid2 = b1+(b2-b1)/2; mid3 = a2+(a3-a2)/2; mid4 = b2+(b3-b2)/2; m1=(b2-b1)/(a2-a1); m2=(b3-b2)/(a3-a2); m1=-1*m1; m2=-1*m2; D=m2-m1; Dx=mid2-(m1*mid1) + (mid3*m2) - mid4; Dy=(m1*(mid3*m2-mid4))-(m2*(mid1*m1-mid2)); x=Dx/D; y=Dy/D; printf("%f %f",x,y); return 0; } int main() { float a1,a2,a3,b1,b2,b3; a1=4.0; b1=1.0; a2=-3.0; b2=7.0; a3=5.0; b3=-2.0; is_formCircle(a1,b1,a2,b2,a3,b3); return 0; } </code></pre> <p>Why my code giving Wrong Answer?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload