Esempio n. 1
0
def test_util_centroid():
    p = Polygon((0, 0), (10, 0), (10, 10))
    q = p.translate(0, 20)
    assert centroid(p, q) == Point(20, 40) / 3
    p = Segment((0, 0), (2, 0))
    q = Segment((0, 0), (2, 2))
    assert centroid(p, q) == Point(1, 2 * sqrt(2) / (2 + 2 * sqrt(2)))
    assert centroid(Point(0, 0), Point(2, 0)) == Point(2, 0) / 2
    assert centroid(Point(0, 0), Point(0, 0), Point(2, 0)) == Point(2, 0) / 3
Esempio n. 2
0
def test_util_centroid():
    p = Polygon((0, 0), (10, 0), (10, 10))
    q = p.translate(0, 20)
    assert centroid(p, q) == Point(20, 40) / 3
    p = Segment((0, 0), (2, 0))
    q = Segment((0, 0), (2, 2))
    assert centroid(p, q) == Point(1, 2 * sqrt(2) / (2 + 2 * sqrt(2)))
    assert centroid(Point(0, 0), Point(2, 0)) == Point(2, 0) / 2
    assert centroid(Point(0, 0), Point(0, 0), Point(2, 0)) == Point(2, 0) / 3