Python – Sympy Curve.translate()方法
在Sympy中,函数Curve.translate()用于将给定的曲线按给定的x、y值进行平移,它将曲线沿x轴和y轴两个方向平移。
语法: Curve.translate(x, y)
参数:
x:沿x轴的翻译值
y:沿y轴的翻译值
返回:翻译的曲线
示例 #1:
# import Curve, parameter and interpolate
from sympy.geometry.curve import Curve
from sympy.abc import t
from sympy import interpolate
# using interpolate() and Curve()
C1 = Curve((t, interpolate([1, 4, 9, 16], t)), (t, 0, 1));
print(C1)
# using translate()
C2 = C1.translate(2, 3)
print(C2)
输出:
Curve((t, t**2), (t, 0, 1))
Curve((t + 2, t**2 + 3), (t, 0, 1))
示例 #2:
# import Curve and parameter
from sympy.geometry.curve import Curve
from sympy.abc import x
# using Curve()
C1 = Curve((x, x), (x, 0, 1));
print(C1)
# using translate()
C2 = C1.translate(1, 2)
print(C2)
输出:
Curve((x, x), (x, 0, 1))
Curve((x + 1, x + 2), (x, 0, 1))