多边形#

class sympy.geometry.polygon.Polygon(*args, n=0, **kwargs)[源代码]#

二维多边形。

空间中的简单多边形。可以从一系列点或从中心、半径、边数和旋转角度构造。

参数:

vertices

A sequence of points.

n : int, optional

If \(> 0\), an n-sided RegularPolygon is created. Default value is \(0\).

加薪:

GeometryError

如果所有参数都不是点。

笔记

多边形被视为闭合路径而不是二维区域,因此根据点的方向,某些计算可以是负的或正的(例如,面积)。

任何连续的相同点都将被简化为一个点,并且任何共线点和两点之间的点都将被删除,除非它们需要定义一个明确的交点(参见示例)。

当提供的点不超过3个时,将返回一个三角形、线段或点。

实例

>>> from sympy import Polygon, pi
>>> p1, p2, p3, p4, p5 = [(0, 0), (1, 0), (5, 1), (0, 1), (3, 0)]
>>> Polygon(p1, p2, p3, p4)
Polygon(Point2D(0, 0), Point2D(1, 0), Point2D(5, 1), Point2D(0, 1))
>>> Polygon(p1, p2)
Segment2D(Point2D(0, 0), Point2D(1, 0))
>>> Polygon(p1, p2, p5)
Segment2D(Point2D(0, 0), Point2D(3, 0))

当顶点沿逆时针方向遍历时,多边形的面积计算为正。当多边形的边交叉时,该区域将有正的和负的贡献。下面定义了一个Z形,其中右下角连接回左上角。

>>> Polygon((0, 2), (2, 2), (0, 0), (2, 0)).area
0

When the keyword \(n\) is used to define the number of sides of the Polygon then a RegularPolygon is created and the other arguments are interpreted as center, radius and rotation. The unrotated RegularPolygon will always have a vertex at Point(r, 0) where \(r\) is the radius of the circle that circumscribes the RegularPolygon. Its method \(spin\) can be used to increment that angle.

>>> p = Polygon((0,0), 1, n=3)
>>> p
RegularPolygon(Point2D(0, 0), 1, 3, 0)
>>> p.vertices[0]
Point2D(1, 0)
>>> p.args[0]
Point2D(0, 0)
>>> p.spin(pi/2)
>>> p.vertices[0]
Point2D(0, 1)

属性

地区

周长

顶点

质心

property angles#

每个顶点的内角。

返回:

:dict命令

一个字典,其中每个键都是一个顶点,每个值都是该顶点处的内角。顶点用点表示。

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.angles[p1]
pi/2
>>> poly.angles[p2]
acos(-4*sqrt(17)/17)
arbitrary_point(parameter='t')[源代码]#

多边形上的参数化点。

该参数从0到1不等,将点指定给周长上的位置,即总周长的分数。所以在t=1/2处求值的点将从围绕多边形1/2的第一个顶点返回该点。

参数:

参数 :str,可选

默认值为“t”。

返回:

arbitrary_point :点

加薪:

ValueError

什么时候? \(parameter\) 已经出现在多边形的定义中。

实例

>>> from sympy import Polygon, Symbol
>>> t = Symbol('t', real=True)
>>> tri = Polygon((0, 0), (1, 0), (1, 1))
>>> p = tri.arbitrary_point('t')
>>> perimeter = tri.perimeter
>>> s1, s2 = [s.length for s in tri.sides[:2]]
>>> p.subs(t, (s1 + s2/2)/perimeter)
Point2D(1, 1/2)
property area#

多边形的面积。

笔记

根据点的方向,面积计算可以是正值或负值。如果多边形的任何一边与另一边交叉,则会出现符号相反的区域。

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.area
3

在Z形多边形中(右下角连接到左上角),这些区域相互抵消:

>>> Z = Polygon((0, 1), (1, 1), (0, 0), (1, 0))
>>> Z.area
0

在M形多边形中,由于没有边与其他边相交(尽管有一个接触点),所以区域不会取消。

>>> M = Polygon((0, 0), (0, 1), (2, 0), (3, 1), (3, 0))
>>> M.area
-3/2
bisectors(prec=None)[源代码]#

返回多边形的角平分线。如果给定了prec,则将定义光线的点近似到该精度。

定义平分线光线的点之间的距离为1。

实例

