Area moments of parts of a rectangle divided by a line

90 Views Asked by At

I want to calculate the areas (and possibly their first and second moments) of a rectangle split into two parts by a line. It would be very helpful for me if there're closed form expressions for this for the general case.

Here's a schematic of what I have - I know the equation of the line in terms of it's normal and offset and I know that the rectangle is centered at the origin. In the figure below, I want to find the areas (and moments) of the red and blue regions respectively.

enter image description here

Maybe the solution is something very simple that I'm missing, but I'll be thankful for any help possible for this. I know that this is an oft-encountered scenario in linear programming.