Thread: Overlapping area of two circles

  1. #1
    Citizen of Awesometown the_jackass's Avatar
    Join Date
    Oct 2014
    Location
    Awesometown
    Posts
    269

    Overlapping area of two circles

    Hi all, I have a very simple question.

    Given the coordinates of centres and radii of two circles on the plane, I need to calculate the area of the overlapping region.

    I have made a formula but it seems to be giving wrong answers. Can I get an hint what is wrong with my formula?

    The derivation:

    Overlapping area of two circles-damn_circles-png

    The distance between the centres d is computed with the coordinates of centres. So we know all sides of the triangle (r1, r2 and d). alpha and beta are calculated with arccos and the cosine formula of triangle. Area of a segment is given by 1/2*r^2[theta - sin(theta)]. So I compute the segment areas of both circles and add them up...with theta = 2*alpha and 2*beta in each case.

    But this seems to be giving wrong results. For example with the following data:

    C1(-0.5,0), r1 = 1.0
    C2( 0.5,0), r2 = 1.0

    the answer is supposed to be approx. 5.0548 but my technique is giving 1.2284.

    Where am I making a mistake?
    "Highbrow philosophical truth: Everybody is an ape in monkeytown" --Oscar Wilde

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Computing the circular segments and adding them up should work. Maybe you implemented the algorithm wrong.
    Devoted my life to programming...

  3. #3
    Citizen of Awesometown the_jackass's Avatar
    Join Date
    Oct 2014
    Location
    Awesometown
    Posts
    269
    Oh okay.

    I got it.

    The problem asked to compute the area of the whole figure, whereas I'm just computing the area of the overlapping part.
    How did I not notice the area of overlap between two unit circles can never be more than pi? xD

    When I do area of circle 1 + area of circle 2 - overlapping area I get the correct answer.
    Last edited by the_jackass; 08-12-2016 at 11:13 AM.
    "Highbrow philosophical truth: Everybody is an ape in monkeytown" --Oscar Wilde

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Overlapping squares
    By Tobias Mihel in forum C++ Programming
    Replies: 2
    Last Post: 05-25-2013, 10:40 AM
  2. Replies: 4
    Last Post: 05-02-2012, 10:22 PM
  3. Overlapping Memory
    By hammer1234 in forum C Programming
    Replies: 1
    Last Post: 04-05-2006, 03:05 AM
  4. Overlapping arrays problem
    By earth_angel in forum C++ Programming
    Replies: 4
    Last Post: 07-05-2005, 09:19 AM
  5. Overlapping toolbars
    By minesweeper in forum Windows Programming
    Replies: 3
    Last Post: 06-14-2003, 11:26 PM

Tags for this Thread