Given two circles:
- C1 at (
x1
,y1
) withradius1
- C2 at (
x2
,y2
) withradius2
How do you calculate the area of their intersection? All standard math functions (sin
, cos
, etc.) are available, of course.
Given two circles:
x1
, y1
) with radius1
x2
, y2
) with radius2
How do you calculate the area of their intersection? All standard math functions (sin
, cos
, etc.) are available, of course.
You might want to check out this analytical solution and apply the formula with your input values.
Another Formula given here -
Okay, using the Wolfram link and Misnomer's cue to look at equation 14, I have derived the following Java solution using the variables I listed and the distance between the centers (which can trivially be derived from them):
Here is a JavaScript function that does exactly what Chris was after:
However, this method will return NaN if one circle is completely inside the other, or they are not touching at all. A slightly different version that doesn't fail in these conditions is as follows:
I wrote this function by reading the information found at the Math Forum. I found this clearer than the Wolfram MathWorld explanation.
Here here i was making character generation tool, based on circle intersections... you may find it useful.
with dynamically provided circles:
Check FULL fiddle... FIDDLE