I am trying to have my code detect horizontal planes in order to find the floor. My floor is the biggest horizontal surface below the device at starting point. My current algorithm is working to find the biggest horizontal plane and identifies it as floor, but it also counts the ceiling as a horizontal plane - which it shouldn't. I have been looking around for a way around this, but no dice.
Any help is appreciated.
This is my code:
var areas = [Float]()
for grid1 in grids {
let a = grid1.planeGeometry.width * grid1.planeGeometry.height
areas.append(Float(a))
}
for grid2 in grids {
let area = grid2.planeGeometry.width * grid2.planeGeometry.height
if (Float(area)==areas.max()) {
grid2.floored(state: true)
} else {
grid2.floored(state: false)
}
}
EDIT
To clarify the definition of the floor, it is the biggest, lowest plane detected from the device's initial starting point. So, for example, if two planes (say a carpet and the floor itself) are detected separately and are of the same size, the lower one would be the floor. But, if the carpet covers more space then it is the floor.