Пример #1
0
def dst(p, l):
    """Distance from a point to a line."""
    (x, y), (a, b, c) = p, ransac.points_to_line(*l)
    return abs(a * x + b * y + c) / sqrt(a*a+b*b)
Пример #2
0
 def get(self, sample):
     if len(sample) == 2:
         return ransac.points_to_line(*sample)
     else:
         return ransac.least_squares(sample)
Пример #3
0
class Line:
    """Line with a list of important points that lie on it.

    This and the Point class in this module serves to implement a model of
    perspective plain -- a line has a list of intersections with other lines and
    each intersection has two lines that go through it.
    """

    def __init__(self, (a, b, c)):
        self.a, self.b, self.c = (a, b, c)
        self.points = []

    @classmethod
    def from_ad(cls, (a, d), size):
        p = linef.line_from_angl_dist((a, d), size)
        return cls(ransac.points_to_line(*p))

    def __iter__(self):
        yield self.a
        yield self.b
        yield self.c

    def __len__(self):
        return 3

    def __getitem__(self, key):
        if key == 0:
            return self.a
        elif key == 1:
            return self.b
        elif key == 2: