# Thread: Point to lie on a circle. Help!

1. ## Point to lie on a circle. Help!

Please, would you help me with this program:

Code:
``` #include <iostream>
#include <cmath>
using namespace std;

void main()
{
cout << "x = ";
double x;
cin >> x;

cout << "y = ";
double y;
cin >> y;

bool c1 = ((((x + 1)*(x + 1) + (y - 1)*(y - 1)) <= 1) &&
(y <= (1/3*x + 1)) &&
(y >= (x + 1)) &&
(y >= 0));

if (c1)
cout << "true" << endl;
else
cout << "false" << endl;

}```

The point don`t have to lie in (-2, 0.5), (-2, 1) and (0,1). :S

2. Sure:

1. It's int main(). Read why void main() is wrong
2. Learn how to indent your code.
3. Learn how to ask questions.

3. On a circle?
In a circle?

We need more than some random uncommented code, and an unexplained picture.

4. Shouldn't you have more than just one set of numbers? Like D is the diameter of the circle, and X,Y is the coordinate of the center of the circle, and pX,pY is the coordinates of the point you want to check? You have X and Y, but what are you comparing X and Y to? You can't find out if something is relative to a coordinate, if you only have one of the two pairs of coordinates.

"Is this point on a line?"
"Maybe."

Quzah.

5. Quzah is right. You cannot solve this problem without knowing the center of the circle and the radius or diameter of the circle. Since a circle is the set of all points equidistant from a center point the check to see if px,py lies on the circle is simple if you know those two pieces of information about the circle.

6. From the diagram, we know the centre of the circle. I think what we don't know is what the original poster is actually asking.

7. Thank you!

8. For what? You have not explained what you want.

9. I still don't know what that shaded area is supposed to be. The area of triangle 0/-1,-1/0,-3/0 that happens to fall in the circle? That doesn't really do anything for us as far as finding "a point to lie on a circle".

Quzah.