簡體   English   中英

Python 計算不規則彎曲多邊形的面積

[英]Calculating Area of Irregular Curved Polygon in Python

我知道圖像中顯示的藍點的 x、y 坐標。 如何計算以這些點為界的不規則形狀的面積? 上表面和下表面的點數不同

圖片

正如@Fractalism 所建議的,您可以使用 Schoelace 公式。 這是使用 Numpy 的 python 的實現。我從這里獲取它:

import numpy as np
# x,y are arrays containing coordinates of the polygon vertices
x=np.array([3,5,12,9,5]) 
y=np.array([4,11,8,5,6]) 
i=np.arange(len(x))
#Area=np.sum(x[i-1]*y[i]-x[i]*y[i-1])*0.5 # signed area, positive if the vertex sequence is counterclockwise
Area=np.abs(np.sum(x[i-1]*y[i]-x[i]*y[i-1])*0.5) # one line of code for the shoelace formula

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM