我想比较无人机的实际位置是否在任何列表中。 看看评论。我不知道如何搜索实际位置是否在所有创建的列表(k列表)的任何元素中。
actual_position是一个观点。
private void function()
{
int distance = 2;
for (int k = 0; k < drone.Length; k++)
{
//create a list of each drone and add the actual position
list[k].Add(actual_position);
//create multiple positions ( something like a safe area around actual_position based on distance
for (int i = (int)actual_position.X - distance; i <= (int)actual_position.X + distance; i++)
{
for (int j = (int)actual_position.Y - distance; j <= (int)actual_position.Y + distance; j++)
{
//add position to the list
list[k].Add(new PointF(i, j));
}
}
//if actual_position of a different drone == any element of list (all the lists k)
}
}
修改
基本上我把无人机的位置和安全区域放在它周围。例如,我不希望任何其他无人机进入那个安全区域。基本上如果actual_position ==列表中的任何元素(所有列表k)都停止移动。