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!

 Réponse acceptée

KSSV
KSSV le 26 Sep 2018
Modifié(e) : KSSV le 26 Sep 2018
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 commentaires

adam adam
adam adam le 26 Sep 2018
Modifié(e) : adam adam le 26 Sep 2018
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.
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?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by