• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python geometry.Curve类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_geometry_transforms

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,代码行数:27,代码来源:test_geometry.py


示例2: test_curve

def test_curve():
    s = Symbol('s')
    z = Symbol('z')

    # this curve is independent of the indicated parameter
    c = Curve([2*s, s**2], (z, 0, 2))

    assert c.parameter == z
    assert c.functions == (2*s, s**2)
    assert c.arbitrary_point() == Point(2*s, s**2)
    assert c.arbitrary_point(z) == Point(2*s, s**2)

    # this is how it is normally used
    c = Curve([2*s, s**2], (s, 0, 2))

    assert c.parameter == s
    assert c.functions == (2*s, s**2)
    t = Symbol('t')
    assert c.arbitrary_point() != Point(2*t, t**2) # the t returned as assumptions
    t = Symbol('t', real=True) # now t has the same assumptions so the test passes
    assert c.arbitrary_point() == Point(2*t, t**2)
    assert c.arbitrary_point(z) == Point(2*z, z**2)
    assert c.arbitrary_point(c.parameter) == Point(2*s, s**2)

    raises(ValueError, 'Curve((s, s + t), (s, 1, 2)).arbitrary_point()')
    raises(ValueError, 'Curve((s, s + t), (t, 1, 2)).arbitrary_point(s)')
开发者ID:AlexandruFlorescu,项目名称:sympy,代码行数:26,代码来源:test_geometry.py


示例3: test_transform

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,代码行数:15,代码来源:test_curve.py


示例4: test_curve

def test_curve():
    s = Symbol("s")
    z = Symbol("z")

    # this curve is independent of the indicated parameter
    c = Curve([2 * s, s ** 2], (z, 0, 2))

    assert c.parameter == z
    assert c.functions == (2 * s, s ** 2)
    assert c.arbitrary_point() == Point(2 * s, s ** 2)
    assert c.arbitrary_point(z) == Point(2 * s, s ** 2)

    # this is how it is normally used
    c = Curve([2 * s, s ** 2], (s, 0, 2))

    assert c.parameter == s
    assert c.functions == (2 * s, s ** 2)
    t = Symbol("t")
    assert c.arbitrary_point() != Point(2 * t, t ** 2)  # the t returned as assumptions
    t = Symbol("t", real=True)  # now t has the same assumptions so the test passes
    assert c.arbitrary_point() == Point(2 * t, t ** 2)
    assert c.arbitrary_point(z) == Point(2 * z, z ** 2)
    assert c.arbitrary_point(c.parameter) == Point(2 * s, s ** 2)
    assert c.arbitrary_point(None) == Point(2 * s, s ** 2)
    assert c.plot_interval() == [t, 0, 2]
    assert c.plot_interval(z) == [z, 0, 2]

    assert (
        Curve([x, x], (x, 0, 1)).rotate(pi / 2, (1, 2)).scale(2, 3).translate(1, 3).arbitrary_point(s)
        == Line((0, 0), (1, 1)).rotate(pi / 2, (1, 2)).scale(2, 3).translate(1, 3).arbitrary_point(s)
        == Point(-2 * s + 7, 3 * s + 6)
    )

    raises(ValueError, lambda: Curve((s), (s, 1, 2)))
    raises(ValueError, lambda: Curve((x, x * 2), (1, x)))

    raises(ValueError, lambda: Curve((s, s + t), (s, 1, 2)).arbitrary_point())
    raises(ValueError, lambda: Curve((s, s + t), (t, 1, 2)).arbitrary_point(s))
开发者ID:flacjacket,项目名称:sympy,代码行数:38,代码来源:test_geometry.py


示例5: test_parameter_value

def test_parameter_value():
    t = Symbol('t')
    C = Curve([2*t, t**2], (t, 0, 2))
    assert C.parameter_value((2, 1), t) == {t: 1}
    raises(ValueError, lambda: C.parameter_value((2, 0), t))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:5,代码来源:test_curve.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python geometry.Ellipse类代码示例发布时间:2022-05-27
下一篇:
Python geometry.intersection函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap