std::vector<vsr::cga2D::Vec> Intersect(const Circle &circle, const LineSegment &segment) { auto C = ToDualCircle(circle); auto L = ToLine(segment); auto intersection = C <= L; auto size = vsr::nga::Round::size(intersection, false); // Point pair size is negative, no intersection points if(size < -1e-6f) { return std::vector<vsr::cga2D::Vec>{}; } // Get the intersection points auto split_pts = vsr::nga::Round::split(intersection); auto pt1 = vsr::cga2D::Vec(split_pts[0][0], split_pts[0][1]); auto pts = std::vector<vsr::cga2D::Vec>{}; if(LineSegmentContainsPoint(segment, pt1)) { pts.push_back(pt1); } // If the size of the point pair is above threshold, there // are 2 valid intersection points if(size > 1e-6) { auto pt2 = vsr::cga2D::Vec(split_pts[1][0], split_pts[1][1]); if(LineSegmentContainsPoint(segment, pt2)) { pts.push_back(pt2); } } return pts; }
std::vector<vsr::cga2D::Vec> Intersect(const LineSegment &segment1, const LineSegment &segment2) { auto L1 = ToLine(segment1); auto L2 = ToLine(segment2); // Intersection as a flat point (Flp) auto intersection = (L1.dual() ^ L2.dual()).dual(); // Check if the only intersection is the point at infinity if(std::abs(intersection[2]) <= 1e-6) { return std::vector<vsr::cga2D::Vec>{}; } // Check if the intersection point is withint the line segments auto pt = vsr::cga2D::Vec(intersection[0], intersection[1]) / intersection[2]; auto within1 = LineSegmentContainsPoint(segment1, pt); auto within2 = LineSegmentContainsPoint(segment2, pt); if(!within1 || !within2) { return std::vector<vsr::cga2D::Vec>{}; } return std::vector<vsr::cga2D::Vec>{pt}; }
bool CAsmFile::parse() { CNodeManageFile::Read(); ToLine(m_pData, m_len); delete m_pData; m_pData = NULL; bool bRet = true; bRet &= ParseBlockCMT(); bRet &= ParseLineCMT(); bRet &= ParseKeyword(); return bRet; }