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


Python Curve.subs方法代码示例

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


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

示例1: test_geometry_transforms

# 需要导入模块: from sympy.geometry import Curve [as 别名]
# 或者: from sympy.geometry.Curve import subs [as 别名]
def test_geometry_transforms():
    from sympy import Tuple

    c = Curve((x, x ** 2), (x, 0, 1))
    pts = [Point(0, 0), Point(S(1) / 2, S(1) / 4), Point(1, 1)]
    cout = Curve((2 * x - 4, 3 * x ** 2 - 10), (x, 0, 1))
    pts_out = [Point(-4, -10), Point(-3, -S(37) / 4), Point(-2, -7)]
    assert c.scale(2, 3, (4, 5)) == cout
    assert [c.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts
    assert [cout.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts_out
    assert Triangle(*pts).scale(2, 3, (4, 5)) == Triangle(*pts_out)

    assert Ellipse((0, 0), 2, 3).scale(2, 3, (4, 5)) == Ellipse(Point(-4, -10), 4, 9)
    assert Circle((0, 0), 2).scale(2, 3, (4, 5)) == Ellipse(Point(-4, -10), 4, 6)
    assert Ellipse((0, 0), 2, 3).scale(3, 3, (4, 5)) == Ellipse(Point(-8, -10), 6, 9)
    assert Circle((0, 0), 2).scale(3, 3, (4, 5)) == Circle(Point(-8, -10), 6)
    assert Circle(Point(-8, -10), 6).scale(S(1) / 3, S(1) / 3, (4, 5)) == Circle((0, 0), 2)
    assert Curve((x + y, 3 * x), (x, 0, 1)).subs(y, S.Half) == Curve((x + S(1) / 2, 3 * x), (x, 0, 1))
    assert Curve((x, 3 * x), (x, 0, 1)).translate(4, 5) == Curve((x + 4, 3 * x + 5), (x, 0, 1))
    assert Circle((0, 0), 2).translate(4, 5) == Circle((4, 5), 2)
    assert Circle((0, 0), 2).scale(3, 3) == Circle((0, 0), 6)
    assert Point(1, 1).scale(2, 3, (4, 5)) == Point(-2, -7)
    assert Point(1, 1).translate(4, 5) == Point(5, 6)
    assert scale(1, 2, (3, 4)).tolist() == [[1, 0, 0], [0, 2, 0], [0, -4, 1]]
    assert RegularPolygon((0, 0), 1, 4).scale(2, 3, (4, 5)) == Polygon(
        Point(-2, -10), Point(-4, -7), Point(-6, -10), Point(-4, -13)
    )
开发者ID:flacjacket,项目名称:sympy,代码行数:29,代码来源:test_geometry.py

示例2: test_transform

# 需要导入模块: from sympy.geometry import Curve [as 别名]
# 或者: from sympy.geometry.Curve import subs [as 别名]
def test_transform():
    x = Symbol('x', real=True)
    y = Symbol('y', real=True)
    c = Curve((x, x**2), (x, 0, 1))
    cout = Curve((2*x - 4, 3*x**2 - 10), (x, 0, 1))
    pts = [Point(0, 0), Point(1/2, 1/4), Point(1, 1)]
    pts_out = [Point(-4, -10), Point(-3, -37/4), Point(-2, -7)]

    assert c.scale(2, 3, (4, 5)) == cout
    assert [c.subs(x, xi/2) for xi in Tuple(0, 1, 2)] == pts
    assert [cout.subs(x, xi/2) for xi in Tuple(0, 1, 2)] == pts_out
    assert Curve((x + y, 3*x), (x, 0, 1)).subs(y, S.Half) == \
        Curve((x + 1/2, 3*x), (x, 0, 1))
    assert Curve((x, 3*x), (x, 0, 1)).translate(4, 5) == \
        Curve((x + 4, 3*x + 5), (x, 0, 1))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:17,代码来源:test_curve.py


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