本文整理汇总了Python中sympy.geometry.Triangle.intersection方法的典型用法代码示例。如果您正苦于以下问题:Python Triangle.intersection方法的具体用法?Python Triangle.intersection怎么用?Python Triangle.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.geometry.Triangle
的用法示例。
在下文中一共展示了Triangle.intersection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_intersection
# 需要导入模块: from sympy.geometry import Triangle [as 别名]
# 或者: from sympy.geometry.Triangle import intersection [as 别名]
def test_intersection():
poly1 = Triangle(Point(0, 0), Point(1, 0), Point(0, 1))
poly2 = Polygon(Point(0, 1), Point(-5, 0),
Point(0, -4), Point(0, S(1)/5),
Point(S(1)/2, -0.1), Point(1,0), Point(0, 1))
assert poly1.intersection(poly2) == [Point2D(S(1)/3, 0),
Segment(Point(0, S(1)/5), Point(0, 0)),
Segment(Point(1, 0), Point(0, 1))]
assert poly2.intersection(poly1) == [Point(S(1)/3, 0),
Segment(Point(0, 0), Point(0, S(1)/5)),
Segment(Point(1, 0), Point(0, 1))]
assert poly1.intersection(Point(0, 0)) == [Point(0, 0)]
assert poly1.intersection(Point(-12, -43)) == []
assert poly2.intersection(Line((-12, 0), (12, 0))) == [Point(-5, 0),
Point(0, 0),Point(S(1)/3, 0), Point(1, 0)]
assert poly2.intersection(Line((-12, 12), (12, 12))) == []
assert poly2.intersection(Ray((-3,4), (1,0))) == [Segment(Point(1, 0),
Point(0, 1))]
assert poly2.intersection(Circle((0, -1), 1)) == [Point(0, -2),
Point(0, 0)]
assert poly1.intersection(poly1) == [Segment(Point(0, 0), Point(1, 0)),
Segment(Point(0, 1), Point(0, 0)), Segment(Point(1, 0), Point(0, 1))]
assert poly2.intersection(poly2) == [Segment(Point(-5, 0), Point(0, -4)),
Segment(Point(0, -4), Point(0, S(1)/5)),
Segment(Point(0, S(1)/5), Point(S(1)/2, -S(1)/10)),
Segment(Point(0, 1), Point(-5, 0)),
Segment(Point(S(1)/2, -S(1)/10), Point(1, 0)),
Segment(Point(1, 0), Point(0, 1))]
assert poly2.intersection(Triangle(Point(0, 1), Point(1, 0), Point(-1, 1))) \
== [Point(-S(5)/7, S(6)/7), Segment(Point2D(0, 1), Point(1, 0))]
assert poly1.intersection(RegularPolygon((-12, -15), 3, 3)) == []