當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Python Sympy encloses_point()用法及代碼示例


在sympy中,函數encloses_point()用於檢查給定點是否被給定橢圓所包圍。
用法: Ellipse.encloses_point(point)

返回: True:if point is enclosed by ellipse, otherwise False.

範例1:

# import sympy and geometry module  
from sympy import * 
from sympy.geometry import * 
  
x = Point(0, 0)  
  
# making ellipse with given point as center and radii 
e1 = Ellipse(x, 3, 2) 
  
# using encloses_point() method 
isEnclosed = e1.encloses_point((0, 0)) 
  
print(isEnclosed) 
  

輸出:


True

範例2:

# import sympy and geometry module  
from sympy import * 
from sympy.geometry import * 
  
x = Point(3, 1)  
  
# making ellipse with given point as center, hradius and eccentricity 
e2 = Ellipse(x, hradius = 3, eccentricity = Rational(4, 5)) 
  
# using encloses_point() method 
isEnclosed = e2.encloses_point((4, 6)) 
  
print(isEnclosed) 
  

輸出:

False


相關用法


注:本文由純淨天空篩選整理自ravikishor大神的英文原創作品 Python | Sympy encloses_point() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。