Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 通过点阵列的中点打印三维平面_Matlab_Plot_3d_Plane - Fatal编程技术网

Matlab 通过点阵列的中点打印三维平面

Matlab 通过点阵列的中点打印三维平面,matlab,plot,3d,plane,Matlab,Plot,3d,Plane,我在MATLAB中遇到了一个小问题:我有一个点数组(名为X),其中有X,y和z坐标,以矩阵20乘以3的形式给出。我还有一个平面的标准化法向量NV,并从数组X中选择中点作为平面上的点 我尝试了以下方法从数据中绘制平面、点阵列和中点。我希望中点是平面的一部分,但平面发生了位移。我只是看不出有什么错误,非常感谢你的帮助 X =[0.8176, 0.2277, 0.4242; 0.7948, 0.4357, 0.5079; 0.6443, 0.3111, 0.0855; 0.3786, 0.9234,

我在MATLAB中遇到了一个小问题:我有一个点数组(名为X),其中有X,y和z坐标,以矩阵20乘以3的形式给出。我还有一个平面的标准化法向量NV,并从数组X中选择中点作为平面上的点

我尝试了以下方法从数据中绘制平面、点阵列和中点。我希望中点是平面的一部分,但平面发生了位移。我只是看不出有什么错误,非常感谢你的帮助

X =[0.8176, 0.2277, 0.4242; 
0.7948, 0.4357, 0.5079;
0.6443, 0.3111, 0.0855;
0.3786, 0.9234, 0.2625;
0.8116, 0.4302, 0.8010;
0.5328, 0.1848, 0.0292;
0.3507, 0.9049, 0.9289;
0.9390, 0.9797, 0.7303;
0.8759, 0.4389, 0.4886;
0.5502, 0.1111, 0.5785;
0.6225, 0.2581, 0.2373;
0.5870, 0.4087, 0.4588;
0.2077, 0.5949, 0.9631;
0.3012, 0.2622, 0.5468;
0.4709, 0.6028, 0.5211;
0.2305, 0.7112, 0.2316;
0.8443, 0.2217, 0.4889;
0.1948, 0.1174, 0.6241;
0.2259, 0.2967, 0.6791;
0.1707, 0.3188, 0.3955];

MidP = mean(X);
NV = [0.1815, -0.6091, 0.7721];

x_min = min(X(:,1));
x_max = max(X(:,1));
z_min = min(X(:,3));
z_max = max(X(:,3));
Y1 = ((((z_min+MidP(3))*NV(3))+(x_min+MidP(1))*NV(1))/NV(2))-MidP(2);
Y2 = ((((z_min+MidP(3))*NV(3))+(x_max+MidP(1))*NV(1))/NV(2))-MidP(2);
Y3 = ((((z_max+MidP(3))*NV(3))+(x_min+MidP(1))*NV(1))/NV(2))-MidP(2);
Y4 = ((((z_max+MidP(3))*NV(3))+(x_max+MidP(1))*NV(1))/NV(2))-MidP(2);

figure('Name','Plane, Points and Midpoint') 
hold on 
surf([x_min x_max; x_min x_max],[Y1 Y2; Y3 Y4],[z_max z_max; z_min z_min]); %Plane
plot3(X(:,1), X(:,2), X(:,3),'.'); %Points
plot3(MidP(1),MidP(2),MidP(3),'*'); %Midpoint
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
hold off

我认为你应该减去平面方程中的中点,而不是加上它:

(x-MidP(1))*NV(1) + (y-MidP(2))*NV(2) + (z-MidP(3))*NV(3) = 0
然后相应地解Y1到Y4(注意符号)

这样,您将看到平面接触中点


非常感谢你:)
Y1 = -(((z_min-MidP(3))*NV(3))+(x_min-MidP(1))*NV(1))/NV(2)+MidP(2);
Y2 = -(((z_min-MidP(3))*NV(3))+(x_max-MidP(1))*NV(1))/NV(2)+MidP(2);
Y3 = -(((z_max-MidP(3))*NV(3))+(x_min-MidP(1))*NV(1))/NV(2)+MidP(2);
Y4 = -(((z_max-MidP(3))*NV(3))+(x_max-MidP(1))*NV(1))/NV(2)+MidP(2);