平面#

class sympy.geometry.plane.Plane(p1, a=None, b=None, **kwargs)[源代码]#

A plane is a flat, two-dimensional surface. A plane is the two-dimensional analogue of a point (zero-dimensions), a line (one-dimension) and a solid (three-dimensions). A plane can generally be constructed by two types of inputs. They are: - three non-collinear points - a point and the plane's normal vector

实例

>>> from sympy import Plane, Point3D
>>> Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2))
Plane(Point3D(1, 1, 1), (-1, 2, -1))
>>> Plane((1, 1, 1), (2, 3, 4), (2, 2, 2))
Plane(Point3D(1, 1, 1), (-1, 2, -1))
>>> Plane(Point3D(1, 1, 1), normal_vector=(1,4,7))
Plane(Point3D(1, 1, 1), (1, 4, 7))

属性

第一页

normal_vector

angle_between(o)[源代码]#

平面与其他几何实体的夹角。

参数:

线性度3D,平面。

返回:

:以弧度表示的角度

笔记

此方法只接受三维图元作为参数,但如果要计算二维图元与平面之间的角度,则应首先通过投影到所需平面来转换为三维图元,然后继续计算角度。

实例

>>> from sympy import Point3D, Line3D, Plane
>>> a = Plane(Point3D(1, 2, 2), normal_vector=(1, 2, 3))
>>> b = Line3D(Point3D(1, 3, 4), Point3D(2, 2, 2))
>>> a.angle_between(b)
-asin(sqrt(21)/6)
arbitrary_point(u=None, v=None)[源代码]#

返回平面上的任意点。如果给定两个参数,则点的范围覆盖整个平面。如果给定1个参数或没有参数,则返回一个具有一个参数的点,该参数在0到2*pi之间变化时,将该点在平面的p1半径为1的圆中移动。

返回:

三维点

实例

>>> from sympy import Plane, Ray
>>> from sympy.abc import u, v, t, r
>>> p = Plane((1, 1, 1), normal_vector=(1, 0, 0))
>>> p.arbitrary_point(u, v)
Point3D(1, u + 1, v + 1)
>>> p.arbitrary_point(t)
Point3D(1, cos(t) + 1, sin(t) + 1)

t可以从任意点的角度来构造任意点的半径

>>> Ray(p.p1, _).arbitrary_point(r)
Point3D(1, r*cos(t) + 1, r*sin(t) + 1)
static are_concurrent(*planes)[源代码]#

一系列的平面是并行的吗?

如果两个或多个平面的交点是一条公共线,则它们是并行的。

参数:

平面:列表

返回:

布尔

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(5, 0, 0), normal_vector=(1, -1, 1))
>>> b = Plane(Point3D(0, -2, 0), normal_vector=(3, 1, 1))
>>> c = Plane(Point3D(0, -1, 0), normal_vector=(5, -1, 9))
>>> Plane.are_concurrent(a, b)
True
>>> Plane.are_concurrent(a, b, c)
False
distance(o)[源代码]#

平面与另一几何实体之间的距离。

参数:

Point3D,LinearEntity3D,平面。

返回:

距离

笔记

此方法只接受三维图元作为参数,但如果要计算二维图元与平面之间的距离,则应首先通过投影到所需平面来转换为三维图元,然后再继续计算距离。

实例

>>> from sympy import Point3D, Line3D, Plane
>>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1))
>>> b = Point3D(1, 2, 3)
>>> a.distance(b)
sqrt(3)
>>> c = Line3D(Point3D(2, 3, 1), Point3D(1, 2, 2))
>>> a.distance(c)
0
equals(o)[源代码]#

如果self和o是相同的,则返回相同的数学实体。

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(1, 2, 3), normal_vector=(1, 1, 1))
>>> b = Plane(Point3D(1, 2, 3), normal_vector=(2, 2, 2))
>>> c = Plane(Point3D(1, 2, 3), normal_vector=(-1, 4, 6))
>>> a.equals(a)
True
>>> a.equals(b)
True
>>> a.equals(c)
False
equation(x=None, y=None, z=None)[源代码]#

