平面和射线交点

设平面 A x + B y + C z + D = 0 ( A 2 + B 2 + C 2 ≠ 0 ) Ax+By+Cz +D=0\left(A^2+B^2+C^2\neq 0\right) Ax+By+Cz+D=0(A2+B2+C2=0),
P ( P x , P y , P z ) P(P_x, P_y, P_z) P(Px,Py,Pz)

(1)求点 P P P到平面距离
(2)过点 P P P作直线,方向为 ( D x , D y , D z ) \left(D_x, D_y, D_z\right) (Dx,Dy,Dz),求平面与直线交点
(2)过点 P P P作射线,方向为 ( D x , D y , D z ) \left(D_x, D_y, D_z\right) (Dx,Dy,Dz),求平面与直线交点

解:
(1)这个高中有学过
∣ A P x + B P y + C P z + D ∣ A 2 + B 2 + C 2 \frac{\left|AP_x+BP_y+CP_z +D\right|}{\sqrt{A^2+B^2+C^2}} A2+B2+C2 APx+BPy+CPz+D

(2)为了方便,平面法向量 n = ( A , B , C ) \mathbf{n} = \left(A,B,C\right) n=(A,B,C)
直线方向向量 d = ( D x , D y , D z ) \mathbf{d} = \left(D_x,D_y,D_z\right) d=(Dx,Dy,Dz)
直线上的点可以表示为 P + t d P+t\mathbf{d} P+td,其中 t ∈ R t\in \mathbb{R} tR

1.若 n ⋅ d ≠ 0 \mathbf{n}\cdot \mathbf{d}\neq 0 nd=0,则直线和平面有且仅有1个交点
由于 P + t d P+t\mathbf{d} P+td在平面上,因此
n ⋅ ( P + t d ) + D = 0 ⇒ t = − D + n ⋅ P n ⋅ d \mathbf{n}\cdot\left(P+t\mathbf{d}\right) +D = 0\Rightarrow t= -\frac{D + \mathbf{n}\cdot P}{\mathbf{n}\cdot \mathbf{d}} n(P+td)+D=0t=ndD+nP
进而交点坐标
P + t d = P − D + n ⋅ P n ⋅ d d = ( P x − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D x P y − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D y P z − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D z ) \begin{aligned} P+t\mathbf{d} & = P -\frac{D + \mathbf{n}\cdot P}{\mathbf{n}\cdot \mathbf{d}}\mathbf{d}\\ &=\begin{pmatrix}P_x - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_x\\ P_y - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_y\\ P_z - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_z\\ \end{pmatrix} \end{aligned} P+td=PndD+nPd= PxADx+BDy+CDz(APx+BPy+CPz+D)DxPyADx+BDy+CDz(APx+BPy+CPz+D)DyPzADx+BDy+CDz(APx+BPy+CPz+D)Dz

2.若 n ⋅ d = 0 \mathbf{n}\cdot \mathbf{d}= 0 nd=0,且 n ⋅ P + d = 0 \mathbf{n}\cdot P +d = 0 nP+d=0,则直线与平面重合
3.若 n ⋅ d = 0 \mathbf{n}\cdot \mathbf{d}= 0 nd=0,且 n ⋅ P + d ≠ 0 \mathbf{n}\cdot P +d \neq 0 nP+d=0,则直线与平面无交点

(3)与(2)类似
射线上的点可以表示为 P + t d P+t\mathbf{d} P+td,其中 t ∈ R + t\in \mathbb{R}_{+} tR+
依然可以得到 t = − D + n ⋅ P n ⋅ d t= -\frac{D + \mathbf{n}\cdot P}{\mathbf{n}\cdot \mathbf{d}} t=ndD+nP

1.若 n ⋅ d ≠ 0 \mathbf{n}\cdot \mathbf{d}\neq 0 nd=0 t < 0 t<0 t<0则无交点
2.若 n ⋅ d ≠ 0 \mathbf{n}\cdot \mathbf{d}\neq 0 nd=0 t ≥ 0 t\ge0 t0,则只有一个交点
P + t d = P − D + n ⋅ P n ⋅ d d = ( P x − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D x P y − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D y P z − ( A P x + B P y + C P z + D ) A D x + B D y + C D z D z ) \begin{aligned} P+t\mathbf{d} & = P -\frac{D + \mathbf{n}\cdot P}{\mathbf{n}\cdot \mathbf{d}}\mathbf{d}\\ &=\begin{pmatrix}P_x - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_x\\ P_y - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_y\\ P_z - \frac{\left(AP_x+BP_y +CP_z+D\right)}{AD_x +BD_y+CD_z}D_z\\ \end{pmatrix} \end{aligned} P+td=PndD+nPd= PxADx+BDy+CDz(APx+BPy+CPz+D)DxPyADx+BDy+CDz(APx+BPy+CPz+D)DyPzADx+BDy+CDz(APx+BPy+CPz+D)Dz

3.若 n ⋅ d = 0 \mathbf{n}\cdot \mathbf{d}= 0 nd=0,且 n ⋅ P + d = 0 \mathbf{n}\cdot P +d = 0 nP+d=0,则直线与平面重合
4.若 n ⋅ d = 0 \mathbf{n}\cdot \mathbf{d}= 0 nd=0,且 n ⋅ P + d ≠ 0 \mathbf{n}\cdot P +d \neq 0 nP+d=0,则直线与平面无交点

参考:
https://zhuanlan.zhihu.com/p/404311333

你可能感兴趣的:(数学,平面,算法,机器学习)