📜  Python| Sympy Ellipse.equation() 方法

📅  最后修改于: 2022-05-13 01:54:58.079000             🧑  作者: Mango

Python| Sympy Ellipse.equation() 方法

在 sympy 中,函数Ellipse.equation()用于制作给定椭圆的方程。
Syntax: Ellipse.equation(x='x', y='y', _slope=None)

Parameters:
x : Label for the x-axis. Default value is ‘x’.
y : Label for the y-axis. Default value is ‘y’.
_slope : The slope of the major axis. Ignored when ‘None’.

Returns: equation : sympy expression

示例 #1:

# import sympy, Point and Ellipse
from sympy import Point, Ellipse
from sympy.abc import x, y
  
# using Ellipse() 
e1 = Ellipse(Point(1, 0), 3, 2)
  
# using equation()
eq1 = e1.equation(x, y);
  
print(eq1)

输出:

y**2/4 + (x/3 - 1/3)**2 - 1

示例 #2:

# import sympy, Point and Ellipse
from sympy import Point, Ellipse
from sympy.abc import x, y
  
# using Ellipse() 
e2 = Ellipse(Point(0, 0), 3, 2)
  
# using equation()
eq2 = e2.equation(x, y);
  
print(eq2)

输出:

x**2/9 + y**2/4 - 1