当前位置: 首页>>代码示例>>Python>>正文


Python geometry.convex_hull函数代码示例

本文整理汇总了Python中sympy.geometry.convex_hull函数的典型用法代码示例。如果您正苦于以下问题:Python convex_hull函数的具体用法?Python convex_hull怎么用?Python convex_hull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了convex_hull函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_convex_hull

def test_convex_hull():
    p = [Point(-5,-1), Point(-2,1), Point(-2,-1), Point(-1,-3), Point(0,0),
         Point(1,1), Point(2,2), Point(2,-1), Point(3,1), Point(4,-1), Point(6,2)]
    ch = Polygon(p[0], p[3], p[9], p[10], p[6], p[1])
    assert convex_hull(p) == ch
    assert convex_hull(p[0]) == p[0]
    assert convex_hull(p[0], p[1]) == Segment(p[0], p[1])
开发者ID:gnulinooks,项目名称:sympy,代码行数:7,代码来源:test_geometry.py

示例2: test_convex_hull

def test_convex_hull():
    p = [Point(-5,-1), Point(-2,1), Point(-2,-1), Point(-1,-3), Point(0,0),
         Point(1,1), Point(2,2), Point(2,-1), Point(3,1), Point(4,-1), Point(6,2)]
    ch = Polygon(p[0], p[3], p[9], p[10], p[6], p[1])
    #test handling of duplicate points
    p.append(p[3])

    #more than 3 collinear points
    another_p = [Point(-45, -85), Point(-45, 85), Point(-45,26),Point(-45,-24)]
    ch2 = Segment(another_p[0],another_p[1])

    assert convex_hull(another_p) == ch2
    assert convex_hull(p) == ch
    assert convex_hull(p[0]) == p[0]
    assert convex_hull(p[0], p[1]) == Segment(p[0], p[1])
开发者ID:pernici,项目名称:sympy,代码行数:15,代码来源:test_geometry.py

示例3: test_convex_hull

def test_convex_hull():
    p = [
        Point(-5, -1),
        Point(-2, 1),
        Point(-2, -1),
        Point(-1, -3),
        Point(0, 0),
        Point(1, 1),
        Point(2, 2),
        Point(2, -1),
        Point(3, 1),
        Point(4, -1),
        Point(6, 2),
    ]
    ch = Polygon(p[0], p[3], p[9], p[10], p[6], p[1])
    # test handling of duplicate points
    p.append(p[3])

    # more than 3 collinear points
    another_p = [Point(-45, -85), Point(-45, 85), Point(-45, 26), Point(-45, -24)]
    ch2 = Segment(another_p[0], another_p[1])

    assert convex_hull(*another_p) == ch2
    assert convex_hull(*p) == ch
    assert convex_hull(p[0]) == p[0]
    assert convex_hull(p[0], p[1]) == Segment(p[0], p[1])

    # no unique points
    assert convex_hull(*[p[-1]] * 3) == p[-1]

    # collection of items
    assert convex_hull(*[Point(0, 0), Segment(Point(1, 0), Point(1, 1)), RegularPolygon(Point(2, 0), 2, 4)]) == Polygon(
        Point(0, 0), Point(2, -2), Point(4, 0), Point(2, 2)
    )
开发者ID:flacjacket,项目名称:sympy,代码行数:34,代码来源:test_geometry.py

示例4: __init__

    def __init__(self, dim, polygon=None, point=None):
        """
        Construct OBB from either the polygon which represents the convex hull or from a list of point.
        :param polygon: the sympy.geometry.Polygon which represents the convex hull of a set of points.
        :param point: list of sympy,geometry.Point.
        :modify: if successful diagonal coordinates of OBB where
                 r[0]: x_min
                 r[1]: y_min
                 r[2]: x_max
                 r[3]: y_max.
        :error: if dim is not 2 or both polygon and point are None raise ValueError.
        """

        if dim != 2:
            raise ValueError('only 2D is supported.')
        if point is None and polygon is not None:
            for _ in range(2*dim):
                self.r.append(polygon.bounds[_])
        elif point is not None and polygon is None:
            symgeo.convex_hull(point)
        else:
            raise ValueError('both polygon and point are None.')
开发者ID:orxshi,项目名称:kyrenia,代码行数:22,代码来源:ADT.py

示例5: test_util

def test_util():
    # coverage for some leftover functions in sympy.geometry.util
    assert intersection(Point(0, 0)) == []
    raises(ValueError, lambda: intersection(Point(0, 0), 3))
    raises(ValueError, lambda: convex_hull(Point(0, 0), 3))
开发者ID:flacjacket,项目名称:sympy,代码行数:5,代码来源:test_geometry.py

示例6: test_convex_hull

def test_convex_hull():
    raises(TypeError, lambda: convex_hull(Point(0, 0), 3))
    points = [(1, -1), (1, -2), (3, -1), (-5, -2), (15, -4)]
    assert convex_hull(*points, **dict(polygon=False)) == (
        [Point2D(-5, -2), Point2D(1, -1), Point2D(3, -1), Point2D(15, -4)],
        [Point2D(-5, -2), Point2D(15, -4)])
开发者ID:asmeurer,项目名称:sympy,代码行数:6,代码来源:test_util.py


注:本文中的sympy.geometry.convex_hull函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。