Plot colored angle between two lines on the YZ plane

2 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 14 Mar 2023
Commenté : Les Beckham le 17 Mar 2023
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')

Réponse acceptée

Les Beckham
Les Beckham le 14 Mar 2023
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 commentaires
Alberto Acri
Alberto Acri le 15 Mar 2023
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 le 17 Mar 2023
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).

Connectez-vous pour commenter.

Plus de réponses (1)

Adam Drake
Adam Drake le 14 Mar 2023
Modifié(e) : Adam Drake le 14 Mar 2023
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')

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by