Any one can guide me how to do that?

Design a Circle class and write a function to determine if 2 circles intersect

Design a Circle class and write a function to determine if 2 circles intersect

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

http://www.krissteele.net/blogdetails.aspx?id=251

About the comment from jmcg above. I believe it is not quite correct.

First, we need to decide what "intersect" means. Because sometimes people mean that two circles "overlap". In this case the only condition is that two circles intersect if the distance between their centres is smaller than or equal to the sum of their radii.

If we are talking about circle line you may look at the example http://csharphelper.com/blog/2014/09/determine-where-two-circles-intersect-in-c/.

Note that the condition "Two circles intersect if the distance between their centers is smaller than or equal to the sum of their radii but also larger than or equal to the smaller circle's radius" is NOT correct. The second part of the condition should be something like: "but also larger than or equal to the difference of radii). I.e. a small circle can be inside a big one.

You may also note some cases from the link I gave above.

"If d > r0 + r1: The circles are too far apart to intersect.

If d < |r0 – r1|: One circle is inside the other so there is no intersection.

If d = 0 and r0 = r1: The circles are the same.

If d = r0 + r1: The circles touch at a single point.

Otherwise: The circles touch at two points."

The last case - circles are next to each other.

Obviously, they are missing one case: d = |r0 – r1|! Citcles are inside each other and have one point of intersection.

Hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialNo. Then you hadn't learned anything. You did it right.

/gustav

C#

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get every solution instantly with Premium.
Start your 7-day free trial.