本文整理汇总了Python中sympy.geometry.Point.reflect方法的典型用法代码示例。如果您正苦于以下问题:Python Point.reflect方法的具体用法?Python Point.reflect怎么用?Python Point.reflect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.geometry.Point
的用法示例。
在下文中一共展示了Point.reflect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reflect
# 需要导入模块: from sympy.geometry import Point [as 别名]
# 或者: from sympy.geometry.Point import reflect [as 别名]
def test_reflect():
b = Symbol('b')
m = Symbol('m')
l = Line((0, b), slope=m)
p = Point(x, y)
r = p.reflect(l)
dp = l.perpendicular_segment(p).length
dr = l.perpendicular_segment(r).length
assert test_numerically(dp, dr)
t = Triangle((0, 0), (1, 0), (2, 3))
assert t.area == -t.reflect(l).area
e = Ellipse((1, 0), 1, 2)
assert e.area == -e.reflect(Line((1, 0), slope=0)).area
assert e.area == -e.reflect(Line((1, 0), slope=oo)).area
raises(NotImplementedError, lambda: e.reflect(Line((1,0), slope=m)))
# test entity overrides
c = Circle((x, y), 3)
cr = c.reflect(l)
assert cr == Circle(r, -3)
assert c.area == -cr.area
pent = RegularPolygon((1, 2), 1, 5)
l = Line((0, pi), slope=sqrt(2))
rpent = pent.reflect(l)
poly_pent = Polygon(*pent.vertices)
assert rpent.center == pent.center.reflect(l)
assert str([w.n(3) for w in rpent.vertices]) == (
'[Point(-0.586, 4.27), Point(-1.69, 4.66), '
'Point(-2.41, 3.73), Point(-1.74, 2.76), '
'Point(-0.616, 3.10)]')
assert pent.area.equals(-rpent.area)
示例2: test_reflect_entity_overrides
# 需要导入模块: from sympy.geometry import Point [as 别名]
# 或者: from sympy.geometry.Point import reflect [as 别名]
def test_reflect_entity_overrides():
x = Symbol('x', real=True)
y = Symbol('y', real=True)
b = Symbol('b')
m = Symbol('m')
l = Line((0, b), slope=m)
p = Point(x, y)
r = p.reflect(l)
c = Circle((x, y), 3)
cr = c.reflect(l)
assert cr == Circle(r, -3)
assert c.area == -cr.area
pent = RegularPolygon((1, 2), 1, 5)
l = Line(pent.vertices[1],
slope=Rational(random() - .5, random() - .5))
rpent = pent.reflect(l)
assert rpent.center == pent.center.reflect(l)
rvert = [i.reflect(l) for i in pent.vertices]
for v in rpent.vertices:
for i in range(len(rvert)):
ri = rvert[i]
if ri.equals(v):
rvert.remove(ri)
break
assert not rvert
assert pent.area.equals(-rpent.area)
示例3: test_reflect
# 需要导入模块: from sympy.geometry import Point [as 别名]
# 或者: from sympy.geometry.Point import reflect [as 别名]
def test_reflect():
x = Symbol('x', real=True)
y = Symbol('y', real=True)
b = Symbol('b')
m = Symbol('m')
l = Line((0, b), slope=m)
p = Point(x, y)
r = p.reflect(l)
dp = l.perpendicular_segment(p).length
dr = l.perpendicular_segment(r).length
assert verify_numerically(dp, dr)
t = Triangle((0, 0), (1, 0), (2, 3))
assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((3, 0), slope=oo)) \
== Triangle(Point(5, 0), Point(4, 0), Point(4, 2))
assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((0, 3), slope=oo)) \
== Triangle(Point(-1, 0), Point(-2, 0), Point(-2, 2))
assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((0, 3), slope=0)) \
== Triangle(Point(1, 6), Point(2, 6), Point(2, 4))
assert Polygon((1, 0), (2, 0), (2, 2)).reflect(Line((3, 0), slope=0)) \
== Triangle(Point(1, 0), Point(2, 0), Point(2, -2))
示例4: test_reflect_entity_overrides
# 需要导入模块: from sympy.geometry import Point [as 别名]
# 或者: from sympy.geometry.Point import reflect [as 别名]
def test_reflect_entity_overrides():
x = Symbol('x', real=True)
y = Symbol('y', real=True)
b = Symbol('b')
m = Symbol('m')
l = Line((0, b), slope=m)
p = Point(x, y)
r = p.reflect(l)
c = Circle((x, y), 3)
cr = c.reflect(l)
assert cr == Circle(r, -3)
assert c.area == -cr.area
pent = RegularPolygon((1, 2), 1, 5)
l = Line((0, pi), slope=sqrt(2))
rpent = pent.reflect(l)
assert rpent.center == pent.center.reflect(l)
assert str([w.n(3) for w in rpent.vertices]) == (
'[Point2D(-0.586, 4.27), Point2D(-1.69, 4.66), '
'Point2D(-2.41, 3.73), Point2D(-1.74, 2.76), '
'Point2D(-0.616, 3.10)]')
assert pent.area.equals(-rpent.area)