三维投影方差分割

在讨论了二维方差分割之后,继续讨论三维方差分割的问题:如何在三维空间中选择一条直线\(l\),使得三维点集\(A=\{(x_i,y_i,z_i)|i=1,2,…N\}\)的投影点\(P=\{ p_i∈l|i=1,2,…N\}\)的距离方差最大。

通过前面得讨论可知:可以三位点集\(A\)的质心为原点,建立三维直角坐标系。设直线\(l\)通过坐标原点,其单位方向矢量\(\overrightarrow l = (a,b,c)\)。令:

\[H = \sum\limits_{i = 1}^N {{{(\overrightarrow {O{p_i}} \cdot \overrightarrow l )}^2}} = \sum\limits_{i = 1}^N {{{(a{x_i} + b{y_i} + c{z_i})}^2}} \]

显然\(H\)是关于\(a,b,c\)的多元函数,附加条件为:

\[ \phi (a,b,c) = {a^2} + {b^2} + {c^2} – 1 = 0 \]

先做拉格朗日函数:

\[ L(a,b,c) = H(a,b,c) + \lambda \cdot \phi (a,b,c) \]

其中\(\lambda\)为参数,分别对参数\(a,b,c\)求一阶偏导数,并使之等于0。然后联立方程组:

\[ \frac{{\partial L}}{{\partial a}} = \frac{{\partial H}}{{\partial a}} + \lambda \cdot \frac{{\partial \phi }}{{\partial a}} = \sum\limits_{i = 1}^N {2(a{x_i} + b{y_i} + c{z_i}){x_i} + 2\lambda a = 0} \]

\[ \frac{{\partial L}}{{\partial b}} = \frac{{\partial H}}{{\partial b}} + \lambda \cdot \frac{{\partial \phi }}{{\partial b}} = \sum\limits_{i = 1}^N {2(a{x_i} + b{y_i} + c{z_i}){y_i} + 2\lambda b = 0} \]

\[\frac{{\partial L}}{{\partial c}} = \frac{{\partial H}}{{\partial c}} + \lambda \cdot \frac{{\partial \phi }}{{\partial c}} = \sum\limits_{i = 1}^N {2(a{x_i} + b{y_i} + c{z_i}){z_i} + 2\lambda c = 0} \]

令:

\[\begin{array}{*{20}{c}}
{{m_{xx}} = \sum\limits_{i = 1}^N {{x_i}{x_i}} }&{{m_{xy}} = \sum\limits_{i = 1}^N {{x_i}{y_i}} }&{{m_{xz}} = \sum\limits_{i = 1}^N {{x_i}{z_i}} }
\end{array}\]

\[\begin{array}{*{20}{c}}
{{m_{yy}} = \sum\limits_{i = 1}^N {{y_i}{y_i}} }&{{m_{yz}} = \sum\limits_{i = 1}^N {{y_i}{z_i}} }&{{m_{zz}} = \sum\limits_{i = 1}^N {{z_i}{z_i}} }
\end{array}\]

最后可以简化得到一个一元三次方程(该方程耗费了作者不少手工算力):

\[ {\lambda ^3} + ({m_{xx}} + {m_{yy}} + {m_{zz}}){\lambda ^2} \\ + ({m_{xx}}{m_{yy}} + {m_{xx}}{m_{zz}} + {m_{yy}}{m_{zz}} – m_{xy}^2 – m_{xz}^2 – m_{yz}^2)\lambda \\ + ({m_{xx}}{m_{yy}}{m_{zz}} – {m_{xx}}m_{yz}^2 – {m_{yy}}m_{xz}^2 – {m_{zz}}m_{xy}^2 + 2{m_{xy}}{m_{xz}}{m_{yz}}) = 0 \]

到此时可以利用Matlab等软件直接求得\(\lambda\)数值解。带入上述方程,即可解开\(a,b,c\)的数值。那么直线\(l\)所代表的方向是距离方差最大值方向,也是分割平面的法矢方向,且该分割平面过质心。