找出曲线是在python边界内还是在边界外.具有不同分辨率的X轴(python) [英] Finding out if a curve is inside or outside a boundary in python. X axis with different resolutions (python)

查看:99
本文介绍了找出曲线是在python边界内还是在边界外.具有不同分辨率的X轴(python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个1000x1列表,组成两个边界(上下边界).我也有74条具有(x,y)大小变化的曲线(大约80000x1),我想找到一种方法来检查曲线(蓝色)是否完全在边界(红色区域)内.

I've two 1000x1 lists composing two boundaries (upper and lower). I've as well 74 curves with varying dimensions of (x,y) (around 80000x1) and I would like to find a way to check if the curve (blue) is entirely inside the boundaries (red area).

我一直在寻找用于不同x,y分辨率的曲线交叉/相交算法,但找不到任何方法.

I've been searching for curves crossing/intersection algorithms for different x,y resolutions but couldn't find any.

您是否知道如何处理此问题?

Would you have any idea how to deal with this problem?

推荐答案

理想情况下,您希望为红色区域中的每个坐标设置y值列表.然后,您需要检查曲线的每个数据点y坐标,以及红色区域Xmin< = x< =红色区域X max之间的x坐标.如果所有数据点y坐标都在列表中,那么您知道曲线在红色区域内,如果数据点y坐标之一不在红色区域内,那么您知道某些曲线在红色区域之外.

Ideally, you'd want to set up a list of y values for each co-ordinate in the red area. Then you'd want to check every data point y co-ordinate of the curve with x co-ordinate between red area Xmin <= x <= red area X max. If all the data point y coordinates are in the list, then you know the curve is inside the red area, if one of the data point y coordinates isn't, then you know that some of the curve is outside of the red area.

 red_area_yvals = [y1, y2, y3, y4, y5, ...]
 red_area_xmin = x1
 red_area_xmax = xmax
 curvecoordinates = [[a1,b1],[a2,b2],....]
 check=True

 for coord in curvecoordinates:
     if  coord[0] >= red_area_xmin and coord[0] <= red_area_xmax:
         if coord[1] in red_area_yvals:
             continue 
         else:
             check=False
             break
    
if check:
     print("fully in")
else:
     print("not fully in")

如果红色区域是一个完美的矩形,则可以使用,对于更复杂的红色区域,我会考虑同时检查x和y的组合,而不仅仅是检查y.

edit: if the red area was a perfect rectangle this would work, for a more complex red area I would think about checking both combination of x and y rather than just y.

第二次可能有一种积分方法(例如,曲线下方的区域,将红色区域底部下方的区域从y = 0取走,然后对曲线上方的区域进行相同的操作,然后将两者进行比较),但是这超出了我的数学能力,在Python中还无法处理复杂的曲线.

2nd edit: There is probably a way of doing this with integration (i.e areas under the curve, taking away the area from under bottom of the red area to y=0 then doing the same for above the curve and comparing the two) but that is beyond my mathematical ability and in Python for complex curves.

这篇关于找出曲线是在python边界内还是在边界外.具有不同分辨率的X轴(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