Plot colored angle between two lines on the YZ plane

4 次查看(过去 30 天)
Hi. I would like to plot on my figure, the black corner (see image below) on the YZ plane. How can I do it?
meta = [14.97, 29.84, 5.61];
meta_plan1 = [15, -10, 38.13];
meta_plan2 = [15, -10, 32.64];
linea_plan1 = [15, -10, 38.13; 14.97, 29.84, 5.61];
linea_plan2 = [15, -10, 32.64; 14.97, 29.84, 5.61];
figure
plot3(meta(:,1),meta(:,2),meta(:,3),'k.','Markersize',15);
hold on
plot3(meta_plan1(:,1),meta_plan1(:,2),meta_plan1(:,3),'k.','Markersize',15);
plot3(meta_plan2(:,1),meta_plan2(:,2),meta_plan2(:,3),'k.','Markersize',15);
plot3(linea_plan1(:,1),linea_plan1(:,2),linea_plan1(:,3),'r','LineWidth',1);
plot3(linea_plan2(:,1),linea_plan2(:,2),linea_plan2(:,3),'b','LineWidth',1);
hold off
grid off
xlabel('x')
ylabel('y')
zlabel('z')

采纳的回答

Les Beckham
Les Beckham 2023-3-14
This doesn't look exactly like what you want, but should get you started.
meta = [14.97, 29.84, 5.61];
meta_plan1 = [15, -10, 38.13];
meta_plan2 = [15, -10, 32.64];
linea_plan1 = [15, -10, 38.13; 14.97, 29.84, 5.61];
linea_plan2 = [15, -10, 32.64; 14.97, 29.84, 5.61];
figure
plot3(meta(:,1),meta(:,2),meta(:,3),'k.','Markersize',15);
hold on
plot3(meta_plan1(:,1),meta_plan1(:,2),meta_plan1(:,3),'k.','Markersize',15);
plot3(meta_plan2(:,1),meta_plan2(:,2),meta_plan2(:,3),'k.','Markersize',15);
plot3(linea_plan1(:,1),linea_plan1(:,2),linea_plan1(:,3),'r','LineWidth',1);
plot3(linea_plan2(:,1),linea_plan2(:,2),linea_plan2(:,3),'b','LineWidth',1);
hold off
grid off
xlabel('x')
ylabel('y')
zlabel('z')
grid on
view(90, 0)
patch([linea_plan1(2,1) mean(linea_plan1(1:2,1)) mean(linea_plan2(1:2,1)) linea_plan1(2,1)], ...
[linea_plan1(2,2) mean(linea_plan1(1:2,2)) mean(linea_plan2(1:2,2)) linea_plan1(2,2)], ...
[linea_plan1(2,3) mean(linea_plan1(1:2,3)) mean(linea_plan2(1:2,3)) linea_plan1(2,3)], ...
'k');
  2 个评论
Alberto Acri
Alberto Acri 2023-3-15
How can I change these values so that I can create a smaller/larger black triangle?
mean(line_plan1(1:2,K)) mean(line_plan2(1:2,K)) % K=1,2,3
Les Beckham
Les Beckham 2023-3-17
Can you be more specific about what you mean by "smaller/larger"?
My initial approach makes the triangle end half way between the endpoints of the lines. Adam Drake showed a way that you could use a different fraction of the length of the lines (his example shows 1/3).

请先登录,再进行评论。

更多回答(1 个)

Adam Drake
Adam Drake 2023-3-14
编辑:Adam Drake 2023-3-14
meta = [14.97, 29.84, 5.61];
meta_plan1 = [15, -10, 38.13];
meta_plan2 = [15, -10, 32.64];
linea_plan1 = [15, -10, 38.13; 14.97, 29.84, 5.61];
linea_plan2 = [15, -10, 32.64; 14.97, 29.84, 5.61];
figure
plot3(meta(1),meta(2),meta(3),'k.','Markersize',15);
hold on
plot3(meta_plan1(:,1),meta_plan1(:,2),meta_plan1(:,3),'k.','Markersize',15);
plot3(meta_plan2(:,1),meta_plan2(:,2),meta_plan2(:,3),'k.','Markersize',15);
plot3(linea_plan1(:,1),linea_plan1(:,2),linea_plan1(:,3),'r','LineWidth',1);
plot3(linea_plan2(:,1),linea_plan2(:,2),linea_plan2(:,3),'b','LineWidth',1);
x = [meta(1) meta_plan1(1) meta_plan2(1)];
y = [meta(2) meta_plan1(2) meta_plan2(2)];
z = [meta(3) meta_plan1(3) meta_plan2(3)];
% Find points a percentage along the lines
x1 = (x(2) - x(1))/3 + x(1);
y1 = (y(2) - y(1))/3 + y(1);
z1 = (z(2) - z(1))/3 + z(1);
x2 = (x(3) - x(1))/3 + x(1);
y2 = (y(3) - y(1))/3 + y(1);
z2 = (z(3) - z(1))/3 + z(1);
xfill = [x(1) x1 x2];
yfill = [y(1) y1 y2];
zfill = [z(1) z1 z2];
fill3(xfill,yfill,zfill,1)
hold off
grid off
xlabel('x')
ylabel('y')
zlabel('z')

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by