MCPcopy Create free account
hub / github.com/comaps/comaps / Intersect

Function Intersect

libs/geometry/segment2d.cpp:51–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51IntersectionResult Intersect(Segment2D const & seg1, Segment2D const & seg2, double eps)
52{
53 if (!SegmentsIntersect(seg1.m_u, seg1.m_v, seg2.m_u, seg2.m_v))
54 return IntersectionResult(IntersectionResult::Type::Zero);
55
56 Line2D const line1(seg1);
57 Line2D const line2(seg2);
58 auto const lineIntersection = Intersect(line1, line2, eps);
59 if (lineIntersection.m_type != IntersectionResult::Type::One)
60 return lineIntersection;
61
62 if (IsPointOnSegmentEps(lineIntersection.m_point, seg1.m_u, seg1.m_v, eps) &&
63 IsPointOnSegmentEps(lineIntersection.m_point, seg2.m_u, seg2.m_v, eps))
64 {
65 return lineIntersection;
66 }
67
68 return IntersectionResult(IntersectionResult::Type::Zero);
69}
70
71std::string DebugPrint(Segment2D const & segment)
72{

Callers

nothing calls this directly

Calls 3

SegmentsIntersectFunction · 0.85
IsPointOnSegmentEpsFunction · 0.85
IntersectionResultClass · 0.70

Tested by

no test coverage detected