平面方程。

实例

>>> from sympy import Point3D, Plane
>>> a = Plane(Point3D(1, 1, 2), Point3D(2, 4, 7), Point3D(3, 5, 1))
>>> a.equation()
-23*x + 11*y - 2*z + 16
>>> a = Plane(Point3D(1, 4, 2), normal_vector=(6, 6, 6))
>>> a.equation()
6*x + 6*y + 6*z - 42
intersection(o)[源代码]#

与其他几何实体的交集。

参数:

点,点3D,线性度,线性度3D,平面

返回:

实例

>>> from sympy import Point3D, Line3D, Plane
>>> a = Plane(Point3D(1, 2, 3), normal_vector=(1, 1, 1))
>>> b = Point3D(1, 2, 3)
>>> a.intersection(b)
[Point3D(1, 2, 3)]
>>> c = Line3D(Point3D(1, 4, 7), Point3D(2, 2, 2))
>>> a.intersection(c)
[Point3D(2, 2, 2)]
>>> d = Plane(Point3D(6, 0, 0), normal_vector=(2, -5, 3))
>>> e = Plane(Point3D(2, 0, 0), normal_vector=(3, 4, -3))
>>> d.intersection(e)
[Line3D(Point3D(78/23, -24/23, 0), Point3D(147/23, 321/23, 23))]
is_coplanar(o)[源代码]#

返回true \(o\) 与自我共面,否则就错了。

实例

>>> from sympy import Plane
>>> o = (0, 0, 0)
>>> p = Plane(o, (1, 1, 1))
>>> p2 = Plane(o, (2, 2, 2))
>>> p == p2
False
>>> p.is_coplanar(p2)
True
is_parallel(l)[源代码]#

给定的几何实体是否与平面平行?

参数:

线性度3D或平面

返回:

布尔

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6))
>>> b = Plane(Point3D(3,1,3), normal_vector=(4, 8, 12))
>>> a.is_parallel(b)
True
is_perpendicular(l)[源代码]#

Is the given geometric entity perpendicualar to the given plane?

参数:

线性度3D或平面

返回:

布尔

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6))
>>> b = Plane(Point3D(2, 2, 2), normal_vector=(-1, 2, -1))
>>> a.is_perpendicular(b)
True
property normal_vector#

给定平面的法向量。

实例

>>> from sympy import Point3D, Plane
>>> a = Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2))
>>> a.normal_vector
(-1, 2, -1)
>>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 4, 7))
>>> a.normal_vector
(1, 4, 7)
property p1#

平面的唯一定义点。其他可由任意点法得到。

实例

>>> from sympy import Point3D, Plane
>>> a = Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2))
>>> a.p1
Point3D(1, 1, 1)
parallel_plane(pt)[源代码]#

平行于给定平面并通过点pt的平面。

参数:

pt:Point3D

返回:

平面

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(1, 4, 6), normal_vector=(2, 4, 6))
>>> a.parallel_plane(Point3D(2, 3, 5))
Plane(Point3D(2, 3, 5), (2, 4, 6))
parameter_value(other, u, v=None)[源代码]#

返回与给定点对应的参数。

实例

>>> from sympy import pi, Plane
>>> from sympy.abc import t, u, v
>>> p = Plane((2, 0, 0), (0, 0, 1), (0, 1, 0))

默认情况下,返回的参数值定义了一个点,该点与平面的p1值的距离为1,并与给定点成直线:

>>> on_circle = p.arbitrary_point(t).subs(t, pi/4)
>>> on_circle.distance(p.p1)
1
>>> p.parameter_value(on_circle, t)
{t: pi/4}

将点移离p1两倍不会更改参数值:

