Plot colored angle between two lines on the YZ plane
조회 수: 1 (최근 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')
댓글 수: 0
채택된 답변
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
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
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')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!