Hi everyone! My primary question is below the problem.(adsbygoogle = window.adsbygoogle || []).push({});

My problem:

Circles

The standard form of an equation for a circle is (x − h)2 + (y − k)2 = r2 where (h,k) represents the center of the circle and r is the radius. The y-value of the equation becomes zero at the point of intersection with the x-axis. When the value of 0 is substituted for y, the equation can be simplified to a quadratic equation in standard form.

(x − h)2 + (0 − k)2=r2

(x − h)2 + k2 = r2

x2 − 2hx + (h2 + k2 − r2)=0

From here, the value(s) of x can be resolved using the quadratic formula.

Write a function that accepts the center point and radius of a circle and returns how many times the circle crosses the x-axis, if at all. If an intersection occurs, the function should return the x-value(s) as well. This new function should call a quadraticRoots function you wrote(which should return only the real roots and the number thereof) to determine if the circle crosses the x-axis and if so, where.

******************************************************************************

My question is how do I break the circle equation down so that I can incorporate it into the new function (circleIntersections) to be operated on by the previous function quadraticRoots.

Code (Text):

int quadraticRoots (double a, double b, double c, double& x1, double& x2);

int circleIntersections (double h, double k, double r, double& x1, double& x2);

int quadraticRoots (double a, double b, double c, double& x1, double& x2)

{

int numberOfroots; //real roots

double findRoots1;

double findRoots2;

if( (b*b)-(4*a*c) < 0) // determinant of quadratic formula

{

numberOfroots=0;

}

else if( (b*b)-(4*a*c) == 0)

{

findRoots1= (-b + ( sqrt( (b*b)-(4*a*c) ) ) ) /(2*a); // quadratic formula

findRoots2= (-b - ( sqrt( (b*b)-(4*a*c) ) ) ) /(2*a);

numberOfroots=1 ;

if (findRoots1 == findRoots2)

{

x1=findRoots1;

}

}

else

{

numberOfroots=2;

x1= (-b + ( sqrt( (b*b)-(4*a*c) ) ) ) /(2*a);

x2= (-b - ( sqrt( (b*b)-(4*a*c) ) ) ) /(2*a);

}

return numberOfroots;

}

//int circleIntersections (double h, double k, double r, double& x1, double& x2);

//{

//}

int main()

{

double a=3, b=2,c=3,x1,x2,h,k,r;

cout<<"The number of real roots are: ";

cout<<quadraticRoots(a,b,c,x1,x2)<<"\n";

cout<<"Real roots: "<<x1<<" & "<<x2<<"\n\n";

cout<<"To determine the zero-points of a circle....";

<<"Please enter '(h,k)' coordinates that are the circle's centerpoint: ";

cin>>h>>k;

cout<<"And please enter the circle's radius: " ;

cin>>r;

circleIntersections (h,k,x1,x2);

return 0;

}

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Finding circle zero-points with C++

**Physics Forums | Science Articles, Homework Help, Discussion**