>>> from sympy import Polygon, Point
>>> p = Polygon(Point(0, 0), Point(2, 0), Point(1, 1), Point(0, 3))
>>> p.bisectors(2)
{Point2D(0, 0): Ray2D(Point2D(0, 0), Point2D(0.71, 0.71)),
 Point2D(0, 3): Ray2D(Point2D(0, 3), Point2D(0.23, 2.0)),
 Point2D(1, 1): Ray2D(Point2D(1, 1), Point2D(0.19, 0.42)),
 Point2D(2, 0): Ray2D(Point2D(2, 0), Point2D(1.1, 0.38))}
property bounds#

xmax,在矩形中表示xmax,表示图形中的xmax。

property centroid#

多边形的质心。

返回:

质心 :点

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.centroid
Point2D(31/18, 11/18)
cut_section(line)[源代码]#

返回分别位于相交线上方和下方的两个多边形线段的元组。

参数:

线:几何模块的线对象

切割多边形的线。返回位于该线上方和下方的多边形部分。

返回:

上部多边形、下部多边形:多边形对象或无

上部多边形是位于给定直线上方的多边形。下面的多边形是位于给定直线下方的多边形。上部多边形和下部多边形为 None 当直线上方或下方不存在多边形时。

加薪:

值错误:当直线与多边形不相交时

实例

>>> from sympy import Polygon, Line
>>> a, b = 20, 10
>>> p1, p2, p3, p4 = [(0, b), (0, 0), (a, 0), (a, b)]
>>> rectangle = Polygon(p1, p2, p3, p4)
>>> t = rectangle.cut_section(Line((0, 5), slope=0))
>>> t
(Polygon(Point2D(0, 10), Point2D(0, 5), Point2D(20, 5), Point2D(20, 10)),
Polygon(Point2D(0, 5), Point2D(0, 0), Point2D(20, 0), Point2D(20, 5)))
>>> upper_segment, lower_segment = t
>>> upper_segment.area
100
>>> upper_segment.centroid
Point2D(10, 15/2)
>>> lower_segment.centroid
Point2D(10, 5/2)

工具书类

distance(o)[源代码]#

返回self和o之间的最短距离。

如果o是一个点,那么self不需要是凸的。如果o是另一个多边形,并且o必须是凸的。

实例

>>> from sympy import Point, Polygon, RegularPolygon
>>> p1, p2 = map(Point, [(0, 0), (7, 5)])
>>> poly = Polygon(*RegularPolygon(p1, 1, 3).vertices)
>>> poly.distance(p2)
sqrt(61)
encloses_point(p)[源代码]#

如果p被self括起来(在其内部),则返回True。

参数:

p :点

返回:

encloses_point :真、假或无

笔记

处于自我的边缘被认为是错误的。

实例

>>> from sympy import Polygon, Point
>>> p = Polygon((0, 0), (4, 0), (4, 4))
>>> p.encloses_point(Point(2, 1))
True
>>> p.encloses_point(Point(2, 2))
False
>>> p.encloses_point(Point(5, 5))
False

工具书类

first_moment_of_area(point=None)[源代码]#

返回二维多边形相对于某个关注点的面积矩。

面积矩是多边形面积相对于轴的分布的度量。整个多边形相对于其自身质心的面积第一矩始终为零。因此,这里计算的是某个兴趣点上方或下方的区域,该区域占多边形的较小部分。此区域以兴趣点和多边形的最末端(顶部或底部)为边界。这个区域的第一个力矩是关于初始多边形的质心轴确定的。

参数:

point: Point, two-tuple of sympifyable objects, or None (default=None)

点是指感兴趣区域位于其上方或下方的点,如果 point=None 然后质心作为兴趣点。

返回:

Q_x, Q_y: number or SymPy expressions

Q_x是关于x轴的第一个面积矩Q_y是关于y轴的第一个面积矩负号表示截面模量是针对形心轴以下(或左侧)的截面确定的

实例

>>> from sympy import Point, Polygon
>>> a, b = 50, 10
>>> p1, p2, p3, p4 = [(0, b), (0, 0), (a, 0), (a, b)]
>>> p = Polygon(p1, p2, p3, p4)
>>> p.first_moment_of_area()
(625, 3125)
>>> p.first_moment_of_area(point=Point(30, 7))
(525, 3000)

工具书类

intersection(o)[源代码]#

多边形与几何实体的交集。

