Ejemplo n.º 1
0
 def __init__(self, a, b, c, d):
     super(Trapezoid, self).__init__()
     self._rect_ab = Polygon.Rect.build_from(a, b)
     self._rect_bc = Polygon.Rect.build_from(b, c)
     self._rect_cd = Polygon.Rect.build_from(c, d)
     self._points = [a, b, c, d]
     self.interval = Interval(a[0], d[0])
 def __init__(self, a, b, c=None):
     super(Triangular, self).__init__()
     if c is None:
         c = (b[0] + (b[0] - a[0]), a[1])
     self._rect_ab = Polygon.Rect.build_from(a, b)
     self._rect_bc = Polygon.Rect.build_from(b, c)
     self._points = [a, b, c]
     self.interval = Interval(a[0], c[0])
 def __init__(self, x=0.0, y=1.0):
     """
     Initialize a singleton
     :param x: element with membership different of zero
     :param y: degree of membership for the x-element
     """
     super(Singleton, self).__init__(None, None)
     self.interval = Interval(x, x)
     self.x = x
     self.y = y
    def add_point(self, point):
        """
        Adds a point to polygon list of points in correct position
        :param point: new point to addition
        """
        X, Y = Polygon.X, Polygon.Y
        points = self._points

        for index, p in enumerate(self._points):
            if point[X] == p[X]:
                point = (point[X], max(point[Y], p[Y]))
                points[index] = point
                break
            if point[X] < p[X]:
                points.insert(index, point)
                break
        else:
            points.append(point)
            # self._lines = []

        self.interval = Interval(points[0][Polygon.X], points[-1][Polygon.X])
 def __init__(self, a, b, c):
     super(SFunction, self).__init__(None, None)
     self.interval = Interval(a[0], c[0])
     self.a = a
     self.b = b
     self.c = c
Ejemplo n.º 6
0
 def __init__(self, center, delta, min_=0, max_=1):
     super(PiFunction, self).__init__(None, Interval(center-delta, center+delta))
     self._center = center
     self._delta = delta
     self._min_ = min_
     self._max_ = max_
Ejemplo n.º 7
0
 def __init__(self, center, width, height=1):
     interval = Interval(center - width, center + width)
     super(Gaussian, self).__init__(None, interval)
     self.width = width
     self.center = center
     self.height = height
 def _quick_build_(points):
     p = Polygon()
     p.interval = Interval(points[0][Polygon.X], points[-1][Polygon.X])
     p._points = points
     return p