예제 #1
0
def line_inter_test(p1x, p1y,
                    p2x, p2y,
                    p3x, p3y,
                    p4x, p4y):
    print 'test if line ((' + str(p1x) + ', ' + str(p1y) + '), (' +\
          str(p2x) + ', ' + str(p2y) + ')), ((' + str(p3x) + ', ' + str(p3y) + '), (' + \
          str(p4x) + ', ' + str(p4y) + ')) intersects'
    pa = Point()
    pb = Point()
    pc = Point()
    pd = Point()
    l1 = Line()
    l2 = Line()
    pa.set_coord(p1x, p1y)
    pb.set_coord(p2x, p2y)
    pc.set_coord(p3x, p3y)
    pd.set_coord(p4x, p4y)
    l1.set_line_by_point(pa, pb)
    l2.set_line_by_point(pc,pd)
    return l1.do_lines_intersect(l2)
예제 #2
0
from line import Line
from line import Point

print 'testing line'

print 'testing line is set...'
l = Line()
print 'test not set'
assert not l.line_is_set()
l.set_line_by_coord(0, 0, 1, 1)
print 'test set'
assert l.line_is_set()
l = Line()
p1 = Point()
p2 = Point()
l.set_line_by_point(p1, p2)
print 'test setting by point not set'
assert not l.line_is_set()
p1.set_coord(0, 0)
p2.set_coord(1, 1)
assert l.line_is_set()
print 'test line with same start and end'
p2.set_coord(0, 0)
assert not l.line_is_set()

print 'testing get line...'
l = Line()
p1 = Point()
p1.set_coord(0, 0)
p2 = Point()
p2.set_coord(1, 1)