import{_ as l,c as a,j as s,a as e,a4 as t,o as i}from"./chunks/framework.DpC1ZpOZ.js";const Zs=JSON.parse('{"title":"mbcp.mp_math.plane","description":"","frontmatter":{"title":"mbcp.mp_math.plane","lastUpdated":false},"headers":[],"relativePath":"api/mp_math/plane.md","filePath":"zh/api/mp_math/plane.md"}'),n={name:"api/mp_math/plane.md"},h=t(`

模块 mbcp.mp_math.plane

本模块定义了三维空间中的平面类

class Plane3

method __init__(self, a: float, b: float, c: float, d: float)

说明: 平面方程:ax + by + cz + d = 0

参数:

源代码在GitHub上查看
python
def __init__(self, a: float, b: float, c: float, d: float):
    self.a = a
    self.b = b
    self.c = c
    self.d = d

method approx(self, other: Plane3) -> bool

说明: 判断两个平面是否近似相等。

参数:

返回: bool: 是否近似相等

源代码在GitHub上查看
python
def approx(self, other: 'Plane3') -> bool:
    if self.a != 0:
        k = other.a / self.a
        return approx(other.b, self.b * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
    elif self.b != 0:
        k = other.b / self.b
        return approx(other.a, self.a * k) and approx(other.c, self.c * k) and approx(other.d, self.d * k)
    elif self.c != 0:
        k = other.c / self.c
        return approx(other.a, self.a * k) and approx(other.b, self.b * k) and approx(other.d, self.d * k)
    else:
        return False

method cal_angle(self, other: Line3 | Plane3) -> AnyAngle

说明: 计算平面与平面之间的夹角。

`,16),p={class:"tip custom-block"},r=s("p",{class:"custom-block-title"},"TIP",-1),o=s("p",null,"平面间夹角计算公式:",-1),k={tabindex:"0",class:"MathJax",jax:"SVG",display:"true",style:{direction:"ltr",display:"block","text-align":"center",margin:"1em 0",position:"relative"}},d={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-2.17ex"},xmlns:"http://www.w3.org/2000/svg",width:"22.011ex",height:"5.206ex",role:"img",focusable:"false",viewBox:"0 -1342 9729 2301","aria-hidden":"true"},Q=t('',1),T=[Q],g=s("mjx-assistive-mml",{unselectable:"on",display:"block",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",overflow:"hidden",width:"100%"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("mi",null,"θ"),s("mo",null,"="),s("mi",null,"arccos"),s("mo",{"data-mjx-texclass":"NONE"},"⁡"),s("mo",{stretchy:"false"},"("),s("mfrac",null,[s("mrow",null,[s("mi",null,"n"),s("mn",null,"1"),s("mo",null,"⋅"),s("mi",null,"n"),s("mn",null,"2")]),s("mrow",null,[s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mi",null,"n"),s("mn",null,"1"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mo",null,"⋅"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mi",null,"n"),s("mn",null,"2"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|")])]),s("mo",{stretchy:"false"},")")])],-1),m={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},c={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.489ex",height:"1.532ex",role:"img",focusable:"false",viewBox:"0 -666 1100 677","aria-hidden":"true"},E=t('',1),y=[E],u=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"n"),s("mn",null,"1")])],-1),F={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},f={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.489ex",height:"1.532ex",role:"img",focusable:"false",viewBox:"0 -666 1100 677","aria-hidden":"true"},b=t('',1),_=[b],C=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"n"),s("mn",null,"2")])],-1),x={class:"tip custom-block"},w=s("p",{class:"custom-block-title"},"TIP",-1),H=s("p",null,"平面与直线夹角计算公式:",-1),L={tabindex:"0",class:"MathJax",jax:"SVG",display:"true",style:{direction:"ltr",display:"block","text-align":"center",margin:"1em 0",position:"relative"}},D={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-2.17ex"},xmlns:"http://www.w3.org/2000/svg",width:"19.568ex",height:"5.269ex",role:"img",focusable:"false",viewBox:"0 -1370 8649 2329","aria-hidden":"true"},A=t('',1),v=[A],B=s("mjx-assistive-mml",{unselectable:"on",display:"block",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",overflow:"hidden",width:"100%"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("mi",null,"θ"),s("mo",null,"="),s("mi",null,"arccos"),s("mo",{"data-mjx-texclass":"NONE"},"⁡"),s("mo",{stretchy:"false"},"("),s("mfrac",null,[s("mrow",null,[s("mi",null,"n"),s("mo",null,"⋅"),s("mi",null,"d")]),s("mrow",null,[s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mi",null,"n"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mo",null,"⋅"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|"),s("mi",null,"d"),s("mo",{"data-mjx-texclass":"ORD",stretchy:"false"},"|")])]),s("mo",{stretchy:"false"},")")])],-1),M={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},V={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.357ex",height:"1.025ex",role:"img",focusable:"false",viewBox:"0 -442 600 453","aria-hidden":"true"},Z=s("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[s("g",{"data-mml-node":"math"},[s("g",{"data-mml-node":"mi"},[s("path",{"data-c":"1D45B",d:"M21 287Q22 293 24 303T36 341T56 388T89 425T135 442Q171 442 195 424T225 390T231 369Q231 367 232 367L243 378Q304 442 382 442Q436 442 469 415T503 336T465 179T427 52Q427 26 444 26Q450 26 453 27Q482 32 505 65T540 145Q542 153 560 153Q580 153 580 145Q580 144 576 130Q568 101 554 73T508 17T439 -10Q392 -10 371 17T350 73Q350 92 386 193T423 345Q423 404 379 404H374Q288 404 229 303L222 291L189 157Q156 26 151 16Q138 -11 108 -11Q95 -11 87 -5T76 7T74 17Q74 30 112 180T152 343Q153 348 153 366Q153 405 129 405Q91 405 66 305Q60 285 60 284Q58 278 41 278H27Q21 284 21 287Z",style:{"stroke-width":"3"}})])])],-1),P=[Z],q=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"n")])],-1),S={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},j={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.023ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.176ex",height:"1.593ex",role:"img",focusable:"false",viewBox:"0 -694 520 704","aria-hidden":"true"},N=s("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[s("g",{"data-mml-node":"math"},[s("g",{"data-mml-node":"mi"},[s("path",{"data-c":"1D451",d:"M366 683Q367 683 438 688T511 694Q523 694 523 686Q523 679 450 384T375 83T374 68Q374 26 402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487H491Q506 153 506 145Q506 140 503 129Q490 79 473 48T445 8T417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157Q33 205 53 255T101 341Q148 398 195 420T280 442Q336 442 364 400Q369 394 369 396Q370 400 396 505T424 616Q424 629 417 632T378 637H357Q351 643 351 645T353 664Q358 683 366 683ZM352 326Q329 405 277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q233 26 290 98L298 109L352 326Z",style:{"stroke-width":"3"}})])])],-1),z=[N],G=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"d")])],-1),I=t(`

参数:

返回: AnyAngle: 夹角

引发:

源代码在GitHub上查看
python
def cal_angle(self, other: 'Line3 | Plane3') -> 'AnyAngle':
    if isinstance(other, Line3):
        return self.normal.cal_angle(other.direction).complementary
    elif isinstance(other, Plane3):
        return AnyAngle(math.acos(self.normal @ other.normal / (self.normal.length * other.normal.length)), is_radian=True)
    else:
        raise TypeError(f'Unsupported type: {type(other)}')

method cal_distance(self, other: Plane3 | Point3) -> float

说明: 计算平面与平面或点之间的距离。

参数:

返回: float: 距离

引发:

源代码在GitHub上查看
python
def cal_distance(self, other: 'Plane3 | Point3') -> float:
    if isinstance(other, Plane3):
        return 0
    elif isinstance(other, Point3):
        return abs(self.a * other.x + self.b * other.y + self.c * other.z + self.d) / (self.a ** 2 + self.b ** 2 + self.c ** 2) ** 0.5
    else:
        raise TypeError(f'Unsupported type: {type(other)}')

method cal_intersection_line3(self, other: Plane3) -> Line3

说明: 计算两平面的交线。

`,16),R={class:"tip custom-block"},J=s("p",{class:"custom-block-title"},"TIP",-1),O=s("p",null,"计算两平面交线的一般步骤:",-1),$=s("ol",null,[s("li",null,"求两平面的法向量的叉乘得到方向向量")],-1),U={tabindex:"0",class:"MathJax",jax:"SVG",display:"true",style:{direction:"ltr",display:"block","text-align":"center",margin:"1em 0",position:"relative"}},K={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.186ex"},xmlns:"http://www.w3.org/2000/svg",width:"11.937ex",height:"1.756ex",role:"img",focusable:"false",viewBox:"0 -694 5276 776","aria-hidden":"true"},W=t('',1),X=[W],Y=s("mjx-assistive-mml",{unselectable:"on",display:"block",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",overflow:"hidden",width:"100%"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("mi",null,"d"),s("mo",null,"="),s("mi",null,"n"),s("mn",null,"1"),s("mo",null,"×"),s("mi",null,"n"),s("mn",null,"2")])],-1),ss={start:"2"},as={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},is={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.186ex"},xmlns:"http://www.w3.org/2000/svg",width:"5.442ex",height:"1.692ex",role:"img",focusable:"false",viewBox:"0 -666 2405.6 748","aria-hidden":"true"},ts=t('',1),es=[ts],ls=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"x"),s("mo",null,"="),s("mn",null,"0")])],-1),ns={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},hs={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.464ex"},xmlns:"http://www.w3.org/2000/svg",width:"5.257ex",height:"1.971ex",role:"img",focusable:"false",viewBox:"0 -666 2323.6 871","aria-hidden":"true"},ps=t('',1),rs=[ps],os=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"y"),s("mo",null,"="),s("mn",null,"0")])],-1),ks={class:"MathJax",jax:"SVG",style:{direction:"ltr",position:"relative"}},ds={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-0.186ex"},xmlns:"http://www.w3.org/2000/svg",width:"5.2ex",height:"1.692ex",role:"img",focusable:"false",viewBox:"0 -666 2298.6 748","aria-hidden":"true"},Qs=t('',1),Ts=[Qs],gs=s("mjx-assistive-mml",{unselectable:"on",display:"inline",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",width:"auto",overflow:"hidden"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[s("mi",null,"z"),s("mo",null,"="),s("mn",null,"0")])],-1),ms={tabindex:"0",class:"MathJax",jax:"SVG",display:"true",style:{direction:"ltr",display:"block","text-align":"center",margin:"1em 0",position:"relative"}},cs={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-3.281ex"},xmlns:"http://www.w3.org/2000/svg",width:"13.363ex",height:"7.692ex",role:"img",focusable:"false",viewBox:"0 -1950 5906.6 3400","aria-hidden":"true"},Es=t('',1),ys=[Es],us=s("mjx-assistive-mml",{unselectable:"on",display:"block",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",overflow:"hidden",width:"100%"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("mrow",{"data-mjx-texclass":"INNER"},[s("mo",{"data-mjx-texclass":"OPEN"},"{"),s("mtable",{columnalign:"left left",columnspacing:"1em",rowspacing:".2em"},[s("mtr",null,[s("mtd",null,[s("mi",null,"x"),s("mo",null,"="),s("msub",null,[s("mi",null,"x"),s("mn",null,"0")]),s("mo",null,"+"),s("mi",null,"d"),s("mi",null,"t")])]),s("mtr",null,[s("mtd",null,[s("mi",null,"y"),s("mo",null,"="),s("msub",null,[s("mi",null,"y"),s("mn",null,"0")]),s("mo",null,"+"),s("mi",null,"d"),s("mi",null,"t")])]),s("mtr",null,[s("mtd",null,[s("mi",null,"z"),s("mo",null,"="),s("msub",null,[s("mi",null,"z"),s("mn",null,"0")]),s("mo",null,"+"),s("mi",null,"d"),s("mi",null,"t")])])]),s("mo",{"data-mjx-texclass":"CLOSE",fence:"true",stretchy:"true",symmetric:"true"})])])],-1),Fs=s("p",null,"或",-1),fs={tabindex:"0",class:"MathJax",jax:"SVG",display:"true",style:{direction:"ltr",display:"block","text-align":"center",margin:"1em 0",position:"relative"}},bs={style:{overflow:"visible","min-height":"1px","min-width":"1px","vertical-align":"-1.991ex"},xmlns:"http://www.w3.org/2000/svg",width:"27.19ex",height:"4.839ex",role:"img",focusable:"false",viewBox:"0 -1259 12018.1 2139","aria-hidden":"true"},_s=t('',1),Cs=[_s],xs=s("mjx-assistive-mml",{unselectable:"on",display:"block",style:{top:"0px",left:"0px",clip:"rect(1px, 1px, 1px, 1px)","-webkit-touch-callout":"none","-webkit-user-select":"none","-khtml-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none",position:"absolute",padding:"1px 0px 0px 0px",border:"0px",display:"block",overflow:"hidden",width:"100%"}},[s("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[s("mfrac",null,[s("mrow",null,[s("mi",null,"x"),s("mo",null,"−"),s("msub",null,[s("mi",null,"x"),s("mn",null,"0")])]),s("mi",null,"m")]),s("mo",null,"="),s("mfrac",null,[s("mrow",null,[s("mi",null,"y"),s("mo",null,"−"),s("msub",null,[s("mi",null,"y"),s("mn",null,"0")])]),s("mi",null,"n")]),s("mo",null,"="),s("mfrac",null,[s("mrow",null,[s("mi",null,"z"),s("mo",null,"−"),s("msub",null,[s("mi",null,"z"),s("mn",null,"0")])]),s("mi",null,"p")])])],-1),ws=t(`

参数:

返回: Line3: 交线

引发:

源代码在GitHub上查看
python
def cal_intersection_line3(self, other: 'Plane3') -> 'Line3':
    if self.normal.is_parallel(other.normal):
        raise ValueError('Planes are parallel and have no intersection.')
    direction = self.normal.cross(other.normal)
    x, y, z = (0, 0, 0)
    if self.a != 0 and other.a != 0:
        A = np.array([[self.b, self.c], [other.b, other.c]])
        B = np.array([-self.d, -other.d])
        y, z = np.linalg.solve(A, B)
    elif self.b != 0 and other.b != 0:
        A = np.array([[self.a, self.c], [other.a, other.c]])
        B = np.array([-self.d, -other.d])
        x, z = np.linalg.solve(A, B)
    elif self.c != 0 and other.c != 0:
        A = np.array([[self.a, self.b], [other.a, other.b]])
        B = np.array([-self.d, -other.d])
        x, y = np.linalg.solve(A, B)
    return Line3(Point3(x, y, z), direction)

method cal_intersection_point3(self, other: Line3) -> Point3

说明: 计算平面与直线的交点。

参数:

返回: Point3: 交点

引发:

源代码在GitHub上查看
python
def cal_intersection_point3(self, other: 'Line3') -> 'Point3':
    if self.normal @ other.direction == 0:
        raise ValueError('The plane and the line are parallel or coincident.')
    x, y, z = other.get_parametric_equations()
    t = -(self.a * other.point.x + self.b * other.point.y + self.c * other.point.z + self.d) / (self.a * other.direction.x + self.b * other.direction.y + self.c * other.direction.z)
    return Point3(x(t), y(t), z(t))

method cal_parallel_plane3(self, point: Point3) -> Plane3

说明: 计算平行于该平面且过指定点的平面。

参数:

返回: Plane3: 平面

源代码在GitHub上查看
python
def cal_parallel_plane3(self, point: 'Point3') -> 'Plane3':
    return Plane3.from_point_and_normal(point, self.normal)

method is_parallel(self, other: Plane3) -> bool

说明: 判断两个平面是否平行。

参数:

返回: bool: 是否平行

源代码在GitHub上查看
python
def is_parallel(self, other: 'Plane3') -> bool:
    return self.normal.is_parallel(other.normal)

@property

method normal(self) -> Vector3

说明: 平面的法向量。

返回: Vector3: 法向量

源代码在GitHub上查看
python
@property
def normal(self) -> 'Vector3':
    return Vector3(self.a, self.b, self.c)

@classmethod

method from_point_and_normal(cls, point: Point3, normal: Vector3) -> Plane3

说明: 工厂函数 由点和法向量构造平面(点法式构造)。

参数:

返回: Plane3: 平面

源代码在GitHub上查看
python
@classmethod
def from_point_and_normal(cls, point: 'Point3', normal: 'Vector3') -> 'Plane3':
    a, b, c = (normal.x, normal.y, normal.z)
    d = -a * point.x - b * point.y - c * point.z
    return cls(a, b, c, d)

@classmethod

method from_three_points(cls, p1: Point3, p2: Point3, p3: Point3) -> Plane3

说明: 工厂函数 由三点构造平面。

参数:

返回: 平面

源代码在GitHub上查看
python
@classmethod
def from_three_points(cls, p1: 'Point3', p2: 'Point3', p3: 'Point3') -> 'Plane3':
    v1 = p2 - p1
    v2 = p3 - p1
    normal = v1.cross(v2)
    return cls.from_point_and_normal(p1, normal)

@classmethod

method from_two_lines(cls, l1: Line3, l2: Line3) -> Plane3

说明: 工厂函数 由两直线构造平面。

参数:

返回: 平面

源代码在GitHub上查看
python
@classmethod
def from_two_lines(cls, l1: 'Line3', l2: 'Line3') -> 'Plane3':
    v1 = l1.direction
    v2 = l2.point - l1.point
    if v2 == zero_vector3:
        v2 = l2.get_point(1) - l1.point
    return cls.from_point_and_normal(l1.point, v1.cross(v2))

@classmethod

method from_point_and_line(cls, point: Point3, line: Line3) -> Plane3

说明: 工厂函数 由点和直线构造平面。

参数:

返回: 平面

源代码在GitHub上查看
python
@classmethod
def from_point_and_line(cls, point: 'Point3', line: 'Line3') -> 'Plane3':
    return cls.from_point_and_normal(point, line.direction)

@overload

method self & other: Line3 => Point3 | None

源代码在GitHub上查看
python
@overload
def __and__(self, other: 'Line3') -> 'Point3 | None':
    ...

@overload

method self & other: Plane3 => Line3 | None

源代码在GitHub上查看
python
@overload
def __and__(self, other: 'Plane3') -> 'Line3 | None':
    ...

method self & other

说明: 取两平面的交集(人话:交线)

参数:

返回: Line3 | Point3 | None: 交集

引发:

源代码在GitHub上查看
python
def __and__(self, other):
    if isinstance(other, Plane3):
        if self.normal.is_parallel(other.normal):
            return None
        return self.cal_intersection_line3(other)
    elif isinstance(other, Line3):
        if self.normal @ other.direction == 0:
            return None
        return self.cal_intersection_point3(other)
    else:
        raise TypeError(f"unsupported operand type(s) for &: 'Plane3' and '{type(other)}'")

method self == other => bool

说明: 判断两个平面是否等价。

参数:

返回: bool: 是否等价

源代码在GitHub上查看
python
def __eq__(self, other) -> bool:
    return self.approx(other)

method self & other: Line3 => Point3

源代码在GitHub上查看
python
def __rand__(self, other: 'Line3') -> 'Point3':
    return self.cal_intersection_point3(other)
`,81);function Hs(Ls,Ds,As,vs,Bs,Ms){return i(),a("div",null,[h,s("div",p,[r,o,s("mjx-container",k,[(i(),a("svg",d,T)),g]),s("p",null,[e("其中 "),s("mjx-container",m,[(i(),a("svg",c,y)),u]),e(" 和 "),s("mjx-container",F,[(i(),a("svg",f,_)),C]),e(" 分别为两个平面的法向量")])]),s("div",x,[w,H,s("mjx-container",L,[(i(),a("svg",D,v)),B]),s("p",null,[e("其中 "),s("mjx-container",M,[(i(),a("svg",V,P)),q]),e(" 为平面的法向量,"),s("mjx-container",S,[(i(),a("svg",j,z)),G]),e(" 为直线的方向向量")])]),I,s("div",R,[J,O,$,s("mjx-container",U,[(i(),a("svg",K,X)),Y]),s("ol",ss,[s("li",null,[e("寻找直线上的一点,依次假设"),s("mjx-container",as,[(i(),a("svg",is,es)),ls]),e(", "),s("mjx-container",ns,[(i(),a("svg",hs,rs)),os]),e(", "),s("mjx-container",ks,[(i(),a("svg",ds,Ts)),gs]),e(",并代入两平面方程求出合适的点 直线最终可用参数方程或点向式表示")])]),s("mjx-container",ms,[(i(),a("svg",cs,ys)),us]),Fs,s("mjx-container",fs,[(i(),a("svg",bs,Cs)),xs])]),ws])}const Ps=l(n,[["render",Hs]]);export{Zs as __pageData,Ps as default};