Commit 54fea7b4 by ronan

BreakPoint à corriger

parent 8a66719c
 from Node import Node from Vector3D import Vector3D import math class BeachLine: def __init__(self): self.dico = {} self.root = None def insert(self, p0): pass \ No newline at end of file if self.root is None: self.root = Node(p0) else: self.root.insert(p0)
 ... ... @@ -36,17 +36,17 @@ class Fortune: x1 = p1.point.getX(); x1_2 = x1*x1; x2 = p2.point.getX(); x2_2 = x2*x2; x3 = p3.point.getX(); x3_2 = x3*x3; y1 = p1.point.getY(); y1_2 = y1*y1; y2 = p2.point.getY(); y2_2 = y2*y2; y3 = p3.point.getY(); y3_2 = y3*y3; #First part # First part h = x2_2 + y2_2 - (y1_2 + x1_2) b = 2*(x2 - x1) a = (y1 - y2) #Second Part # Second Part f = x3_2 + y3_2 - (y1_2 + x1_2) d = 2*(y3 - y1) e = (x1 - x3) #Determine Center # Determine Center x = ((2*a*f/d) + h)/(b*(1-(4*a*e/(d*b)))) y = (2*x*e + f)/d ... ... @@ -57,6 +57,51 @@ class Fortune: vSite = VSite(minY, center) return vSite def computeBreakPoint(self, p1, p2, ly): x1 = p1.point.getX(); x1_2 = x1*x1; x2 = p2.point.getX(); x2_2 = x2*x2; y1 = p1.point.getY(); y1_2 = y1*y1; y2 = p2.point.getY(); y2_2 = y2*y2; ly_2 = ly*ly; # First part h = x1_2 + y1_2 + ly_2 e = 2*(y1 - ly) # Second Part a = 2*(x2 - x1) b = 2*(y2 - y1) c = x1_2 + y1_2 - x2_2 - y2_2 d = (a - 2*((x1*b)/e)) f = (((h*b)/e) + c) delta = -(d*d - 4*b/e*f) x = 0 y = 0 print(delta) assert(delta >= 0) if delta > 0.00001: x = -d/(2*b/e) y = (x*x - 2*x1*x + h)/e else: xa = (-d + math.sqrt(delta))/(2*b/e) xb = (-d - math.sqrt(delta))/(2*b/e) # On prend entre les deux ya = (xa*xa - 2*x1*xa + h)/e yb = (xb*xb - 2*x1*xb + h)/e if (ya >= y1 and ya <= y2) or (ya <= y1 and ya >= y2): x = xa y = ya else: x = xb y = yb breakPoint = Vector3D(x, y) return breakPoint def insertBeachLine(self, p0): pass ... ...
Node.py 0 → 100644
 class Node: def __init__(self, site): self.site = site self.left = None self.right = None self.value = 0 self.stop = False def insert(self, p0): magnL = 0 magnR = 0 if self.left is not None: magnL = self.left.getMagn() if self.right is not None: magnR = self.right.getMagn() if magnL < magnR: self.left.insert def getY(self): return self.site.point.getY() def getMagn(self, site): v = site.point - self.site.point return v.getMagnitude() \ No newline at end of file
 ... ... @@ -110,6 +110,16 @@ if __name__ == "__main__": canvas.pack() fenetre.mainloop() """ def draw_Pol(screen, p, y): fac = 10 a = p.getY()*p.getY() - y*y b = (2*(y - p.getY())) for x in range(500): x1 = x + p.getX() - 250 h = (p.getX() - x1)*(p.getX() - x1) + a y1 = -h/b screen.create_oval(x1 - 1, y1 - 1, x1 + 1, y1 + 1, fill='black') if __name__ == "__main__": fenetre = Tk() canvas = Canvas(fenetre, width=800, height=800, background='white') ... ... @@ -134,9 +144,19 @@ if __name__ == "__main__": #canvas.bind("", clavier) ly = 100 f = Fortune(vec) p = [f.sites[4], f.sites[5]] for i in p: i.point.draw(canvas) draw_Pol(canvas, i.point, ly) a = f.computeBreakPoint(p[0], p[1], ly) a.draw(canvas) print(a) canvas.create_line(0, ly, 500, ly) canvas.pack() fenetre.mainloop()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!