Plot colored angle between two lines on the YZ plane

4 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2023 年 3 月 14 日
コメント済み: Les Beckham 2023 年 3 月 17 日
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 Center および File ExchangeDiscrete Data Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by