Find the area enclosed by a closed GeneralPath [du

2019-09-14 23:53发布

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 ) ).

标签: java geometry
2条回答
混吃等死
2楼-- · 2019-09-15 00:07

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.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-09-15 00:13

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

查看更多
登录 后发表回答