>>> off_circle = p.p1 + (on_circle - p.p1)*2
>>> off_circle.distance(p.p1)
2
>>> p.parameter_value(off_circle, t)
{t: pi/4}

如果需要2值参数,请提供两个参数符号,将返回替换字典:

>>> p.parameter_value(on_circle, u, v)
{u: sqrt(10)/10, v: sqrt(10)/30}
>>> p.parameter_value(off_circle, u, v)
{u: sqrt(10)/5, v: sqrt(10)/15}
perpendicular_line(pt)[源代码]#

垂直于给定平面的线。

参数:

pt:Point3D

返回:

线条3D

实例

>>> from sympy import Plane, Point3D
>>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6))
>>> a.perpendicular_line(Point3D(9, 8, 7))
Line3D(Point3D(9, 8, 7), Point3D(11, 12, 13))
perpendicular_plane(*pts)[源代码]#

返回穿过给定点的垂直线。如果点之间的方向比与平面的法线向量相同,则要从无限数量的可能平面中选择,将在z轴上选择第三个点(如果法线向量已经平行于z轴,则选择y轴)。如果给定的点少于两个,则提供如下内容:如果没有给定点,则pt1将为自。p1;如果没有给出第二个点,则pt1将是平行于z轴的线上的一个点(如果法线不是z轴,否则位于平行于y轴的线上)。

参数:

点:0、1或2点3D

返回:

平面

实例

>>> from sympy import Plane, Point3D
>>> a, b = Point3D(0, 0, 0), Point3D(0, 1, 0)
>>> Z = (0, 0, 1)
>>> p = Plane(a, normal_vector=Z)
>>> p.perpendicular_plane(a, b)
Plane(Point3D(0, 0, 0), (1, 0, 0))
projection(pt)[源代码]#

将给定点沿平面法线投影到平面上。

参数:

点或点3D

返回:

三维点

实例

>>> from sympy import Plane, Point3D
>>> A = Plane(Point3D(1, 1, 2), normal_vector=(1, 1, 1))

投影沿法向量方向,而不是z轴,因此(1,1)不会投影到平面A上的(1,1,2):

>>> b = Point3D(1, 1)
>>> A.projection(b)
Point3D(5/3, 5/3, 2/3)
>>> _ in A
True

但是点(1,1,2)投影到XY平面上的(1,1):

>>> XY = Plane((0, 0, 0), (0, 0, 1))
>>> XY.projection((1, 1, 2))
Point3D(1, 1, 0)
projection_line(line)[源代码]#

通过包含该线的法向平面投影给定线。

参数:

线性度或线性度3D

返回:

Point3D、Line3D、Ray3D或Segment3D

笔记

对于二维和三维直线(线段、光线)之间的交互,应使用此方法将直线转换为三维。例如,要查找二维线和三维线之间的交点,请将二维线投影到所需平面上,将其转换为三维线,然后继续查找这些线之间的交点。

实例

>>> from sympy import Plane, Line, Line3D, Point3D
>>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1))
>>> b = Line(Point3D(1, 1), Point3D(2, 2))
>>> a.projection_line(b)
Line3D(Point3D(4/3, 4/3, 1/3), Point3D(5/3, 5/3, -1/3))
>>> c = Line3D(Point3D(1, 1, 1), Point3D(2, 2, 2))
>>> a.projection_line(c)
Point3D(1, 1, 1)
random_point(seed=None)[源代码]#

返回平面上的随机点。

返回:

三维点

实例

>>> from sympy import Plane
>>> p = Plane((1, 0, 0), normal_vector=(0, 1, 0))
>>> r = p.random_point(seed=42)  # seed value is optional
>>> r.n(3)
Point3D(2.29, 0, -1.35)

可以移动随机点,使其位于以p1为中心的半径为1的圆上:

>>> c = p.p1 + (r - p.p1).unit
>>> c.distance(p.p1).equals(1)
True