I have a 10x10 grid of circles(similar) in which lies a random point.

I need to display in which circle is the point. The attributes of the circle and point are : id(int) and position(Point2D).

Could some one help me with this please?

Printable View

- 07-02-2008, 10:11 PMnidhirastogiIn which circle is the Point lying?
I have a 10x10 grid of circles(similar) in which lies a random point.

I need to display in which circle is the point. The attributes of the circle and point are : id(int) and position(Point2D).

Could some one help me with this please? - 07-02-2008, 11:12 PMNorm
Write a class for the circle (x,y,r). Add a method contains() that takes a point (x,Y) and computes if that point is in the circle.

The logic would be a bit of trig. Or use Pythagorian's rule to see if the distance from the center to the point is less than the radius.

Make a list of all the circles and call each circle to see which one contains the point.