交点可以为空,并且可以包含单独的点和完整的线段。

参数:

其他:几何体

返回:

交叉 :列表

线段和点的列表

实例

>>> from sympy import Point, Polygon, Line
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly1 = Polygon(p1, p2, p3, p4)
>>> p5, p6, p7 = map(Point, [(3, 2), (1, -1), (0, 2)])
>>> poly2 = Polygon(p5, p6, p7)
>>> poly1.intersection(poly2)
[Point2D(1/3, 1), Point2D(2/3, 0), Point2D(9/5, 1/5), Point2D(7/3, 1)]
>>> poly1.intersection(Line(p1, p2))
[Segment2D(Point2D(0, 0), Point2D(1, 0))]
>>> poly1.intersection(p1)
[Point2D(0, 0)]
is_convex()[源代码]#

多边形是凸的吗?

如果多边形的所有内角小于180度,且边与边之间没有交点,则它是凸的。

返回:

is_convex :布尔值

如果此多边形是凸的,则为True,否则为False。

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.is_convex()
True
property perimeter#

多边形的周长。

返回:

周长 :数字或基本实例

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.perimeter
sqrt(17) + 7
plot_interval(parameter='t')[源代码]#

多边形的默认几何绘图的绘图间隔。

参数:

参数 :str,可选

默认值为“t”。

返回:

plot_interval :list(绘图间隔)

[parameter, lower_bound, upper_bound]

实例

>>> from sympy import Polygon
>>> p = Polygon((0, 0), (1, 0), (1, 1))
>>> p.plot_interval()
[t, 0, 1]
polar_second_moment_of_area()[源代码]#

返回二维多边形的极模

它是面积第二矩的组成部分,通过垂直轴定理联系起来。平面面积二阶矩描述的是物体在受到平行于中心轴的平面上的力时,其抗偏转(弯曲)的能力,面积极秒矩描述了物体在垂直于物体中心轴的平面上(即平行于横截面)施加的力矩时,其抗偏转能力

实例

>>> from sympy import Polygon, symbols
>>> a, b = symbols('a, b')
>>> rectangle = Polygon((0, 0), (a, 0), (a, b), (0, b))
>>> rectangle.polar_second_moment_of_area()
a**3*b/12 + a*b**3/12

工具书类

second_moment_of_area(point=None)[源代码]#

返回二维多边形面积的二阶矩和积矩。

参数:

:Point、可聚合对象的两个元组或无(默认值=无)

点是求面积第二矩的点。如果“point=None”,则将围绕穿过多边形质心的轴进行计算。

返回:

I_xx, I_yy, I_xy : number or SymPy expression

Iu-xx,Iu-yy是二维多边形的面积二阶矩。y是二维多边形的面积积矩。

实例

>>> from sympy import Polygon, symbols
>>> a, b = symbols('a, b')
>>> p1, p2, p3, p4, p5 = [(0, 0), (a, 0), (a, b), (0, b), (a/3, b/3)]
>>> rectangle = Polygon(p1, p2, p3, p4)
>>> rectangle.second_moment_of_area()
(a*b**3/12, a**3*b/12, 0)
>>> rectangle.second_moment_of_area(p5)
(a*b**3/9, a**3*b/9, a**2*b**2/36)

工具书类

section_modulus(point=None)[源代码]#

返回具有二维多边形截面模数的元组。

截面模量是多边形的几何性质,定义为面积第二力矩与多边形最末端到质心轴的距离之比。

参数:

:Point、可聚合对象的两个元组或无(默认值=无)

点是找到截面模量的点。如果“point=None”(点=无),则计算距离多边形质心轴最远的点。

返回:

S_x,S峎y:数字或SymPy表达式

S_x是相对于x轴的截面模量S_y是相对于y轴的截面模量负号表示截面模量是针对形心轴下方的一点确定的

实例

>>> from sympy import symbols, Polygon, Point
>>> a, b = symbols('a, b', positive=True)
>>> rectangle = Polygon((0, 0), (a, 0), (a, b), (0, b))
>>> rectangle.section_modulus()
(a*b**2/6, a**2*b/6)
>>> rectangle.section_modulus(Point(a/4, b/4))
(-a*b**2/3, -a**2*b/3)

工具书类

property sides#

形成多边形边的有向线段。

返回:

:边列表

