[Math] How to calculate a specific area inside a circle

circleseuclidean-geometrygeometry

I want to calculate the area displayed in yellow in the following picture:

circle area

The red square has an area of 1. For any given square, I'm looking for the simplest formula to compute the yellow area in this picture.

(Squares are actually pixels in an image processing software, and I need to compute the opacity of the given pixel based on the relative area of the circle compared to the area of the pixel, to create smooth rounded corners.)

Update: I need to be able to do that for any individual square in the image: also the orange and the green one, for example.

Best Answer

Well, I guess I'll take a stab at this. This is definitely a calculus problem. To take the area between two curves, you want to take the integral of the greater function minus the lesser function. For the yellow area, the greater function is $y=1$. The lesser function will take some manipulation. The formula for the circle is:

$(x-4)^2+(y-4)^2=16$

$(y-4)^2=16-(x-4)^2$

$y-4=-\sqrt{16-(x-4)^2}$

$y=4-\sqrt{16-(x-4)^2}$

So our integral is $\int^3_2[1-(4-\sqrt{16-(x-4)^2}]dx$=$\int^3_2-3dx+\int^3_2\sqrt{16-(x-4)^2}dx$. The first integral is $-3x$ evaluated from 2 to 3, or in other words, $-3(3)-[-3(2)]=-9+6=-3$.

For the second half of that integral, we'll use the info from Andreas's comment. We'll perform a change of variable

$u=x-4,du=dx$

$\int^3_2\sqrt{16-(x-4)^2}dx=\int^{-1}_{-2}\sqrt{16-u^2}du=\frac12[u\sqrt{16-u^2}+16sin^{-1}\frac u4]^{-1}_{-2}=\frac12[(x-4)\sqrt{16-(x-4)^2}+16sin^{-1}\frac{x-4}4]^3_2$

That solves the yellow area. For the other 2, you'll want to know where the 2 functions cross.

$(x-4)^2+(1-4)^2=16$

$(x-4)^2=7$

$x=4-\sqrt7$

For the green area, the 2 functions are the same, but it's evaluated from $4-\sqrt7$ to 2. For the orange area, the greater function is $y=2$, but the lesser function changes. It should be easy to see, though, that the right half is a rectangle. The left half is integrated from 1 to $4-\sqrt7$. Also, the first half of the integral has changed from $\int-3dx$ to $\int-2dx=-2x$. So the total orange area is $2x-\frac12[(x-4)\sqrt{16-(x-4)^2}+16sin^{-1}\frac{x-4}4]$ evaluated from 1 to $4-\sqrt7$ plus $1[2-(4-\sqrt7)]$, or $\sqrt7-2$.

Related Question