1
$\begingroup$

Let's say I've got a 2D region r=Region[Polygon[{{0,0},{1,0},{1,1}}]]. I can do integrals like Integrate[1,{x,y}\[Element]r], or Integrate[y,{x,y}\[Element]r], to calculate areas and area moments.

I'd like to do an integral like Integrate[c^2,{x}\[Element]r], where c is the height (ymax-ymin) of the region at a particular value of x.

Any ideas appreciated.

-David

$\endgroup$
0

1 Answer 1

3
$\begingroup$

You can define a height of a region as its intersection with a vertical line at $x$:

c[ℛ_Region][x_?NumericQ] := 
 ArcLength[RegionIntersection[ℛ, InfiniteLine[{x, 0}, {0, 1}]]]

Then compute its bounds and integrate:

ℛ = Region@Annulus[]
{{xmin, xmax}, {ymin, ymax}} = RegionBounds[ℛ];
NIntegrate[c[ℛ][x]^2, {x, xmin, xmax}]
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.