每边都是有向线段。

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.sides
[Segment2D(Point2D(0, 0), Point2D(1, 0)),
Segment2D(Point2D(1, 0), Point2D(5, 1)),
Segment2D(Point2D(5, 1), Point2D(0, 1)), Segment2D(Point2D(0, 1), Point2D(0, 0))]
property vertices#

多边形的顶点。

返回:

顶点 :点列表

笔记

迭代顶点时,索引自身比请求顶点并索引它们更有效。仅当要同时处理所有顶点时才使用这些顶点。对于计算每个顶点的规则多边形,这一点更为重要。

实例

>>> from sympy import Point, Polygon
>>> p1, p2, p3, p4 = map(Point, [(0, 0), (1, 0), (5, 1), (0, 1)])
>>> poly = Polygon(p1, p2, p3, p4)
>>> poly.vertices
[Point2D(0, 0), Point2D(1, 0), Point2D(5, 1), Point2D(0, 1)]
>>> poly.vertices[0]
Point2D(0, 0)
class sympy.geometry.polygon.RegularPolygon(c, r, n, rot=0, **kwargs)[源代码]#

正多边形。

这样一个多边形的所有内角相等,所有边的长度相等。

参数:

中心 :点

半径 :数字或基本实例

从中心到顶点的距离

n :内景

边数

加薪:

GeometryError

如果 \(center\) 不是一个点,或者 \(radius\) 不是一个数或基本实例,也不是边数, \(n\) ,小于3。

笔记

正则多边形可以用带kwargn的多边形实例化。

规则多边形用中心、半径、边数和旋转角度实例化。而多边形的自变量是顶点,则正则多边形的顶点必须用顶点法求出。

实例

>>> from sympy import RegularPolygon, Point
>>> r = RegularPolygon(Point(0, 0), 5, 3)
>>> r
RegularPolygon(Point2D(0, 0), 5, 3, 0)
>>> r.vertices[0]
Point2D(5, 0)

属性

顶点

中心

半径

旋转

阿波托姆

interior_angle

exterior_angle

外接圆

内圆

property angles#

返回一个字典,其中包含键、多边形的顶点、值以及每个顶点处的内角。

实例

>>> from sympy import RegularPolygon, Point
>>> r = RegularPolygon(Point(0, 0), 5, 3)
>>> r.angles
{Point2D(-5/2, -5*sqrt(3)/2): pi/3,
 Point2D(-5/2, 5*sqrt(3)/2): pi/3,
 Point2D(5, 0): pi/3}
property apothem#

正多边形的内半径。

Apothes/inradius是内接圆的半径。

返回:

阿波托姆 :Basic的编号或实例

实例

>>> from sympy import Symbol
>>> from sympy import RegularPolygon, Point
>>> radius = Symbol('r')
>>> rp = RegularPolygon(Point(0, 0), radius, 4)
>>> rp.apothem
sqrt(2)*r/2
property area#

返回区域。

实例

>>> from sympy import RegularPolygon
>>> square = RegularPolygon((0, 0), 1, 4)
>>> square.area
2
>>> _ == square.length**2
True
property args#

返回圆心、半径、边数和方向角。

实例

>>> from sympy import RegularPolygon, Point
>>> r = RegularPolygon(Point(0, 0), 5, 3)
>>> r.args
(Point2D(0, 0), 5, 3, 0)
property center#

正多边形的中心

这也是外切圆的中心。

返回:

中心 :点

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 5, 4)
>>> rp.center
Point2D(0, 0)
property centroid#

正多边形的中心

这也是外切圆的中心。

返回:

中心 :点

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 5, 4)
>>> rp.center
Point2D(0, 0)
property circumcenter#

中心的别名。

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 5, 4)
>>> rp.circumcenter
Point2D(0, 0)
property circumcircle#

正多边形的外接圆。

返回:

外接圆 :圆形

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 4, 8)
>>> rp.circumcircle
Circle(Point2D(0, 0), 4)
property circumradius#

半径的别名。

实例

>>> from sympy import Symbol
>>> from sympy import RegularPolygon, Point
>>> radius = Symbol('r')
>>> rp = RegularPolygon(Point(0, 0), radius, 4)
>>> rp.circumradius
r
encloses_point(p)[源代码]#

如果p被self括起来(在其内部),则返回True。

参数:

p :点

返回:

encloses_point :真、假或无

笔记

处于自我的边缘被认为是错误的。

