Python| Sympy Circle() 方法
在 Simpy 中,函数
Circle()
用于从一个中心和一个半径、从三个非共线点或一个圆的方程来制作圆。Syntax: Circle()
Parameters:
center : Point and
radius : number or sympy expression or
points : sequence of three Points or
equation : equation of a circle
Error: Raises GeometryError When the given equation is not that of a circle. When trying to construct circle from incorrect parameters.
示例 #1:使用中心和半径
# import sympy and geometry module
from sympy.geometry import Point, Circle
# using Circle()
c1 = Circle(Point(0, 0), 5)
print(c1.hradius, c1.vradius, c1.radius)
输出:
(5, 5, 5)
示例#2:使用三点序列
# import sympy and geometry module
from sympy.geometry import Point, Circle
# using Circle()
c2 = Circle(Point(0, 0), Point(1, 1), Point(1, 0))
print(c2.hradius, c2.vradius, c2.radius)
输出:
(sqrt(2)/2, sqrt(2)/2, sqrt(2)/2)
示例#3:使用圆方程
# import sympy and geometry module
from sympy.geometry import Point, Circle
from sympy import Eq
# using Circle()
c3 = Circle(x**2 + y**2 - 25)
print(c3)
输出:
Circle(Point2D(0, 0), 5)