# A circle in coordinate

#### ecjohnny

Joined Jul 16, 2005
142 I need to write a program to get a user input coordinate then check if it falls within the circle. (note: along the circle is consider a circle.)

My initial though was to compare the coords value of the circle( eg. if 3<x<9 and compare x also then is fall is the square.) then i am left with the diagram on the right of the attach pic 4 little sides.
my solution might be wrong coz the method of solving worth 2 marks only which i assume would be easy. the rest of marks is programming.

Anyone has a better solution or help?

#### MrChips

Joined Oct 2, 2009
21,867
Do you know how to calculate the distance of the point (x,y) from the origin (0,0)?
Do you know the equation of a circle f(x,y,r)?

#### djsfantasi

Joined Apr 11, 2010
6,806
You picture didn't show up. Try going to "Manage Attachments" to upload your picture. Is the circle center always at (0,0)? Do you know what polar coordinates are?

#### ecjohnny

Joined Jul 16, 2005
142
ok i'll upload a new pic soon. Anyway is is just finding if an entered coordinate is in a circle. and the circle is at the +x and +y (top right)

#### ecjohnny

Joined Jul 16, 2005
142
Do you know how to calculate the distance of the point (x,y) from the origin (0,0)?
Do you know the equation of a circle f(x,y,r)?
yes i know how to calculate the distance. x,y from origin.

But what does f(x,y,r) mean ?

#### steveb

Joined Jul 3, 2008
2,436
yes i know how to calculate the distance. x,y from origin.

But what does f(x,y,r) mean ?
He just wants you to consider the equation of a circle. You could also say the equation of a circle looks like R^2=f(x,y) which means that the points on the circle are such that when you plug any x and y coordinate for these points into the function f(x,y) the answer is the radius R squared.

You can actually solve this without thinking about the distance formula, although the distance formula in built into the equation for a circle. Basically the points inside the circle will obey the relation R^2 ? f(x,y). Where the ? indicates a relational operator; greater than, less than, greater than or equal and less than or equal (>, <, >= or <=). Can you tell which one? So, all you need is the relational operator ?, and the f(x,y) for the circle of interest. The only other circle parameters, other than the radius, are x0 and y0, which indicate the point of the center of the circle.