将军Polygon.enclosures_点方法仅当一个点分别不在内圆或外圆之内或之外时调用。

实例

>>> from sympy import RegularPolygon, S, Point, Symbol
>>> p = RegularPolygon((0, 0), 3, 4)
>>> p.encloses_point(Point(0, 0))
True
>>> r, R = p.inradius, p.circumradius
>>> p.encloses_point(Point((r + R)/2, 0))
True
>>> p.encloses_point(Point(R/2, R/2 + (R - r)/10))
False
>>> t = Symbol('t', real=True)
>>> p.encloses_point(p.arbitrary_point().subs(t, S.Half))
False
>>> p.encloses_point(Point(5, 5))
False
property exterior_angle#

测量外角。

返回:

exterior_angle :编号

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 4, 8)
>>> rp.exterior_angle
pi/4
property incircle#

正多边形的内圆。

返回:

内圆 :圆形

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 4, 7)
>>> rp.incircle
Circle(Point2D(0, 0), 4*cos(pi/7))
property inradius#

apothem的别名。

实例

>>> from sympy import Symbol
>>> from sympy import RegularPolygon, Point
>>> radius = Symbol('r')
>>> rp = RegularPolygon(Point(0, 0), radius, 4)
>>> rp.inradius
sqrt(2)*r/2
property interior_angle#

内角的测量。

返回:

interior_angle :编号

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 4, 8)
>>> rp.interior_angle
3*pi/4
property length#

返回边的长度。

边的一半长度和顶点构成直角三角形的两条腿,直角三角形的斜边是正多边形的半径。

实例

>>> from sympy import RegularPolygon
>>> from sympy import sqrt
>>> s = square_in_unit_circle = RegularPolygon((0, 0), 1, 4)
>>> s.length
sqrt(2)
>>> sqrt((_/2)**2 + s.apothem**2) == s.radius
True
property radius#

正多边形半径

这也是外切圆的半径。

返回:

半径 :Basic的编号或实例

实例

>>> from sympy import Symbol
>>> from sympy import RegularPolygon, Point
>>> radius = Symbol('r')
>>> rp = RegularPolygon(Point(0, 0), radius, 4)
>>> rp.radius
r
reflect(line)[源代码]#

覆盖几何实体.反射因为这不仅仅是点。

实例

>>> from sympy import RegularPolygon, Line
>>> RegularPolygon((0, 0), 1, 4).reflect(Line((0, 1), slope=-2))
RegularPolygon(Point2D(4/5, 2/5), -1, 4, atan(4/3))
rotate(angle, pt=None)[源代码]#

覆盖几何实体.旋转首先围绕其中心旋转规则多边形。

>>> from sympy import Point, RegularPolygon, pi
>>> t = RegularPolygon(Point(1, 0), 1, 3)
>>> t.vertices[0] # vertex on x-axis
Point2D(2, 0)
>>> t.rotate(pi/2).vertices[0] # vertex on y axis now
Point2D(0, 2)

参见

rotation

spin

在位旋转规则多边形

property rotation#

正多边形旋转的逆时针角

返回:

旋转 :Basic的编号或实例

实例

>>> from sympy import pi
>>> from sympy.abc import a
>>> from sympy import RegularPolygon, Point
>>> RegularPolygon(Point(0, 0), 3, 4, pi/4).rotation
pi/4

数字旋转角度是标准的:

>>> RegularPolygon(Point(0, 0), 3, 4, a).rotation
a
>>> RegularPolygon(Point(0, 0), 3, 4, pi).rotation
0
scale(x=1, y=1, pt=None)[源代码]#

超越几何测量比例尺因为它是必须缩放的半径(如果x==y),否则必须返回新多边形。

>>> from sympy import RegularPolygon

对称缩放返回规则多边形:

>>> RegularPolygon((0, 0), 1, 4).scale(2, 2)
RegularPolygon(Point2D(0, 0), 2, 4, 0)

不对称缩放将风筝返回为多边形:

>>> RegularPolygon((0, 0), 1, 4).scale(2, 1)
Polygon(Point2D(2, 0), Point2D(0, 1), Point2D(-2, 0), Point2D(0, -1))
spin(angle)[源代码]#

增量 就位 虚拟多边形的逆时针旋转。

另请参见:移动中心的旋转方法。

