how to plot 3d pyramid ?

조회 수: 30 (최근 30일)
Brasco , D.
Brasco , D. 2015년 10월 7일
댓글: Brasco , D. 2015년 10월 7일
Hi guys i got confused about ploting 3-D pyramid.
Here ara the edge coordinates of the pyramid.
pt1=[0 0 0]; pt2=[10 0 0]; pt3=[10 -10 0]; pt4=[0 -10 0]; pt5=[0 0 5];
How can i plot it with all of its surfaces ?

채택된 답변

Thorsten
Thorsten 2015년 10월 7일
P = [pt1; pt2; pt3; pt4; pt5]
ind = [1 2 5]; patch(P(ind, 1), P(ind, 2), P(ind, 3), 'r')
hold on
ind = [2 3 5]; patch(P(ind, 1), P(ind, 2), P(ind, 3), 'r')
ind = [3 4 5]; patch(P(ind, 1), P(ind, 2), P(ind, 3), 'r')
ind = [4 1 5]; patch(P(ind, 1), P(ind, 2), P(ind, 3), 'r')
And for the base
ind = 1:4; patch(P(ind, 1), P(ind, 2), zeros(1,4), 'b')
  댓글 수: 1
Brasco , D.
Brasco , D. 2015년 10월 7일
First of all, thank you for your answer.
Your code works but i gave that points for a simple case. My actual problem contains about geographic coordinates and altitudes. I need a generic code, such as given any 5 points it will draw a pyramid.
Thank you for your contribution again.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by