コード例 #1
0
def test_side_of_line_left():
    x1, y1 = ( 0, 0)
    x2, y2 = (10,10)

    Px, Py = (5, 10)
    assert side_of_line(x1, y1, x2, y2, Px, Py) > 0 # left of line is > 0

    Px, Py = (-0.000001, 0.0)
    assert side_of_line(x1, y1, x2, y2, Px, Py) > 0 # left of line is > 0

    Px, Py = (4.9999999999, 5.0)
    assert side_of_line(x1, y1, x2, y2, Px, Py) > 0 # left of line is > 0
コード例 #2
0
def test_side_of_line_on_line():
    x1, y1 = ( 0, 0)
    x2, y2 = (10,10)

    Px, Py = (10, 10)
    assert side_of_line(x1, y1, x2, y2, Px, Py) == 0 # on line is  0 (might not be exact with FP...)

    Px, Py = (0, 0)
    assert side_of_line(x1, y1, x2, y2, Px, Py) == 0 # on line is  0 (might not be exact with FP...)

    Px, Py = (-10, -10)
    assert side_of_line(x1, y1, x2, y2, Px, Py) == 0 # on line is  0 (might not be exact with FP...)
コード例 #3
0
def test_side_of_line_right():
    x1, y1 = ( 0, 0)
    x2, y2 = (10,10)

    Px, Py = (10, 5)
    assert side_of_line(x1, y1, x2, y2, Px, Py) < 0 # right of line is < 0

    Px, Py = (0, -1)
    assert side_of_line(x1, y1, x2, y2, Px, Py) < 0 # right of line is < 0

    Px, Py = (5.000000001, 5)
    assert side_of_line(x1, y1, x2, y2, Px, Py) < 0 # right of line is < 0