Compute multiple Rectangles area intersect by a circle

343 Views Asked by At

I've a need to compute the area of single elements (dice) of a matrix like this:

https://i.stack.imgur.com/EKVSz.jpg

The matrix is composed by 'c' columns and 'r' rows and every element/rectangle has the same height and width of any other.

knowing the element (x,y) center, I can know if its vertex are: - All out of circle area - All inside the circle area or - Partially inside the circle area (ray = 75.000 micron)

My problem is how I can compute the area of dice that are intersectated by the circle and more in deep how I can can compute the area of the portion of dice dice inside the circle.

So, to make an example, to work on, I've a dice with

CenterX , CenterY               [  29870.4 ,  67144.9 ]
DieDimensionX, DieDimensionY    [  5430.52 ,  4320.54 ]
Coord of upper left corner (A)  [ 27155.14 , 69305.17 ]
Coord of upper rightcorner (B)  [ 32585.66 , 69305.17 ]
Coord of lower left corner (C)  [ 27155.14 , 64984.63 ]
Coord of lower right corner (D) [ 32585.66 , 64984.63 ]

For each coord I've computed the segment lenght from axis origin and 1 corner (on 4) is out of circle:

sqrt( (x^2) + (y^2) )

A: 74435.261920332
B: 76583.495783129    == >75.000 
C: 70430.133924738
D: 72696.81818259

Which is the area of this dice inside the circle? Or else: which is the percentage of the area of dice inside the reticule compared with a full dice? I've read something about 'Simpson rule' that could help me but I don't know (a) if this is the correct approach (b) neither how to apply it on my example.

Thanks to anyone that would be able to help me.

Ciao, Stefano