Python Sympy encloses_point()方法
在sympy中,函数encloses_point()是用来检查给定的点是否被给定的椭圆所包围。
语法: Ellipse.encloses_point(point)
返回: True:如果点被椭圆所包围,否则为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