View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Analytical intersection area between two circles

4.9 | 15 ratings Rate this file 15 Downloads (last 30 days) File Size: 3.51 KB File ID: #15899 Version: 1.0
image thumbnail

Analytical intersection area between two circles



10 Aug 2007 (Updated )

Compute the intersection area between 2 circles. The function allows to evaluate the intersection ar

| Watch this File

File Information

Compute the overlap area between 2 circles defined in an array Computation is vectorized, and intersection area are computed an analytical way.
Input: Circles data presented in an array G of three columns.
       G contains parameters of the n circles
          . G(1:n,1) - x-coordinate of the center of circles,
          . G(1:n,2) - y-coordinate of the center of circles,
          . G(1:n,3) - radii of the circles
       Each row of the array contains the information for one circle.

       Input can also be provided in three different vectors. These vectors can be row or column vectors. The 1st one corresponds to x-coordinate of the center of circles, the 2nd one to the y-cooridnate and the 3rd one to the radii of the circles.

Output: Square matrix M(n,n) containing intersection areas between circles
        M(i,j) contains the intersection area between circles i & j
        By definition, M(i,i) corresponds to the area of circle i.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
31 May 2016 Jaume Miro

Good work, it's a useful and easy to understand code, thanks!

19 Feb 2016 amal Mbarki

great work! but if i would like to calculate the intersection area of two ellipse in the same way,how the analytical equation became??

23 Nov 2015 Davide

Davide (view profile)

26 Sep 2015 Alexander Vakulenko


21 Jul 2011 S├ębastien MAILFERT

Good job! But, maybe a possibility to have ellipses and not circles will be helpful and really nice!

13 Apr 2011 Weiguang Ding

16 Jun 2009 John D'Errico

John D'Errico (view profile)

Hmm. I just noticed that my followup rating was shadowed out, and the original one remains. I'll see if I can't have the old rating removed.

16 Jun 2009 Osama

Osama (view profile)

very handy. thanks a lot !!

29 Apr 2009 Idillus

18 Nov 2008 M. A. Hopcroft

M. A. Hopcroft (view profile)

Works great, help file is good. Thanks!

08 May 2008 walid osamy

14 Aug 2007 Benjamin Le Blan

Great! Thanks!

13 Aug 2007 John D'Errico

Nicely cleaned up. My thanks to the author.

13 Aug 2007 Pierre Launay

Efficient, quick, neat

10 Aug 2007 John D'Errico

This is ok. It could be better. What could the author have done to improve it?

Think about the person using this code. What are the arguments? When you do help for the code, all it says about the input(s) is they can be in the form of an nx3 array, or as 3 vectors. WHAT ARE THE VECTORS? WHAT DO THEY MEAN? WHAT ORDER ARE THEY EXPECTED TO LIE IN? Give your user a hint. Is one of them the radius? Maybe its the square of the radius? Which one? While it might be obvious to the author, it is not at all so from the help.

The computation itself seems to be an efficient one, fairly carefully vectorized. although beware of trying to run this with several thousands of circles. You should expect memory problems.

I'd have liked to see more error checking. For example, one might check that the radii are all non-negative. This might catch some cases where the user has entered the vectors in the wrong sequence.

I also note that mlint flagged 8 lines. Minor points all, but worthwhile dealing with them.

Next, since the matrix of area intersections is symmetric, the author might have computed only an upper or lower triangle to save some time, then symmetrized it. The diagonal is trivial of course. I don't know if this would be a gain or not.

Finally, this is one of those codes where you as an author can expect to see people asking for an explanation of how it works. Yes, an assiduous reader can work it out from the code and the internal comments, but it might be worthwhile to include that explanation, rather than just the blanket statement that the area is computed analytically.

I'll be happy to upgrade my rating if improvements are made to this code.

13 Aug 2007

Some comments were added to ease the use of the function. Precise description of the user inputs is described.
Some argument verifications are also performed.
Finally, the number of calculations has been divided by two.

Thanks John D'Errico!

13 Aug 2007

Some explanations, comments were added. Input arguments are detailed.
Verifications of input arguments are performed.
The number of calculations has been divided by two.

Thanks John D'Errico

Contact us