text
stringlengths 0
93.6k
|
---|
speed = 1
|
if speed == 0:
|
speed = 1
|
endTime = time.time_ns()
|
totalTime = endTime - startTime
|
delayUS = (1000000.0 / speed) - totalTime
|
if delayUS < 10000.0:
|
delayUS = 10000
|
self.w.after(int(delayUS / 1000), self.Animate)
|
def Reset(self):
|
for fp in self.footprints:
|
fp.Reset()
|
def Start(self):
|
self.Animate()
|
self.w.mainloop()
|
class Nets:
|
def __init__(self):
|
self.nets = []
|
self.netnames = {}
|
def Load(self, nets):
|
#net format: net number, name, count, checked
|
activenets = 0
|
for i, net in enumerate(nets):
|
if net[2] > 1:
|
self.netnames[nets[i][1]] = []
|
def calc_electron(self, pos1, pos2):
|
# return [0,0]
|
dx = pos2[0] - pos1[0]
|
dy = pos2[1] - pos1[1]
|
distance = math.sqrt(dx ** 2 + dy ** 2)
|
if distance == 0:
|
return [0, 0]
|
force = ELECTRON_CONSTANT # * distance
|
return [force * dx / (distance ** 2), force * dy / (distance ** 2)]
|
def calc_spring(self, pos1, pos2):
|
# return [0,0]
|
dx = pos2[0] - pos1[0]
|
dy = pos2[1] - pos1[1]
|
distance = math.sqrt(dx ** 2 + dy ** 2)
|
if distance == 0:
|
return [0, 0]
|
force = SPRING_CONSTANT # * distance
|
return [force * dx, force * dy]
|
def calc_torque(self, force, xy):
|
# return 0
|
distance = math.sqrt(xy[0] ** 2 + xy[1] ** 2)
|
torque = xy[0]*force[1] - xy[1]*force[0]
|
return torque * TORQUE_CONSTANT
|
def Calc(self, footprints, activenets):
|
for i1, fp1 in enumerate(footprints):
|
for i2, fp2 in enumerate(footprints):
|
if i1 != i2:
|
if footprints[i1].locked == False:
|
force = self.calc_electron(fp1.coord_current, fp2.coord_current)
|
footprints[i1].momentum[0] -= force[0]
|
footprints[i1].momentum[1] -= force[1]
|
for net in activenets:
|
for i, conn in enumerate(self.netnames[net]):
|
for e, conn in enumerate(self.netnames[net]):
|
if i != e:
|
pos1 = self.netnames[net][i]
|
pos2 = self.netnames[net][e]
|
if pos1[0] != pos2[0]:
|
if footprints[pos1[0]].locked == False:
|
xy1 = [sum(x) for x in zip(footprints[pos1[0]].anchors_rotated[pos1[1]], footprints[pos1[0]].coord_current)]
|
xy2 = [sum(x) for x in zip(footprints[pos2[0]].anchors_rotated[pos2[1]], footprints[pos2[0]].coord_current)]
|
force = self.calc_spring(xy1, xy2)
|
torque = self.calc_torque(force, footprints[pos1[0]].anchors_rotated[pos1[1]])
|
footprints[pos1[0]].momentum[0] += force[0]
|
footprints[pos1[0]].momentum[1] += force[1]
|
footprints[pos1[0]].momentum[2] += torque
|
for i, fp in enumerate(footprints):
|
footprints[i].momentum[0] *= DAMPING
|
footprints[i].momentum[1] *= DAMPING
|
footprints[i].momentum[2] *= DAMPING
|
def Associate(self, footprints):
|
for i_f, fp in enumerate(footprints):
|
for i_p, pad in enumerate(fp.nets):
|
if len(pad) > 1:
|
if pad[1] in self.netnames:
|
self.netnames[pad[1]].append([i_f, i_p])
|
class Footprint:
|
def __init__(self, mod = False):
|
self.coord_initial = [0,0,0]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.