I have two arrays of points with xy coordinates:
basic_pts = np.array([[0, 0], [1, 0], [2, 0], [0, 1], [1, 1], [0, 2]])
new_pts = np.array([[2, 2], [2, 1], [0.5, 0.5], [1.5, 0.5]])
As result I want from the array new_ptsonly those points, that fulfil the condition that there is no point in basic_ptswith a bigger x AND y value. So a result would be
res_pts = np.array([[2, 2], [2, 1], [1.5, 0.5]])
I have a solution which works but because of working with list comprehension it is not suitable for a bigger amount of data.
x_cond = ([basic_pts[:, 0] > x for x in new_pts[:, 1]])
y_cond = ([basic_pts[:, 1] > y for y in new_pts[:, 1]])
xy_cond_ = np.logical_and(x_cond, y_cond)
xy_cond = np.swapaxes(xy_cond_, 0, 1)
mask = np.invert(np.logical_or.reduce(xy_cond))
res_pts = new_pts[mask]
Is there a better way to solve this only with numpy and without list comprehension?