Related Articles
Python | Sympy Ellipse() method
• Last Updated : 30 Jan, 2020
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

 `# 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

 `# 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

 `# 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)`

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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up