def _arc_arc_intersection(ipts, arc1, arc2): _cp1 = arc1.getCenter() _r1 = arc1.getRadius() _tempcirc1 = circle.Circle(_cp1, _r1) _cp2 = arc2.getCenter() _r2 = arc2.getRadius() _tempcirc2 = circle.Circle(_cp2, _r2) _ipts = [] _circ_circ_intersection(_ipts, _tempcirc1, _tempcirc2) if len(_ipts): # may have intersection points ... for _ip in _ipts: _cx, _cy = _cp1.getCoords() _x, _y = _ip _angle = math.atan2((_y - _cy), (_x - _cx)) * _rtd if _angle < 0.0: _angle = _angle + 360.0 if arc1.throughAngle(_angle): _cx, _cy = _cp2.getCoords() _angle = math.atan2((_y - _cy), (_x - _cx)) * _rtd if _angle < 0.0: _angle = _angle + 360.0 if arc2.throughAngle(_angle): ipts.append(_ip) _tempcirc1.finish() _tempcirc2.finish()
def _arc_cl_intersection(ipts, obja, objb): if isinstance(obja, arc.Arc): _arc = obja _cl = objb else: _arc = objb _cl = obja _cp = _arc.getCenter() _r = _arc.getRadius() _tempcirc = circle.Circle(_cp, _r) _ipts = [] _circ_cl_intersection(_ipts, _tempcirc, _cl) if len(_ipts): # may have intersection points ... _cx, _cy = _cp.getCoords() for _ip in _ipts: _x, _y = _ip _angle = math.atan2((_y - _cy), (_x - _cx)) * _rtd if _angle < 0.0: _angle = _angle + 360.0 if _arc.throughAngle(_angle): ipts.append(_ip) _tempcirc.finish()
def hatchtests(): p1 = point.Point(0, 0) p2 = point.Point(10, 0) p3 = point.Point(10, 10) p4 = point.Point(0, 10) s1 = segment.Segment(p1, p2) s2 = segment.Segment(p2, p3) s3 = segment.Segment(p3, p4) s4 = segment.Segment(p4, p1) l1 = layer.Layer('foo') l1.addObject(p1) l1.addObject(p2) l1.addObject(p3) l1.addObject(p4) l1.addObject(s1) l1.addObject(s2) l1.addObject(s3) l1.addObject(s4) # find_hatched_area(l1, hpx, hpy) p5 = point.Point(2.95, 3.95) l1.addObject(p5) c1 = circle.Circle(p5, 1) l1.addObject(c1)