MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / getSegmentContainingPoint

Method getSegmentContainingPoint

src/Core/Transform/Polygon.cpp:203–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

LoadClassPolygonFunction · 0.80

Calls 6

getSegmentMethod · 0.95
isBetweenFunction · 0.85
make_optionalFunction · 0.85
sizeMethod · 0.45
distanceMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected