Пример #1
0
 def __init__(self, ps, color=None):
     Shape.__init__(self, color)
     mn = min(enumerate(ps), key=lambda (i,v): (v.y, v.x))[0]
     self.vs = list(ps[mn:]) + list(ps[:mn])
     self.bound = Vector.union(*self.vs)
     self.half_planes = []
     for i in xrange(len(self.vs)):
         h = HalfPlane(self.vs[i], self.vs[(i+1) % len(self.vs)])
         self.half_planes.append(h)
Пример #2
0
 def __init__(self, a=1.0, b=1.0, c=0.0, d=0.0, e=0.0, f=-1.0, color=None):
     Shape.__init__(self, color)
     self.a = a
     self.b = b
     self.c = c
     self.d = d
     self.e = e
     self.f = f
     t = Transform(2 * a, c, 0, c, 2 * b, 0)
     self.center = t.inverse() * Vector(-d, -e)
     l1, l0 = quadratic(1, 2 * (-a - b), 4 * a * b - c * c)
     v = t.eigv()
     axes = [v[0] * ((l0 / 2) ** -0.5), v[1] * ((l1 / 2) ** -0.5)]
     self.bound = Vector.union(self.center - axes[0] - axes[1],
                               self.center - axes[0] + axes[1],
                               self.center + axes[0] - axes[1],
                               self.center + axes[0] + axes[1])