Python | Sympy Ellipse.equation() method
In sympy, the function
Ellipse.equation()
is used to make the equation of the given ellipse.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
Example #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) |
Output:
y**2/4 + (x/3 - 1/3)**2 - 1
Example #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) |
Output:
x**2/9 + y**2/4 - 1
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.