void Span::GetBox(CBox2D &box) { box.Insert(m_p); box.Insert(m_v.m_p); if(this->m_v.m_type) { // arc, add quadrant points Point vs = m_p - m_v.m_c; Point ve = m_v.m_p - m_v.m_c; int qs = GetQuadrant(vs); int qe = GetQuadrant(ve); if(m_v.m_type == -1) { // swap qs and qe int t=qs; qs = qe; qe = t; } if(qe<qs)qe = qe + 4; double rad = m_v.m_p.dist(m_v.m_c); for(int i = qs; i<qe; i++) { box.Insert(m_v.m_c + QuadrantEndPoint(i) * rad); } } }
bool CMole::Intersects(const CBox2D& _krBox) const { CCircle Bounds; Bounds.Initialise(m_vPosition, m_fRadius); return (_krBox.Intersects(Bounds)); }
static void zigzag(const CArea &input_a) { if(input_a.m_curves.size() == 0) { CArea::m_processing_done += CArea::m_single_area_processing_length; return; } one_over_units = 1 / CArea::m_units; CArea a(input_a); rotate_area(a); CBox2D b; a.GetBox(b); double x0 = b.MinX() - 1.0; double x1 = b.MaxX() + 1.0; double height = b.MaxY() - b.MinY(); int num_steps = int(height / stepover_for_pocket + 1); double y = b.MinY();// + 0.1 * one_over_units; Point null_point(0, 0); rightward_for_zigs = true; if(CArea::m_please_abort)return; double step_percent_increment = 0.8 * CArea::m_single_area_processing_length / num_steps; for(int i = 0; i<num_steps; i++) { double y0 = y; y = y + stepover_for_pocket; Point p0(x0, y0); Point p1(x0, y); Point p2(x1, y); Point p3(x1, y0); CCurve c; c.m_vertices.push_back(CVertex(0, p0, null_point, 0)); c.m_vertices.push_back(CVertex(0, p1, null_point, 0)); c.m_vertices.push_back(CVertex(0, p2, null_point, 1)); c.m_vertices.push_back(CVertex(0, p3, null_point, 0)); c.m_vertices.push_back(CVertex(0, p0, null_point, 1)); CArea a2; a2.m_curves.push_back(c); a2.Intersect(a); make_zig(a2, y0, y); rightward_for_zigs = !rightward_for_zigs; if(CArea::m_please_abort)return; CArea::m_processing_done += step_percent_increment; } reorder_zigs(); CArea::m_processing_done += 0.2 * CArea::m_single_area_processing_length; }
bool CWall::Intersects( const CBox2D& Box ) const { return Box.OverlapsLineSegment( m_Line.GetEnd0(), m_Line.GetEnd1() ); }
bool CMole::Intersects( const CBox2D& Box ) const { CCircle Bounds; Bounds.Initialise( m_vPosition, fMOLE_RADIUS ); return Box.Intersects( Bounds ); }
bool CBox2D::Intersect(CBox2D box1, CBox2D box2) { return !( box1.getX() > (box2.getX() + box2.getWidth()) || (box1.getWidth() + box1.getX() < box2.getX()) || (box1.getY() - box1.getHeight() > box2.getY()) || (box1.getY() < box2.getY() - box2.getHeight()) ); }