我是MATLAB的新手。我想找到一组平面的方程,这些平面是我用convhulln
计算的凸包的一部分。它是一个凸多面体。我试着找了很多,但什么也找不到。感谢您的帮助。
这是一组点,我找到了它的凸包。该代码不在MATLAB中,但可以很容易地理解。所有点都是三维点。
pts = {{-0.00033004023134713956, 0, 0},{-0.00033004023134713956, -0.001, 0},
{0.00033004023134713956, -0.001, 0},{0.00033004023134713956, -0.00033004023134713956, 0},
{0,0,0},{-0.00033004023134713956, 0.001, -0.00033004023134713956},{0.00033004023134713956,
0.001, 0.00033004023134713956},{0.00033004023134713956, 0, 0.00033004023134713956},
{-0.00033004023134713956, 0.00033004023134713956, -0.00033004023134713956},{0,0,0},
{-0.00033004023134713956, 0, 0},{-0.00033004023134713956, 0.00033004023134713956,
-0.00033004023134713956},{0,0,0},{0.00033004023134713956, 0, 0.00033004023134713956},
{0.00033004023134713956, -0.00033004023134713956, 0},{0,0,0}};
首先需要将数据转换为N-by-3数字数组:
pts = ...
[[-0.00033004023134713956, 0, 0]; [-0.00033004023134713956, -0.001, 0]; ...
[0.00033004023134713956, -0.001, 0];...
[0.00033004023134713956, -0.00033004023134713956, 0]; [0,0,0];...
[-0.00033004023134713956, 0.001, -0.00033004023134713956];...
[0.00033004023134713956, 0.001, 0.00033004023134713956];...
[0.00033004023134713956, 0, 0.00033004023134713956];...
[-0.00033004023134713956, 0.00033004023134713956, -0.00033004023134713956];...
[0,0,0]; [-0.00033004023134713956, 0, 0];...
[-0.00033004023134713956, 0.00033004023134713956, -0.00033004023134713956];...
[0,0,0];[0.00033004023134713956, 0, 0.00033004023134713956];...
[0.00033004023134713956, -0.00033004023134713956, 0];[0,0,0]];
(数值数组用括号定义,用分号分隔行(
然后你可以调用convevhulln函数
K = convhulln(pts);
结果是一个包含多面体面的索引的NF-by-3数组。要获得包含第一个面的平面的原点和方向向量,可以按如下方式处理:
indF = 1;
pnt1 = pts(K(indF, 1), :);
pnt2 = pts(K(indF, 2), :);
pnt3 = pts(K(indF, 3), :);
origin = pnt1;
vect1 = pnt2 - pnt1;
vect2 = pnt3 - pnt1;