Python Sympy Segment.perpendicular_bisector()方法
在Sympy中,函数perpendicular_bisector()是用来寻找指定线段的垂直平分线的。如果没有指定点,或者指定的点不在平分线上,那么平分线将以直线的形式返回。否则,将返回一个连接指定点和平分线与线段的交点的线段。
语法: Segment.perpendicular_bisector(p=None)
参数 :
p: Point
返回:
bisector: Line or Segment
示例 #1:
# import sympy and Point, Segment
from sympy import Point, Segment
p1, p2, p3 = Point(0, 0), Point(6, 6), Point(5, 1)
s1 = Segment(p1, p2)
# using perpendicular_bisector() method
perpendicularBisector = s1.perpendicular_bisector()
print(perpendicularBisector)
输出:
Line2D(Point2D(3, 3), Point2D(-3, 9))
示例 #2:
# import sympy and Point, Segment
from sympy import Point, Segment
p1, p2, p3 = Point(0, 0), Point(6, 6), Point(5, 1)
s1 = Segment(p1, p2)
# using perpendicular_bisector() method
perpendicularBisector = s1.perpendicular_bisector(p3)
print(perpendicularBisector)
输出:
Segment2D(Point2D(5, 1), Point2D(3, 3))