Considering a polygon with n vertices as input.

enter image description here

I need to calculate the integral of the form \[\int_A p(y) dA \] where $p(y)$ is a piecewise polynomial function of $y$.

May be if I could find the expression $b(y)$ then the integral can be calculated by: $$\int_{0}^{y_\max} p(y) b(y) dy $$

The question is : "is there a straightforward method to find $b(y)$ given the coordinates of the polygon vertices? Or is there a simpler manner to calculate the integral above?"

  • 1
    $\begingroup$ Welcome Hafid! This looks like an application of Cavalieri's principle. You can calculate the (piecewise linear) function $b$ from the polygon's vertices after sorting them with respect to the $y$ coordinate. This should be the easiest way to evaluate the integral. (By the way, since this is a very mathematical question, it might be better suited for math stackexchange.) $\endgroup$
    – user9485
    Commented Jul 6, 2020 at 19:49
  • $\begingroup$ @Chris the Cavalieri's principle! I am not aware of this. I think I have to do some research with google. Thank you very much. $\endgroup$ Commented Jul 6, 2020 at 19:53
  • 1
    $\begingroup$ See this: computergraphics.stackexchange.com/questions/9943/… It's regarding degree 2 polynomials, but the procedure is similar minus the quadrature rule which won't work anymore. $\endgroup$
    – lightxbulb
    Commented Jul 6, 2020 at 21:34
  • 1
    $\begingroup$ Yes the approach I linked is more general. If you want something specific to your problem then you have to split your integration into slabs divided by horizontal lines passing through the vertices. Let at some $y$ the left edge be between $l_1, l_2$ and the right between $r_1, r_2$. Any point on $l_1l_2$ is given by $p(\lambda) = (1-\lambda)l_1 + \lambda l_2$. You need $x$ expressed in terms of $y$ though, so $\lambda = \frac{y-l_{1,y}}{l_{2,y}- l_{1,y}}$, and you can substitute that in the expression for $x$ to get $x_l(y)$. Do the same for the right edge, then $b(y) = \|x_l(y) - x_r(y)\|$. $\endgroup$
    – lightxbulb
    Commented Jul 7, 2020 at 16:39
  • 1
    $\begingroup$ Assuming that your polygon is convex, sort all of the vertices by $y$. Draw a line between the vertex with minimum $y$ and maximum $y$. All vertices to the left of this line will be considered on the left and all vertices to the right will be considered on the right. Start from the min $y$ vertex and walk along the left and right edges to get respectively the left and right edges. After you're done with 1 slab, move 1 vertex up (whichever's next in the ordering regardless if it is left or right). $\endgroup$
    – lightxbulb
    Commented Jul 7, 2020 at 17:27


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.