Find the area enclosed by a closed GeneralPath [du

2019-09-14 23:29发布

问题:

Possible Duplicate:
How to calculate the area of a java.awt.geom.Area?

I don't know how to start on this and I hope someone can help ?

I have a closed java.awt.geom.GeneralPath and I try to measure the square ( area in squarepixel ( point ^ 2 ) ).

回答1:

Because GeneralPath implements Shape, you can count the number times contains() is true for each pixel in the Rectangle returned by getBounds(). If need be, you can scale via the createTransformedShape() method of AffineTransform.



回答2:

You could use Green's theorem and do a contour integral to calculate the area. Integrate along the discretized path in a piecewise manner using Gauss quadrature.

This shows you how it works:

http://mathinsight.org/greens_theorem_find_area



标签: java geometry