Plot colored angle between two lines on the YZ plane

조회 수: 1 (최근 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 CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by