我如何找到两个未排序的x,y阵列中的区域?
我想发现在区域内部受到两个未排序阵列(x和y)的限制。 如果他们进行了排序,我只能按照此
theta = np.linspace(0, 2 * np.pi, num=1000, endpoint=True)
x = np.sin(theta)
y = np.cos(theta)
answer = np.trapz(y, x=x)
其中X和Y数组的正确排序以允许Trapz正确功能的方式(即使端点= false)。 但是,在我的数据中,X和Y没有分类。我想找到由X和Y包围的区域,如以下示例中所述:
theta = np.linspace(0, 2 * np.pi, num=1000, endpoint=True)
ii = np.arange(len(x))
np.random.shuffle(ii)
x = np.sin(theta)[ii]
y = np.cos(theta)[ii]
answer = np.trapz(y, x=x) #This no longer gives the correct integral.
是否有一种方法可以找到阵列所包围的区域而不按角度进行排序?它不必使用trampz。谢谢
I want to find the are inside the region limited by two unsorted arrays (x and y).
If they were sorted, I could just follow this example:
theta = np.linspace(0, 2 * np.pi, num=1000, endpoint=True)
x = np.sin(theta)
y = np.cos(theta)
answer = np.trapz(y, x=x)
In which the x and y array are correctly sorted in a way that allows trapz to correctly function (even if endpoint=False).
However, in my data x and y are not sorted. I would like to find the area enclosed by x and y as given in the following example:
theta = np.linspace(0, 2 * np.pi, num=1000, endpoint=True)
ii = np.arange(len(x))
np.random.shuffle(ii)
x = np.sin(theta)[ii]
y = np.cos(theta)[ii]
answer = np.trapz(y, x=x) #This no longer gives the correct integral.
Is there a way to find the area enclosed by the arrays without sorting by angular position? It doesn't have to be using trampz. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尚未尝试但最终简单地通过角位置对点进行排序,并在(假设点实际包围了一个表面)只是使用陷阱集成。我在此答案中包括我使用的方法。
I have yet to try Convex Hull, but ended up simply sorting the points by angular position and (under the assumption that points actually enclose a surface) just integrated using trapz. I include in this answer the method I used.