本文整理汇总了Python中sympy.geometry.Curve.scale方法的典型用法代码示例。如果您正苦于以下问题:Python Curve.scale方法的具体用法?Python Curve.scale怎么用?Python Curve.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.geometry.Curve
的用法示例。
在下文中一共展示了Curve.scale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_geometry_transforms
# 需要导入模块: from sympy.geometry import Curve [as 别名]
# 或者: from sympy.geometry.Curve import scale [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)
)
示例2: test_transform
# 需要导入模块: from sympy.geometry import Curve [as 别名]
# 或者: from sympy.geometry.Curve import scale [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))