Ramer–Douglas–Peucker algorithm in 3D