Integral bounding below a curve by X and Y

47 Views Asked by At

The problem I'm having is setting up a basic double integral in order to rasterize (display curves as squares to be displayed by pixels from a computer). For example, if I wanted to know the area of a circle of radius 3 where x=[1,2] and y=[2,3], I would think setting up the integral would be as easy as

$$\int_{1}^{2} \int_{2}^{\sqrt{9-x^2}} 1dydx$$

or

$$\int_{1}^{2} \int_{2}^{3} x^2+y^2-9dydx$$

but I can't seem to get a reasonable answer. My end goal is to repeat this process and find the area under the circle(and eventually any other curve) in each unit square on the x-y coordinate system so I may pixelize these shapes. Any help would be great.

2

There are 2 best solutions below

0
On BEST ANSWER

There are actually a few integrals involved in this problem to cover multiple cases. Take a circle at radius 4 so we can hit all 4 of these cases.

Case 1: [3,4]x[0,1]

The curve crosses our unit square and inbeetween only 1 of our bounds either our X bound OR our Y bounds. In this case the integral can be set up like so: $$\int_{0}^{1} \int_{3}^{\sqrt{16-x^2}} 1dydx$$

Case 2: [2,3]x[2,3]

The curve crosses our unit square but does not cross either of our bounds. In this case the integral can be set up like so: $$\int_{2}^{\sqrt{16-3^2}} \int_{2}^{3} 1dydx + \int_{\sqrt{16-3^2}}^{3} \int_{2}^{\sqrt{16-x^2}}1dydx$$

Case 3: [1,2]x[2,3]

The curve does not cross our unit square and is contained between x and y bounds. This simply means that the entire unit square is filled so it would be pointless to set up an integral since our answer would be equal to 1.

$$1$$

Case 4: [0,1]x[4,5]

The curve does not cross our unit square and is not contained between x and y. This simply means that the entire unit square is not filled so it would be pointless to set up an integral since our answer would be equal to 0.

$$0$$

To do this all the way around the circle you would simply have to switch the bounds and multiply your values by -1 depending on what quadrant you're integrating in.

Ex: [-3,-3]x[0,1]

$$\int_{-1}^{0} \int_{3}^{\sqrt{16-x^2}} 1dydx$$

Ex: [-2,-3]x[2,3]

$$\int_{-\sqrt{16-3^2}}^{-2} \int_{2}^{3} 1dydx + \int_{-3}^{-\sqrt{16-3^2}} \int_{2}^{\sqrt{16-x^2}}1dydx$$

Of course in a circle these integrals are equal to their quadrant 1 counter parts but if a brute force algorithm this would be very handy and if a more complex curve was used to integrate under this would not be the case.

3
On

I will say that this procedure will be very hard and very piecewise depending on the kind of pixel we have.

If the pixel is completely contained in the circle, it's just the area of that pixel.

If the pixel intersects the square, we have problems. It will almost certainly not be possible to write the integral as one integral. To give an example:

Suppose the intersection hit the top and right walls of the pixel. Take $x^2+y^2=16$ and consider the pixel $[2,3]\times [2,3]$ Then the double integral that captures this area is

$$\int_2^{\sqrt{7}} \int_2^3 dy dx + \int_{\sqrt{7}}^3 \int_2^{\sqrt{16-x^2}} dydx$$

It is doable, but incredibly annoying to compute every single intersection and figure out not only what the bounds should be, but in which direction the integral should be done first to make it easiest.