| 201 | } |
| 202 | |
| 203 | std::optional<PolygonSegment> Polygon::getSegmentContainingPoint( |
| 204 | const Transform::UnitVector& position, const double tolerance) |
| 205 | { |
| 206 | for (point_index_t i = 0; i < m_points.size(); i++) |
| 207 | { |
| 208 | const point_index_t nextNode = (i != m_points.size() - 1) ? i + 1 : 0; |
| 209 | const double lineLength = m_points[i]->distance(this->get(nextNode)); |
| 210 | const double firstLength = m_points[i]->distance(position); |
| 211 | const double secondLength = m_points[nextNode]->distance(position); |
| 212 | if (Utils::Math::isBetween(lineLength, firstLength + secondLength - tolerance, |
| 213 | firstLength + secondLength + tolerance)) |
| 214 | return std::make_optional(this->getSegment(i)); |
| 215 | } |
| 216 | return std::nullopt; |
| 217 | } |
| 218 | |
| 219 | PolygonPath& Polygon::getAllPoints() |
| 220 | { |
no test coverage detected