通过点阵列的中点绘制 3d 平面
Plotting a 3d-plane through midpoint of point array
我在 MATLAB 中遇到一个小问题:我有一个包含 x、y 和 z 坐标的点数组(名为 X),以 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);
这样你会看到平面接触中点
我在 MATLAB 中遇到一个小问题:我有一个包含 x、y 和 z 坐标的点数组(名为 X),以 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);
这样你会看到平面接触中点