예제 #1
0
def test_poly_clip():
    x = [0, 1, 2, 1]
    y = [0, -1, 0, 1]

    yc, xc = polygon_clip(y, x, 0, 0, 1, 1)
    assert_equal(polygon_area(yc, xc), 0.5)

    x = [-1, 1.5, 1.5, -1]
    y = [.5, 0.5, 1.5, 1.5]
    yc, xc = polygon_clip(y, x, 0, 0, 1, 1)
    assert_equal(polygon_area(yc, xc), 0.5)
예제 #2
0
def test_poly_clip():
    x = [0,  1, 2, 1]
    y = [0, -1, 0, 1]

    yc, xc = polygon_clip(y, x, 0, 0, 1, 1)
    assert_equal(polygon_area(yc, xc), 0.5)

    x = [-1, 1.5, 1.5, -1]
    y = [.5, 0.5, 1.5, 1.5]
    yc, xc = polygon_clip(y, x, 0, 0, 1, 1)
    assert_equal(polygon_area(yc, xc), 0.5)
예제 #3
0
def test_polygon_area():
    x = [0, 0, 1, 1]
    y = [0, 1, 1, 0]

    assert_almost_equal(polygon_area(y, x), 1)

    x = [0, 0, 1]
    y = [0, 1, 1]

    assert_almost_equal(polygon_area(y, x), 0.5)

    x = [0, 0, 0.5, 1, 1, 0.5]
    y = [0, 1, 0.5, 1, 0, 0.5]

    assert_almost_equal(polygon_area(y, x), 0.5)
예제 #4
0
def test_polygon_area():
    x = [0, 0, 1, 1]
    y = [0, 1, 1, 0]

    assert_almost_equal(polygon_area(y, x), 1)

    x = [0, 0, 1]
    y = [0, 1, 1]

    assert_almost_equal(polygon_area(y, x), 0.5)

    x = [0, 0, 0.5, 1, 1, 0.5]
    y = [0, 1, 0.5, 1, 0, 0.5]

    assert_almost_equal(polygon_area(y, x), 0.5)