>>> from sympy import Polygon, Point, pi
>>> r = Polygon(Point(0,0), 1, n=3)
>>> r.vertices[0]
Point2D(1, 0)
>>> r.spin(pi/6)
>>> r.vertices[0]
Point2D(sqrt(3)/2, 1/2)

参见

rotation

rotate

创建围绕点旋转的规则多边形的副本

property vertices#

规则多边形的顶点。

返回:

顶点 :列表

每个顶点都是一个点。

实例

>>> from sympy import RegularPolygon, Point
>>> rp = RegularPolygon(Point(0, 0), 5, 4)
>>> rp.vertices
[Point2D(5, 0), Point2D(0, 5), Point2D(-5, 0), Point2D(0, -5)]
class sympy.geometry.polygon.Triangle(*args, **kwargs)[源代码]#

有三个顶点和三条边的多边形。

参数:

:点序列

keyword: asa, sas, or sss to specify sides/angles of the triangle

加薪:

GeometryError

如果顶点数不等于三,或者其中一个顶点不是点,或者没有给出有效的关键字。

实例

>>> from sympy import Triangle, Point
>>> Triangle(Point(0, 0), Point(4, 0), Point(4, 3))
Triangle(Point2D(0, 0), Point2D(4, 0), Point2D(4, 3))

关键字sss、sas或asa可用于给出定义三角形的所需边长(按顺序)和内角(以度为单位):

>>> Triangle(sss=(3, 4, 5))
Triangle(Point2D(0, 0), Point2D(3, 0), Point2D(3, 4))
>>> Triangle(asa=(30, 1, 30))
Triangle(Point2D(0, 0), Point2D(1, 0), Point2D(1/2, sqrt(3)/6))
>>> Triangle(sas=(1, 45, 2))
Triangle(Point2D(0, 0), Point2D(2, 0), Point2D(sqrt(2)/2, sqrt(2)/2))

属性

顶点

海拔

正中心

圆周中心

外接圆

外接圆

雷迪乌斯

内圆

外半径

中间带

内侧

nine_point_circle

property altitudes#

三角形的高度。

三角形的高度是通过一个顶点的线段,垂直于对边,长度是从包含该边的直线测量的顶点的高度。

返回:

海拔 :dict命令

字典由顶点键和段值组成。

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.altitudes[p1]
Segment2D(Point2D(0, 0), Point2D(1/2, 1/2))
bisectors()[源代码]#

三角形的角平分线。

三角形的角平分线是通过一个顶点的直线,该顶点将相应的角切成两半。

返回:

平分线 :dict命令

每个关键点是一个顶点(点),每个值是相应的平分线(线段)。

实例

>>> from sympy import Point, Triangle, Segment
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> from sympy import sqrt
>>> t.bisectors()[p2] == Segment(Point(1, 0), Point(0, sqrt(2) - 1))
True
property circumcenter#

三角形的外心

外接圆就是外接圆的中心。

返回:

圆周中心 :点

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.circumcenter
Point2D(1/2, 1/2)
property circumcircle#

穿过三角形三个顶点的圆。

返回:

外接圆 :圆形

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.circumcircle
Circle(Point2D(1/2, 1/2), sqrt(2)/2)
property circumradius#

三角形外接圆的半径。

返回:

外接圆 :基本实例数

实例

>>> from sympy import Symbol
>>> from sympy import Point, Triangle
>>> a = Symbol('a')
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, a)
>>> t = Triangle(p1, p2, p3)
>>> t.circumradius
sqrt(a**2/4 + 1/4)
property eulerline#

三角形的欧拉线。

通过外心、质心和正交中心的线。

返回:

欧拉线 :直线(或等边三角形的点,在这种情况下

中心重合)

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.eulerline
Line2D(Point2D(0, 0), Point2D(1/2, 1/2))
property excenters#

三角形的中心。

外圆心是一个圆的中心,它与三角形的一条边和另两条边的延伸相切。

返回:

超中心 :dict命令

实例

外圆心键控到三角形的相应外圆相切的一侧:中心是键控的,例如,与边0接触的圆的超中心是:

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(6, 0), Point(0, 2)
>>> t = Triangle(p1, p2, p3)
>>> t.excenters[t.sides[0]]
Point2D(12*sqrt(10), 2/3 + sqrt(10)/3)

工具书类

property exradii#

三角形外圆的半径。

