std::size_t Winding_Opposite(const Winding& winding, const std::size_t index, const std::size_t other) { ASSERT_MESSAGE(index < winding.numpoints && other < winding.numpoints, "Winding_Opposite: index out of range"); double dist_best = 0; std::size_t index_best = c_brush_maxFaces; Ray edge(ray_for_points(winding[index].vertex, winding[other].vertex)); for(std::size_t i=0; i<winding.numpoints; ++i) { if(i == index || i == other) { continue; } double dist_squared = ray_squared_distance_to_point(edge, winding[i].vertex); if(dist_squared > dist_best) { dist_best = dist_squared; index_best = i; } } return index_best; }
std::size_t Winding::opposite(const std::size_t index, const std::size_t other) const { ASSERT_MESSAGE(index < size() && other < size(), "Winding::opposite: index out of range"); double dist_best = 0; std::size_t index_best = c_brush_maxFaces; Ray edge(ray_for_points((*this)[index].vertex, (*this)[other].vertex)); for (std::size_t i=0; i < size(); ++i) { if (i == index || i == other) { continue; } double dist_squared = ray_squared_distance_to_point(edge, (*this)[i].vertex); if (dist_squared > dist_best) { dist_best = dist_squared; index_best = i; } } return index_best; }