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

Function Intersect

libs/geometry/line2d.cpp:26–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26IntersectionResult Intersect(Line2D const & lhs, Line2D const & rhs, double eps)
27{
28 auto const & a = lhs.m_point;
29 auto const & ab = lhs.m_direction;
30
31 auto const & c = rhs.m_point;
32 auto const & cd = rhs.m_direction;
33
34 if (Collinear(ab, cd, eps))
35 {
36 if (Collinear(c - a, cd, eps))
37 return IntersectionResult(IntersectionResult::Type::Infinity);
38 return IntersectionResult(IntersectionResult::Type::Zero);
39 }
40
41 auto const ac = c - a;
42
43 auto const n = CrossProduct(ac, cd);
44 auto const d = CrossProduct(ab, cd);
45 auto const scale = n / d;
46
47 return IntersectionResult(a + ab * scale);
48}
49} // namespace m2

Callers 9

IntersectEdgeFunction · 0.70
ClipPathByRectImplFunction · 0.70
ForEachRectFunction · 0.70
IsIntersectMethod · 0.70
IntersectMethod · 0.50
UpdateSelectionInfoMethod · 0.50
operator()Method · 0.50
SegmentCrossesRectFunction · 0.50

Calls 3

CollinearFunction · 0.85
IntersectionResultClass · 0.70
CrossProductFunction · 0.70

Tested by 1

operator()Method · 0.40