def addExit1(self, path): q = self.quadrant (x, y) = path[-1].p1 (xStr, yStr) = path[0].p0 r = self.leadRadius if q == XPLUS: if y > yStr: y += r a0 = 180 a1 = 270 direction = CW ex = 0 else: y -= r a0 = 90 a1 = 180 direction = CCW ex = 1 elif q == YPLUS: if x > xStr: x += r a0 = 180 a1 = 270 direction = CCW ex = 4 else: x -= r a0 = 270 a1 = 360 direction = CW ex = 5 elif q == XMINUS: if y > yStr: y += r a0 = 270 a1 = 360 direction = CCW ex = 2 else: y -= r a0 = 0 a1 = 90 direction = CW ex = 3 elif q == YMINUS: if x > xStr: x += r a0 = 90 a1 = 180 direction = CW ex = 6 else: x -= r a0 = 0 a1 = 90 direction = CCW ex = 7 dprt("exit %d direction %s" % (ex, oStr(self.cfg.dir))) l = Arc((x, y), r, a0, a1, direction=direction) path.append(l)
def addEntry1(self, path): q = self.quadrant (x, y) = path[0].p0 (xEnd, yEnd) = path[-1].p1 r = self.leadRadius if q == XPLUS: if y > yEnd: y += r a0 = 180 a1 = 270 direction = CCW en = 0 else: y -= r a0 = 90 a1 = 180 direction = CW en = 1 elif q == YPLUS: if x > xEnd: x += r a0 = 180 a1 = 270 direction = CW en = 4 else: x -= r a0 = 270 a1 = 360 direction = CCW en = 5 elif q == XMINUS: if y > yEnd: y += r a0 = 270 a1 = 360 direction = CW en = 2 else: y -= r a0 = 0 a1 = 90 direction = CCW en = 3 elif q == YMINUS: if x > xEnd: x += r a0 = 90 a1 = 180 direction = CCW en = 6 else: x -= r a0 = 0 a1 = 90 direction = CW en = 7 dprt("entry %d direction %s" % (en, oStr(self.cfg.dir))) l = Arc((x, y), r, a0, a1, direction=direction) path.insert(0, l)
def makePath(self, points, step, rNum, dbg=False): if False: r = 1 for i in range(4): a0 = float(i) * pi / 2 + pi / 4 a = a0 p0 = (r * cos(a), r * sin(a)) for j in range(2): tmp = (pi, -pi)[j] a = a0 + tmp / 2 p1 = (r * cos(a), r * sin(a)) a = a0 + tmp / 1 p2 = (r * cos(a), r * sin(a)) self.pointsArc(p0, p1, p2) dprt() sys.exit() numPoints = len(points) pLast = points[-1] i = 0 path = [] # points.append(points[0]) o0 = orientation(pLast, points[0], points[1]) if dbg: dprt("path orientation %s" % oStr(o0)) while i < numPoints: p0 = points[i] if dbg: dprt("i %3d (%7.4f %7.4f)" % (i, p0[0], p0[1])) d0 = xyDist(p0, pLast) j = i + 1 pa = p0 while j < numPoints - 1: pj = points[j] dist = xyDist(pa, pj) if abs(dist - d0) > 0.001: if dbg: dprt("dist %9.6f d0 %9.6f" % (dist, d0)) break j += 1 pa = pj delta = j - i if delta < 4: l = Line(pLast, p0, i) txt = "s %d r %d i %d" % (step, rNum, i) l.label(txt) i += 1 pLast = p0 else: p1 = points[i + delta / 2] (c, r) = self.pointsArc(pLast, p1, pa) o = orientation(pLast, p1, pa) if o != o0: (pLast, pa) = (pa, pLast) a0 = degAtan2(pLast[1] - c[1], pLast[0] - c[0]) a1 = degAtan2(pa[1] - c[1], pa[0] - c[0]) l = Arc(c, r, a0, a1, direction=o) if dbg: dprt("arc %s %2d i %d (%7.4f %7.4f) %8.3f "\ " %d (%7.4f %7.4f) %8.3f" % \ (oStr(o), delta, i, pLast[0], pLast[1], a0, \ j, pa[0], pa[1], a1)) i = j pLast = pa if dbg: l.prt() path.append(l) return(path)
def addExit(self, path): l = path[-1] (x, y) = l.p1 dx = x - l.p0[0] dy = y - l.p0[1] r = self.leadRadius if abs(x - self.trimX) < MIN_DIST: if self.xPlus: x += r if dy > 0: a0 = 90 a1 = 180 direction = CW ex = 0 else: a0 = 180 a1 = 270 direction = CCW ex = 1 else: x -= r if dy < 0: a0 = 270 a1 = 360 direction = CW ex = 2 else: a0 = 0 a1 = 90 direction = CCW ex = 3 elif abs(y - self.trimY) < MIN_DIST: if self.yPlus: y += r if dx < 0: a0 = 180 a1 = 270 direction = CW ex = 4 else: a0 = 270 a1 = 360 direction = CCW ex = 5 else: y -= r if dx > 0: a0 = 0 a1 = 90 direction = CW ex = 6 else: a0 = 90 a1 = 180 direction = CCW ex = 7 else: ePrint("error") return dprt("exit %d direction %s" % (ex, oStr(self.cfg.dir))) l = Arc((x, y), r, a0, a1, direction=direction) path.append(l)
def addEntry(self, path): l = path[0] (x, y) = l.p0 dx = x - l.p1[0] dy = y - l.p1[1] r = self.leadRadius if abs(x - self.trimX) < MIN_DIST: if self.xPlus: x += r if dy > 0: a0 = 90 a1 = 180 direction = CCW en = 0 else: a0 = 180 a1 = 270 direction = CW en = 1 else: x -= r if dy < 0: a0 = 270 a1 = 360 direction = CCW en = 2 else: a0 = 0 a1 = 90 direction = CW en = 3 elif abs(y - self.trimY) < MIN_DIST: if self.yPlus: y += r if dx < 0: a0 = 180 a1 = 270 direction = CCW en = 4 else: a0 = 270 a1 = 360 direction = CW en = 5 else: y -= r if dx > 0: a0 = 0 a1 = 90 direction = CCW en = 6 else: a0 = 90 a1 = 180 direction = CW en = 7 else: ePrint("addEntry error x %7.4f xTrim %7.4f y %7.4f yTrim %7.4f" % \ (x, self.trimX, y, self.trimY)) return dprt("entry %d direction %s" % (en, oStr(self.cfg.dir))) l = Arc((x, y), r, a0, a1, direction=direction) path.insert(0, l)