Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何计算 java.awt.geom.Area 的面积?
我不知道如何开始,希望有人能提供帮助?
我有一个封闭的java.awt.geom.GeneralPath,我尝试测量正方形(以squarepixel ( ) 为单位的面积)。point ^ 2
java.awt.geom.GeneralPath
point ^ 2
您可以使用格林定理并进行轮廓积分来计算面积。使用高斯求积以分段方式沿离散化路径积分。
这向您展示了它是如何工作的:
http://mathinsight.org/greens_theorem_find_area
因为GeneralPathimplements Shape,你可以计算返回的contains()每个true像素的次数。如果需要,您可以通过.RectanglegetBounds()createTransformedShape()AffineTransform
GeneralPath
Shape
contains()
true
Rectangle
getBounds()
createTransformedShape()
AffineTransform