HomeLanguagesPython | Sympy Ellipse() method

Python | Sympy Ellipse() method

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)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32727 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7105 POSTS0 COMMENTS
Nicole Veronica
12244 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12329 POSTS0 COMMENTS
Shaida Kate Naidoo
7220 POSTS0 COMMENTS
Ted Musemwa
7479 POSTS0 COMMENTS
Thapelo Manthata
7200 POSTS0 COMMENTS
Umr Jansen
7176 POSTS0 COMMENTS