示例#1
0
class wire:
    def __init__(self, left0, left1, right0, right1, planeNo, wireNo,
                 trueWireNo):
        self.leftBound = Line(left0, left1)
        self.rightBound = Line(right0, right1)
        self.planeNo = planeNo
        self.wireNo = wireNo
        self.trueWireNo = trueWireNo

    def rotate(self, angle):
        self.leftBound = self.leftBound.rotate(angle)
        self.rightBound = self.rightBound.rotate(angle)

    def translate(self, x, y):
        self.leftBound = self.leftBound.translate(x, y)
        self.rightBound = self.rightBound.translate(x, y)

    def doesIntersect(self, wire):
        ll = intersect(self.leftBound.points[0], self.leftBound.points[1],
                       wire.leftBound.points[0], wire.leftBound.points[1])
        lr = intersect(self.leftBound.points[0], self.leftBound.points[1],
                       wire.rightBound.points[0], wire.rightBound.points[1])
        rl = intersect(self.rightBound.points[0], self.rightBound.points[1],
                       wire.leftBound.points[0], wire.leftBound.points[1])
        rr = intersect(self.rightBound.points[0], self.rightBound.points[1],
                       wire.rightBound.points[0], wire.rightBound.points[1])
        # print(ll,lr,rl,rr)
        return ll and lr and rl and rr

    def __repr__(self):
        # return str([self.planeNo,self.wireNo,self.trueWireNo])
        return str([self.leftBound, self.rightBound])
示例#2
0
 def eval_end_pt_tang(self, first):
     trgt_pt = self.p0 if first else self.p1
     res_norm = Line(self.center, trgt_pt).direction.unit
     res_tang = res_norm.rotate(np.pi / 2.)
     halfpl = get_halfplane(self.p0, self.p1, self.center)
     if -1 == halfpl:
         res_tang = -res_tang
     return res_tang
示例#3
0
 def eval_pt_tang(self, arc_len):
     try:
         full_len = self.get_length()
         weight = arc_len / full_len
         res_cntr_angle = float(weight * self.central_angle)
         halfpl = get_halfplane(self.p0, self.p1, self.center)
         if -1 == halfpl:
             res_cntr_angle = -res_cntr_angle
         res_pt = self.p0.rotate(res_cntr_angle, self.center)
         res_norm = Line(self.center, res_pt).direction.unit
         res_tang = res_norm.rotate(halfpl * np.pi / 2.)
     except Exception as e:
         res_pt = Point(
             0.,
             0.,
         )
         res_tang = Point(
             0.,
             0.,
         )
     return res_pt, res_tang
inputwidth = float(input("Enter width of the route:"))
xaxis = Line((0, 0), (1, 0))
yaxis = Line((0, 0), (0, 1))
mintime = float('inf')
optimalangle = 0
for angle in range(0, 180, 90):
    angle = float(angle)
    rboundary = boundary.rotate(angle / 180 * math.pi)
    bounds = rboundary.bounds
    cutnum = float(
        math.ceil(
            round((round(bounds[2], 6) - round(bounds[0], 6)) / inputwidth,
                  6)))
    width = (round(bounds[2], 6) - round(bounds[0], 6)) / cutnum
    waypoint = createallwaypoint(rboundary)
    rentrance = Entrance.rotate(angle / 180 * math.pi)
    rexit = Exit.rotate(angle / 180 * math.pi)
    time = timeconsume(waypoint, rentrance, rexit)
    if (time < mintime):
        mintime = time
        optimalangle = angle
rboundary = boundary.rotate(optimalangle / 180 * math.pi)
bounds = rboundary.bounds
cutnum = float(
    math.ceil(
        round((round(bounds[2], 6) - round(bounds[0], 6)) / inputwidth, 6)))
width = (round(bounds[2], 6) - round(bounds[0], 6)) / cutnum
waypoints = createallwaypoint(rboundary)

rwaypoints = []
for i in range(len(waypoints)):