三角形的外圆是三角形外的一个圆,与三角形的一条边相切,与另两条边的延伸相切。

返回:

外半径 :dict命令

实例

exradius接触到它被键入的三角形的边,例如exradius接触面2是:

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(6, 0), Point(0, 2)
>>> t = Triangle(p1, p2, p3)
>>> t.exradii[t.sides[2]]
-2 + sqrt(10)

工具书类

property incenter#

内圆的中心。

内圆是三角形内的圆,与三条边都接触。

返回:

中心 :点

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.incenter
Point2D(1 - sqrt(2)/2, 1 - sqrt(2)/2)
property incircle#

三角形的内圆。

内圆是三角形内的圆,与三条边都接触。

返回:

内圆 :圆形

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(2, 0), Point(0, 2)
>>> t = Triangle(p1, p2, p3)
>>> t.incircle
Circle(Point2D(2 - sqrt(2), 2 - sqrt(2)), 2 - sqrt(2))
property inradius#

内圆的半径。

返回:

雷迪乌斯 :基本实例数

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(4, 0), Point(0, 3)
>>> t = Triangle(p1, p2, p3)
>>> t.inradius
1
is_equilateral()[源代码]#

两边都一样长吗?

返回:

is_equilateral :布尔值

实例

>>> from sympy import Triangle, Point
>>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3))
>>> t1.is_equilateral()
False
>>> from sympy import sqrt
>>> t2 = Triangle(Point(0, 0), Point(10, 0), Point(5, 5*sqrt(3)))
>>> t2.is_equilateral()
True
is_isosceles()[源代码]#

两个或多个边的长度相同吗?

返回:

is_isosceles :布尔值

实例

>>> from sympy import Triangle, Point
>>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(2, 4))
>>> t1.is_isosceles()
True
is_right()[源代码]#

三角形是直角的。

返回:

is_right :布尔值

实例

>>> from sympy import Triangle, Point
>>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3))
>>> t1.is_right()
True
is_scalene()[源代码]#

三角形的所有边都有不同的长度吗?

返回:

is_scalene :布尔值

实例

>>> from sympy import Triangle, Point
>>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(1, 4))
>>> t1.is_scalene()
True
is_similar(t2)[源代码]#

是另一个和这个相似的三角形。

如果一个三角形可以统一缩放到另一个三角形,则两个三角形相似。

参数:

其他:三角形

返回:

is_similar :布尔值

实例

>>> from sympy import Triangle, Point
>>> t1 = Triangle(Point(0, 0), Point(4, 0), Point(4, 3))
>>> t2 = Triangle(Point(0, 0), Point(-4, 0), Point(-4, -3))
>>> t1.is_similar(t2)
True
>>> t2 = Triangle(Point(0, 0), Point(-4, 0), Point(-4, -4))
>>> t1.is_similar(t2)
False
property medial#

三角形的中间三角形。

由三条边的中点形成的三角形。

返回:

内侧 :三角形

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.medial
Triangle(Point2D(1/2, 0), Point2D(1/2, 1/2), Point2D(0, 1/2))
property medians#

三角形的中间点。

三角形的中线是一条穿过顶点和对边中点的直线,并将三角形分成两个相等的区域。

返回:

中间带 :dict命令

每个关键点是一个顶点(点),每个值都是该点的中值(段)。

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.medians[p1]
Segment2D(Point2D(0, 0), Point2D(1/2, 1/2))
property nine_point_circle#

三角形的九点圆。

九点圆是中间三角形的外接圆,它穿过高度的脚和连接顶点和正中心的线段的中点。

返回:

nine_point_circle :圆形

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.nine_point_circle
Circle(Point2D(1/4, 1/4), sqrt(2)/4)
property orthocenter#

三角形的正中心。

正交中心是三角形高度的交点。它可能在里面,外面或者三角形上。

返回:

正中心 :点

实例

>>> from sympy import Point, Triangle
>>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1)
>>> t = Triangle(p1, p2, p3)
>>> t.orthocenter
Point2D(0, 0)
property vertices#

三角形的顶点

返回:

顶点 :元组

元组中的每个元素都是一个点

实例

>>> from sympy import Triangle, Point
>>> t = Triangle(Point(0, 0), Point(4, 0), Point(4, 3))
>>> t.vertices
(Point2D(0, 0), Point2D(4, 0), Point2D(4, 3))