本文整理汇总了Python中sympy.geometry.Ray.contains方法的典型用法代码示例。如果您正苦于以下问题:Python Ray.contains方法的具体用法?Python Ray.contains怎么用?Python Ray.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.geometry.Ray
的用法示例。
在下文中一共展示了Ray.contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_contains
# 需要导入模块: from sympy.geometry import Ray [as 别名]
# 或者: from sympy.geometry.Ray import contains [as 别名]
def test_contains():
p1 = Point(0, 0)
r = Ray(p1, Point(4, 4))
r1 = Ray3D(p1, Point3D(0, 0, -1))
r2 = Ray3D(p1, Point3D(0, 1, 0))
r3 = Ray3D(p1, Point3D(0, 0, 1))
l = Line(Point(0, 1), Point(3, 4))
# Segment contains
assert Point(0, (a + b) / 2) in Segment((0, a), (0, b))
assert Point((a + b) / 2, 0) in Segment((a, 0), (b, 0))
assert Point3D(0, 1, 0) in Segment3D((0, 1, 0), (0, 1, 0))
assert Point3D(1, 0, 0) in Segment3D((1, 0, 0), (1, 0, 0))
assert Segment3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).contains([]) is True
assert Segment3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).contains(
Segment3D(Point3D(2, 2, 2), Point3D(3, 2, 2))) is False
# Line contains
assert l.contains(Point(0, 1)) is True
assert l.contains((0, 1)) is True
assert l.contains((0, 0)) is False
# Ray contains
assert r.contains(p1) is True
assert r.contains((1, 1)) is True
assert r.contains((1, 3)) is False
assert r.contains(Segment((1, 1), (2, 2))) is True
assert r.contains(Segment((1, 2), (2, 5))) is False
assert r.contains(Ray((2, 2), (3, 3))) is True
assert r.contains(Ray((2, 2), (3, 5))) is False
assert r1.contains(Segment3D(p1, Point3D(0, 0, -10))) is True
assert r1.contains(Segment3D(Point3D(1, 1, 1), Point3D(2, 2, 2))) is False
assert r2.contains(Point3D(0, 0, 0)) is True
assert r3.contains(Point3D(0, 0, 0)) is True
assert Ray3D(Point3D(1, 1, 1), Point3D(1, 0, 0)).contains([]) is False
assert Line3D((0, 0, 0), (x, y, z)).contains((2 * x, 2 * y, 2 * z))
with warnings.catch_warnings(record=True) as w:
assert Line3D(p1, Point3D(0, 1, 0)).contains(Point(1.0, 1.0)) is False
assert len(w) == 1
with warnings.catch_warnings(record=True) as w:
assert r3.contains(Point(1.0, 1.0)) is False
assert len(w) == 1
示例2: test_line_geom
# 需要导入模块: from sympy.geometry import Ray [as 别名]
# 或者: from sympy.geometry.Ray import contains [as 别名]
#.........这里部分代码省略.........
s2 = Segment(Point(half, half), Point(1, 0))
pt1 = Point(0, 0)
pt2 = Point(Rational(3)/2, Rational(3)/2)
assert s1.distance(pt1) == 0
assert s1.distance((0, 0)) == 0
assert s2.distance(pt1) == 2**(half)/2
assert s2.distance(pt2) == 2**(half)
# Line to point
p1, p2 = Point(0, 0), Point(1, 1)
s = Line(p1, p2)
assert s.distance(Point(-1, 1)) == sqrt(2)
assert s.distance(Point(1, -1)) == sqrt(2)
assert s.distance(Point(2, 2)) == 0
assert s.distance((-1, 1)) == sqrt(2)
assert Line((0, 0), (0, 1)).distance(p1) == 0
assert Line((0, 0), (0, 1)).distance(p2) == 1
assert Line((0, 0), (1, 0)).distance(p1) == 0
assert Line((0, 0), (1, 0)).distance(p2) == 1
m = symbols('m')
l = Line((0, 5), slope=m)
p = Point(2, 3)
assert l.distance(p) == 2*abs(m + 1)/sqrt(m**2 + 1)
# Ray to point
r = Ray(p1, p2)
assert r.distance(Point(-1, -1)) == sqrt(2)
assert r.distance(Point(1, 1)) == 0
assert r.distance(Point(-1, 1)) == sqrt(2)
assert Ray((1, 1), (2, 2)).distance(Point(1.5, 3)) == 3*sqrt(2)/4
assert r.distance((1, 1)) == 0
#Line contains
p1, p2 = Point(0, 1), Point(3, 4)
l = Line(p1, p2)
assert l.contains(p1) is True
assert l.contains((0, 1)) is True
assert l.contains((0, 0)) is False
#Ray contains
p1, p2 = Point(0, 0), Point(4, 4)
r = Ray(p1, p2)
assert r.contains(p1) is True
assert r.contains((1, 1)) is True
assert r.contains((1, 3)) is False
s = Segment((1, 1), (2, 2))
assert r.contains(s) is True
s = Segment((1, 2), (2, 5))
assert r.contains(s) is False
r1 = Ray((2, 2), (3, 3))
assert r.contains(r1) is True
r1 = Ray((2, 2), (3, 5))
assert r.contains(r1) is False
# Special cases of projection and intersection
r1 = Ray(Point(1, 1), Point(2, 2))
r2 = Ray(Point(2, 2), Point(0, 0))
r3 = Ray(Point(1, 1), Point(-1, -1))
r4 = Ray(Point(0, 4), Point(-1, -5))
r5 = Ray(Point(2, 2), Point(3, 3))
assert intersection(r1, r2) == [Segment(Point(1, 1), Point(2, 2))]
assert intersection(r1, r3) == [Point(1, 1)]
assert r1.projection(r3) == Point(1, 1)
assert r1.projection(r4) == Segment(Point(1, 1), Point(2, 2))
r5 = Ray(Point(0, 0), Point(0, 1))
r6 = Ray(Point(0, 0), Point(0, 2))