Open In App

Python | Sympy Ellipse() method

Last Updated : 25 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
In sympy, the function Ellipse() is used to create ellipse from a center and two radii, the first being the horizontal radius (along the x-axis) and the second being the vertical radius (along the y-axis).
Syntax: Ellipse() Parameters: center: Point hradius: number or SymPy expression, optional vradius: number or SymPy expression, optional eccentricity: number or SymPy expression, optional Error: Raises Geometry Error when hradius, vradius and eccentricity are incorrectly supplied as parameters and Type Error when center is not a Point.
Example #1: Using center and radii Python3
# import sympy and geometry module 
from sympy.geometry import Point, Ellipse

# using Ellipse()
e1 = Ellipse(Point(0, 0), 5, 1)

print(e1.hradius,e1.vradius)
Output:
(5,1)
Example #2: Using center, hradius and eccentricity Python3
# import sympy and geometry module 
from sympy.geometry import Point, Ellipse, Rational

# using Ellipse()
e2 = Ellipse(Point(3, 1), hradius=3, eccentricity=Rational(4, 5))

print(e2)
Output:
Ellipse(Point2D(3, 1), 3, 9/5)
Example #3: Using center, vradius and eccentricity Python3
# import sympy and geometry module 
from sympy.geometry import Point, Ellipse, Rational

# using Ellipse()
e2 = Ellipse(Point(3, 1), vradius=3, eccentricity=Rational(4, 5))

print(e2)
Output:
Ellipse(Point2D(3, 1), 5, 3)

Next Article
Article Tags :
Practice Tags :

Similar Reads