How to create a plot3 on a truncated pyramid ?

Dear all: I want to crat a line plot to produce a truncated pyramid with 45degree inclination. The truncated pyramid has an initial width and length of 50mm,50mm. Hight of 30mm. I want to crat plot3 lines within 0.25mm depth until the final hight is reached(30mm). So how to crat the plot for this truncated pyramid. The sample part is attached. Thank You!

 採用された回答

KSSV
KSSV 2018 年 9 月 26 日
編集済み: KSSV 2018 年 9 月 26 日

0 投票

L = 50 ; B = 50 ; H = -30 ;
theta = 45 ;
% Bottom rectangle
B = [0 0 0; L 0 0; L B 0; 0 B 0; 0 0 0] ;
mx = mean(B(1:4,1)) ; my = mean(B(1:4,2)) ;
h = 0:-0.25:H ;
figure
hold on
plot3(B(:,1),B(:,2),B(:,3),'r')
for i = 1:length(h)
C = [mx my h(i)] ;
x = h(i)/tand(theta) ;
s = L/2-x ;
% Top rectangele points
T = [mx-s my-s h(i); mx+s my-s h(i) ; mx+s my+s h(i) ; mx-s my+s h(i) ; mx-s my-s h(i)] ;
plot3(T(:,1),T(:,2),T(:,3),'b')
end

2 件のコメント

adam adam
adam adam 2018 年 9 月 26 日
編集済み: adam adam 2018 年 9 月 26 日
Thank You very much. let me again kindly add one more question. simply give me some hint if you have time. What to add to the above code if the plot is spiral as attached.
Saurabh Thakur
Saurabh Thakur 2022 年 3 月 7 日
Hi, I want to create similar truncated pyramid. With initial dimensions of 70 X 70 mm. A depth of 25 mm is to be reached and stepsize is 1mm. But the path traced should have equally spaced points at 1mm distance. Can it be done?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

質問済み:

2018 年 9 月 25 日

コメント済み:

2022 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by