省略号#
- class sympy.geometry.ellipse.Ellipse(center=None, hradius=None, vradius=None, eccentricity=None, **kwargs)[源代码]#
椭圆几何体。
- 参数:
中心 :点,可选
默认值为点(0,0)
赫拉迪乌斯 :number或SymPy表达式,可选
弗拉迪乌斯 :number或SymPy表达式,可选
偏心 :number或SymPy表达式,可选
两个 \(hradius\) , \(vradius\) 和 \(eccentricity\) 必须提供以创建椭圆。第三种来源于所提供的两种。
- 加薪:
GeometryError
什么时候? \(hradius\) , \(vradius\) 和 \(eccentricity\) 不正确地作为参数提供。
TypeError
什么时候? \(center\) 不是重点。
笔记
由一个中心和两个半径构成,第一个是水平半径(沿x轴),第二个是垂直半径(沿y轴)。
当使用hradius和vradius的符号值时,任何涉及焦点或长轴或短轴的计算都将假定椭圆的大半径在x轴上。如果不是这样,则需要手动旋转。
实例
>>> from sympy import Ellipse, Point, Rational >>> e1 = Ellipse(Point(0, 0), 5, 1) >>> e1.hradius, e1.vradius (5, 1) >>> e2 = Ellipse(Point(3, 1), hradius=3, eccentricity=Rational(4, 5)) >>> e2 Ellipse(Point2D(3, 1), 3, 9/5)
参见
属性
中心
赫拉迪乌斯
弗拉迪乌斯
地区
圆周
偏心
近虹膜
远视
focus_distance
焦点
- property apoapsis#
椭圆的最远点。
焦点和轮廓之间的最大距离。
- 返回:
远视 :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.apoapsis 2*sqrt(2) + 3
参见
periapsis
返回焦点和轮廓之间的最短距离
- arbitrary_point(parameter='t')[源代码]#
椭圆上的参数化点。
- 参数:
参数 :str,可选
默认值为“t”。
- 返回:
arbitrary_point :点
- 加薪:
ValueError
什么时候? \(parameter\) 已经出现在函数中。
实例
>>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.arbitrary_point() Point2D(3*cos(t), 2*sin(t))
- property area#
椭圆的面积。
- 返回:
area :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.area 3*pi
- auxiliary_circle()[源代码]#
返回直径为椭圆长轴的圆。
实例
>>> from sympy import Ellipse, Point, symbols >>> c = Point(1, 2) >>> Ellipse(c, 8, 7).auxiliary_circle() Circle(Point2D(1, 2), 8) >>> a, b = symbols('a b') >>> Ellipse(c, a, b).auxiliary_circle() Circle(Point2D(1, 2), Max(a, b))
- property bounds#
xmax,在矩形中表示xmax,表示图形中的xmax。
- property center#
椭圆的中心。
- 返回:
中心 :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.center Point2D(0, 0)
- property circumference#
椭圆的周长。
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.circumference 12*elliptic_e(8/9)
- director_circle()[源代码]#
返回由椭圆的两条垂直切线相交的所有点组成的圆。
- 返回:
圆圈
作为几何对象返回的定向圆。
实例
>>> from sympy import Ellipse, Point, symbols >>> c = Point(3,8) >>> Ellipse(c, 7, 9).director_circle() Circle(Point2D(3, 8), sqrt(130)) >>> a, b = symbols('a b') >>> Ellipse(c, a, b).director_circle() Circle(Point2D(3, 8), sqrt(a**2 + b**2))
工具书类
- property eccentricity#
椭圆的偏心率。
- 返回:
偏心 :编号
实例
>>> from sympy import Point, Ellipse, sqrt >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, sqrt(2)) >>> e1.eccentricity sqrt(7)/3
- encloses_point(p)[源代码]#
如果p被self括起来(在其内部),则返回True。
- 参数:
p :点
- 返回:
encloses_point :真、假或无
笔记
处于自我的边缘被认为是错误的。
实例
>>> from sympy import Ellipse, S >>> from sympy.abc import t >>> e = Ellipse((0, 0), 3, 2) >>> e.encloses_point((0, 0)) True >>> e.encloses_point(e.arbitrary_point(t).subs(t, S.Half)) False >>> e.encloses_point((4, 0)) False
- equation(x='x', y='y', _slope=None)[源代码]#
返回与x和y轴对齐的椭圆的方程;当给定斜率时,返回的方程对应于一个长轴具有该斜率的椭圆。
- 参数:
x :str,可选
x轴的标签。默认值为“x”。
y :str,可选
y轴的标签。默认值为“y”。
_slope :Expr,可选
长轴的斜率。“无”时忽略。
- 返回:
方程式 :SymPy表达式
实例
>>> from sympy import Point, Ellipse, pi >>> from sympy.abc import x, y >>> e1 = Ellipse(Point(1, 0), 3, 2) >>> eq1 = e1.equation(x, y); eq1 y**2/4 + (x/3 - 1/3)**2 - 1 >>> eq2 = e1.equation(x, y, _slope=1); eq2 (-x + y + 1)**2/8 + (x + y - 1)**2/18 - 1
e1上的一点满足eq1。让我们在x轴上使用一个:
>>> p1 = e1.center + Point(e1.major, 0) >>> assert eq1.subs(x, p1.x).subs(y, p1.y) == 0
当与旋转椭圆相同,围绕椭圆的中心点旋转时,也将满足旋转椭圆的方程:
>>> r1 = p1.rotate(pi/4, e1.center) >>> assert eq2.subs(x, r1.x).subs(y, r1.y) == 0
参见
arbitrary_point
返回椭圆上的参数化点
工具书类
- evolute(x='x', y='y')[源代码]#
椭圆的渐屈线方程。
- 参数:
x :str,可选
x轴的标签。默认值为“x”。
y :str,可选
y轴的标签。默认值为“y”。
- 返回:
方程式 :SymPy表达式
实例
>>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(1, 0), 3, 2) >>> e1.evolute() 2**(2/3)*y**(2/3) + (3*x - 3)**(2/3) - 5**(2/3)
- property foci#
椭圆的焦点。
- 加薪:
ValueError
无法确定长轴和短轴时。
笔记
只有在长轴/短轴已知的情况下才能计算焦点。
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.foci (Point2D(-2*sqrt(2), 0), Point2D(2*sqrt(2), 0))
- property focus_distance#
椭圆的焦距。
中心和一个焦点之间的距离。
- 返回:
focus_distance :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.focus_distance 2*sqrt(2)
参见
- property hradius#
椭圆的水平半径。
- 返回:
赫拉迪乌斯 :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.hradius 3
- intersection(o)[源代码]#
这个椭圆和另一个几何实体的交点 \(o\) .
- 参数:
o :几何体
- 返回:
交叉 :几何实体对象列表
笔记
当前支持点、直线、线段、射线、圆和椭圆类型的交点。
实例
>>> from sympy import Ellipse, Point, Line >>> e = Ellipse(Point(0, 0), 5, 7) >>> e.intersection(Point(0, 0)) [] >>> e.intersection(Point(5, 0)) [Point2D(5, 0)] >>> e.intersection(Line(Point(0,0), Point(0, 1))) [Point2D(0, -7), Point2D(0, 7)] >>> e.intersection(Line(Point(5,0), Point(5, 1))) [Point2D(5, 0)] >>> e.intersection(Line(Point(6,0), Point(6, 1))) [] >>> e = Ellipse(Point(-1, 0), 4, 3) >>> e.intersection(Ellipse(Point(1, 0), 4, 3)) [Point2D(0, -3*sqrt(15)/4), Point2D(0, 3*sqrt(15)/4)] >>> e.intersection(Ellipse(Point(5, 0), 4, 3)) [Point2D(2, -3*sqrt(7)/4), Point2D(2, 3*sqrt(7)/4)] >>> e.intersection(Ellipse(Point(100500, 0), 4, 3)) [] >>> e.intersection(Ellipse(Point(0, 0), 3, 4)) [Point2D(3, 0), Point2D(-363/175, -48*sqrt(111)/175), Point2D(-363/175, 48*sqrt(111)/175)] >>> e.intersection(Ellipse(Point(-1, 0), 3, 4)) [Point2D(-17/5, -12/5), Point2D(-17/5, 12/5), Point2D(7/5, -12/5), Point2D(7/5, 12/5)]
- is_tangent(o)[源代码]#
是 \(o\) 与椭圆相切?
- 参数:
o :几何体
椭圆、直线或多边形
- 返回:
is_tangent:布尔
如果o与椭圆相切,则为True,否则为False。
- 加薪:
NotImplementedError
当提供错误类型的参数时。
实例
>>> from sympy import Point, Ellipse, Line >>> p0, p1, p2 = Point(0, 0), Point(3, 0), Point(3, 3) >>> e1 = Ellipse(p0, 3, 2) >>> l1 = Line(p1, p2) >>> e1.is_tangent(l1) True
- property major#
椭圆的长轴(如果可以确定的话)或赫拉迪乌斯。
- 返回:
专业 :数字或表达式
实例
>>> from sympy import Point, Ellipse, Symbol >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.major 3
>>> a = Symbol('a') >>> b = Symbol('b') >>> Ellipse(p1, a, b).major a >>> Ellipse(p1, b, a).major b
>>> m = Symbol('m') >>> M = m + 1 >>> Ellipse(p1, m, M).major m + 1
- property minor#
椭圆的短轴(如果可以确定的话)或vradius。
- 返回:
少数的 :数字或表达式
实例
>>> from sympy import Point, Ellipse, Symbol >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.minor 1
>>> a = Symbol('a') >>> b = Symbol('b') >>> Ellipse(p1, a, b).minor b >>> Ellipse(p1, b, a).minor a
>>> m = Symbol('m') >>> M = m + 1 >>> Ellipse(p1, m, M).minor m
- normal_lines(p, prec=None)[源代码]#
正常线之间 \(p\) 还有椭圆。
- 参数:
p :点
- 返回:
normal_lines :用1、2或4行列出
实例
>>> from sympy import Point, Ellipse >>> e = Ellipse((0, 0), 2, 3) >>> c = e.center >>> e.normal_lines(c + Point(1, 0)) [Line2D(Point2D(0, 0), Point2D(1, 0))] >>> e.normal_lines(c) [Line2D(Point2D(0, 0), Point2D(0, 1)), Line2D(Point2D(0, 0), Point2D(1, 0))]
离轴点需要四次方程的解。这通常会导致非常大的表达式,而这些表达式可能几乎没有实际用途。的近似解 \(prec\) 通过传入所需的值可以获得数字:
>>> e.normal_lines((3, 3), prec=2) [Line2D(Point2D(-0.81, -2.7), Point2D(0.19, -1.2)), Line2D(Point2D(1.5, -2.0), Point2D(2.5, -2.7))]
上述解决方案的操作计数为12,而精确解决方案的操作计数为2020。
- property periapsis#
椭圆的近心点。
焦点和轮廓之间的最短距离。
- 返回:
近虹膜 :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.periapsis 3 - 2*sqrt(2)
参见
apoapsis
返回焦点和轮廓之间的最大距离
- plot_interval(parameter='t')[源代码]#
椭圆的默认几何绘图的绘图间隔。
- 参数:
参数 :str,可选
默认值为“t”。
- 返回:
plot_interval :列表
[parameter, lower_bound, upper_bound]
实例
>>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.plot_interval() [t, -pi, pi]
- polar_second_moment_of_area()[源代码]#
返回椭圆面积的极性第二矩
它是面积第二矩的组成部分,通过垂直轴定理联系起来。平面面积二阶矩描述的是物体在受到平行于中心轴的平面上的力时,其抗偏转(弯曲)的能力,面积极秒矩描述了物体在垂直于物体中心轴的平面上(即平行于横截面)施加的力矩时,其抗偏转能力
实例
>>> from sympy import symbols, Circle, Ellipse >>> c = Circle((5, 5), 4) >>> c.polar_second_moment_of_area() 128*pi >>> a, b = symbols('a, b') >>> e = Ellipse((0, 0), a, b) >>> e.polar_second_moment_of_area() pi*a**3*b/4 + pi*a*b**3/4
工具书类
- random_point(seed=None)[源代码]#
椭圆上的随机点。
- 返回:
点 :点
实例
>>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.random_point() # gives some random point Point2D(...) >>> p1 = e1.random_point(seed=0); p1.n(2) Point2D(2.1, 1.4)
笔记
当创建一个随机点时,可以简单地用一个随机数替换参数。然而,当这样做时,随机数应为有理数,否则该点可能无法测试为椭圆:
>>> from sympy.abc import t >>> from sympy import Rational >>> arb = e1.arbitrary_point(t); arb Point2D(3*cos(t), 2*sin(t)) >>> arb.subs(t, .1) in e1 False >>> arb.subs(t, Rational(.1)) in e1 True >>> arb.subs(t, Rational('.1')) in e1 True
- reflect(line)[源代码]#
覆盖几何实体.反射因为半径不是几何单位。
实例
>>> from sympy import Circle, Line >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1))) Circle(Point2D(1, 0), -1) >>> from sympy import Ellipse, Line, Point >>> Ellipse(Point(3, 4), 1, 3).reflect(Line(Point(0, -4), Point(5, 0))) Traceback (most recent call last): ... NotImplementedError: General Ellipse is not supported but the equation of the reflected Ellipse is given by the zeros of: f(x, y) = (9*x/41 + 40*y/41 + 37/41)**2 + (40*x/123 - 3*y/41 - 364/123)**2 - 1
笔记
在一般椭圆(没有平行于x轴的轴)被支持之前,提出了一个未实现的误差,并给出了定义旋转椭圆的零点方程。
- rotate(angle=0, pt=None)[源代码]#
旋转
angle
点的逆时针弧度pt
.注:由于不支持普通椭圆,因此只允许旋转pi/2的整数倍。
实例
>>> from sympy import Ellipse, pi >>> Ellipse((1, 0), 2, 1).rotate(pi/2) Ellipse(Point2D(0, 1), 1, 2) >>> Ellipse((1, 0), 2, 1).rotate(pi) Ellipse(Point2D(-1, 0), 2, 1)
- scale(x=1, y=1, pt=None)[源代码]#
覆盖几何体.比例尺因为长轴和短轴必须按比例缩放,它们不是几何量。
实例
>>> from sympy import Ellipse >>> Ellipse((0, 0), 2, 1).scale(2, 4) Circle(Point2D(0, 0), 4) >>> Ellipse((0, 0), 2, 1).scale(2) Ellipse(Point2D(0, 0), 4, 1)
- second_moment_of_area(point=None)[源代码]#
返回椭圆的二阶矩和积矩面积。
- 参数:
点 :Point、两个可解释对象的元组,或无(默认值为None)
点是求面积第二矩的点。如果“point=None”,则将围绕穿过椭圆质心的轴进行计算。
- 返回:
I_xx, I_yy, I_xy : number or SymPy expression
I_xx,I_yy是椭圆面积的第二时刻。y是椭圆面积的积矩。
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.second_moment_of_area() (3*pi/4, 27*pi/4, 0)
工具书类
- section_modulus(point=None)[源代码]#
返回具有椭圆截面模数的元组
截面模量是椭圆的几何性质,定义为截面二阶矩与椭圆最末端到质心轴的距离之比。
- 参数:
点 :Point、可聚合对象的两个元组或无(默认值=无)
点是找到截面模量的点。如果“点=无”将计算离椭圆质心轴最远的点的截面模量。
- 返回:
S_x,S峎y:数字或SymPy表达式
S_x是相对于x轴的截面模量S_y是相对于y轴的截面模量负号表示截面模量是针对形心轴下方的一点确定的。
实例
>>> from sympy import Symbol, Ellipse, Circle, Point2D >>> d = Symbol('d', positive=True) >>> c = Circle((0, 0), d/2) >>> c.section_modulus() (pi*d**3/32, pi*d**3/32) >>> e = Ellipse(Point2D(0, 0), 2, 4) >>> e.section_modulus() (8*pi, 4*pi) >>> e.section_modulus((2, 2)) (16*pi, 4*pi)
工具书类
- property semilatus_rectum#
计算椭圆的半椭圆直肠。
Semi-latus rectum is defined as one half of the chord through a focus parallel to the conic section directrix of a conic section.
- 返回:
semilatus_rectum :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.semilatus_rectum 1/3
工具书类
- tangent_lines(p)[源代码]#
切线之间 \(p\) 还有椭圆。
如果 \(p\) 在椭圆上,返回切线通过点 \(p\) . 否则,返回 \(p\) 如果没有切线,则为无(例如。, \(p\) 椭圆内部)。
- 参数:
p :点
- 返回:
tangent_lines :用1行或2行列出
- 加薪:
NotImplementedError
只能找到一个点的切线, \(p\) ,在椭圆上。
实例
>>> from sympy import Point, Ellipse >>> e1 = Ellipse(Point(0, 0), 3, 2) >>> e1.tangent_lines(Point(3, 0)) [Line2D(Point2D(3, 0), Point2D(3, -12))]
- property vradius#
椭圆的垂直半径。
- 返回:
弗拉迪乌斯 :编号
实例
>>> from sympy import Point, Ellipse >>> p1 = Point(0, 0) >>> e1 = Ellipse(p1, 3, 1) >>> e1.vradius 1
- class sympy.geometry.ellipse.Circle(*args, **kwargs)[源代码]#
空间中的一个圆圈。
由一个中心和一个半径、三个非共线点或圆的方程简单地构造出来的。
- 参数:
中心 :点
radius : number or SymPy expression
点 :三点序列
方程式 :圆方程
- 加薪:
GeometryError
当给定的方程不是圆的方程时。当试图用不正确的参数构造圆时。
实例
>>> from sympy import Point, Circle, Eq >>> from sympy.abc import x, y, a, b
由中心和半径构成的圆:
>>> c1 = Circle(Point(0, 0), 5) >>> c1.hradius, c1.vradius, c1.radius (5, 5, 5)
由三个点构成的圆:
>>> c2 = Circle(Point(0, 0), Point(1, 1), Point(1, 0)) >>> c2.hradius, c2.vradius, c2.radius, c2.center (sqrt(2)/2, sqrt(2)/2, sqrt(2)/2, Point2D(1/2, 1/2))
一个圆可以由以下形式的方程构成 \(a*x**2 + by**2 + gx + hy + c = 0\) ,也是:
>>> Circle(x**2 + y**2 - 25) Circle(Point2D(0, 0), 5)
如果与x和y相对应的变量被命名为其他名称,则可以提供它们的名称或符号:
>>> Circle(Eq(a**2 + b**2, 25), x='a', y=b) Circle(Point2D(0, 0), 5)
属性
半径(与赫拉迪乌斯、弗拉迪乌斯、大调和小调同义)
圆周
方程式
- property circumference#
圆的周长。
- 返回:
圆周 :number或SymPy表达式
实例
>>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.circumference 12*pi
- equation(x='x', y='y')[源代码]#
圆的方程式。
- 参数:
x :str或Symbol,可选
默认值为“x”。
y :str或Symbol,可选
默认值为“y”。
- 返回:
方程式 :SymPy表达式
实例
>>> from sympy import Point, Circle >>> c1 = Circle(Point(0, 0), 5) >>> c1.equation() x**2 + y**2 - 25
- intersection(o)[源代码]#
这个圆与另一个几何实体的交点。
- 参数:
o :几何体
- 返回:
交叉 :几何体列表
实例
>>> from sympy import Point, Circle, Line, Ray >>> p1, p2, p3 = Point(0, 0), Point(5, 5), Point(6, 0) >>> p4 = Point(5, 0) >>> c1 = Circle(p1, 5) >>> c1.intersection(p2) [] >>> c1.intersection(p4) [Point2D(5, 0)] >>> c1.intersection(Ray(p1, p2)) [Point2D(5*sqrt(2)/2, 5*sqrt(2)/2)] >>> c1.intersection(Line(p2, p3)) []
- property radius#
圆的半径。
- 返回:
radius : number or SymPy expression
实例
>>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.radius 6
- reflect(line)[源代码]#
覆盖几何实体.反射因为半径不是几何单位。
实例
>>> from sympy import Circle, Line >>> Circle((0, 1), 1).reflect(Line((0, 0), (1, 1))) Circle(Point2D(1, 0), -1)
- scale(x=1, y=1, pt=None)[源代码]#
覆盖几何体.比例尺因为半径不是几何单位。
实例
>>> from sympy import Circle >>> Circle((0, 0), 1).scale(2, 2) Circle(Point2D(0, 0), 2) >>> Circle((0, 0), 1).scale(2, 4) Ellipse(Point2D(0, 0), 2, 4)
- property vradius#
此椭圆属性是圆半径的别名。
虽然赫拉迪乌斯,大调和小调都可以使用椭圆的约定,但维拉迪乌斯并不存在于一个圆上。它总是一个正值,以便圆,像多边形一样,有一个面积,可以是正的,也可以是负的,由赫拉迪厄斯的符号决定。
实例
>>> from sympy import Point, Circle >>> c1 = Circle(Point(3, 4), 6) >>> c1.vradius 6