Dies ist eine alte Version des Dokuments!
class Wedge(object): def __init__(self,a,b,c,alpha): self.a=a self.b=b self.c=c self.alpha=alpha def __repr__(self): return "W["+str(self.a)+",\t"+str(self.b)+",\t"+str(self.c)+"]" def selfplot(self,knotenliste): plt.plot([knotenliste[self.a].koords[0],knotenliste[self.b].koords[0],knotenliste[self.c].koords[0]], [knotenliste[self.a].koords[1],knotenliste[self.b].koords[1],knotenliste[self.c].koords[1]]) fig.canvas.draw() plt.pause(0.01) def getWedges(knotenliste): from operator import itemgetter,attrgetter allWedges=[] for knoten in knotenliste: orderedconnections=[] anzahl_nachbarn=0 for nachbar in knoten.nachbarn: alpha=np.arctan2(nachbar.koords[1]-knoten.koords[1], nachbar.koords[0]-knoten.koords[0]) if alpha<0: alpha+=2*math.pi orderedconnections.append([ nachbar.selfindex, alpha]) anzahl_nachbarn+=1 orderedconnections.sort(key=itemgetter(1)) for i in range(anzahl_nachbarn): this=orderedconnections[i-1] afterthis=orderedconnections[i] neueswedge=Wedge(this[0],knoten.selfindex,afterthis[0],this[1]-afterthis[1]) allWedges.append(neueswedge) allWedges.sort(key=attrgetter('a','b')) return allWedges def getPolygons(wedgeliste,knotenliste): from bisect import bisect_left as search allpolygons=[] def search(x): s1=x.b s2=x.c for wedge in wedgeliste: if wedge.a==s1 and wedge.b==s2: return wedge while len(wedgeliste)>0: start=x=wedgeliste[0] currentpolygon=[] while True: currentpolygon.append(x.a) x=search(x) if x is not None: wedgeliste.remove(x) if x is start: allpolygons.append(currentpolygon) break return allpolygons