本文介绍了Matlab:如何在边界框中找到一个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个散布在整个矩阵中的点或位置的阵列,矩阵内有一个小的边界框。我需要一种方法来检查数组中的点是否在边界框内。感谢您的建议。 BoundingBox = [BB1,BB2,BB3,BB4];
Array = [x1,y1; x2,y2; x3,y3; x4,y4; x5,y5; x6,y6];
我曾尝试
ismember([BB1,BB2,BB3,BB4],阵列);
和
ismember(矩形( '位置',[BB1,BB2,BB3,BB4]),阵列);
但是没有任何功能可用
解决方案
您应该阅读检查点是否在多边形内。
I have an array of points or locations that are scattered throughout a big matrix, and I have a small bounding box inside the matrix. I need a way to check if the points in the array are within the bounding box. Thanks for your suggestions.
BoundingBox = [BB1,BB2,BB3,BB4];
Array = [x1,y1;x2,y2;x3,y3;x4,y4;x5,y5;x6,y6];
I have tried
ismember([BB1,BB2,BB3,BB4],Array);
and
ismember(rectangle('Position',[BB1,BB2,BB3,BB4]),Array);
but nothing is working
解决方案
You should read ismember()
's documentation more carefully:
So, this check is related to set operations.
Instead, you should use inpolygon()
to check whether points are inside a polygon.
这篇关于Matlab:如何在边界框中找到一个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!