How to 3D plot eight 4x4 matrices to form a cuboid?

2 ビュー (過去 30 日間)
Reana Taylor
Reana Taylor 2021 年 8 月 5 日
回答済み: darova 2021 年 8 月 8 日
I have to create a cuboid at the x,y,z origin. This cuboid will undergo transformation (another 4x4 matrix of rotation and translation). I have done this so far, but cannot figure out how to plot the 8 matrices and form a cuboid from it.
x=input('enter width (x direction)= ');
y=input('enter height (y direction)= ');
z=input('enter depth (z direction)= ');
vertex1= [0 0 0 0; 0 0 0 0; 0 0 0 0; 0 0 0 1];
vertex2= [0 0 0 x; 0 0 0 0; 0 0 0 0; 0 0 0 1];
vertex3= [0 0 0 x; 0 0 0 y; 0 0 0 0; 0 0 0 1];
vertex4= [0 0 0 0; 0 0 0 y; 0 0 0 0; 0 0 0 1];
vertex11= [0 0 0 0; 0 0 0 0; 0 0 0 z; 0 0 0 1];
vertex22= [0 0 0 x; 0 0 0 0; 0 0 0 z; 0 0 0 1];
vertex33= [0 0 0 x; 0 0 0 y; 0 0 0 z; 0 0 0 1];
vertex44= [0 0 0 0; 0 0 0 y; 0 0 0 z; 0 0 0 1];

回答 (2 件)

Image Analyst
Image Analyst 2021 年 8 月 5 日
  2 件のコメント
Reana Taylor
Reana Taylor 2021 年 8 月 6 日
I saw this, but it wasnt very helpful as I didn't understand the code. Also, that code is for automatic rotation of the cube whereas mine would be a manual one which will undergo both translation and rotation. Do you know how to plot the 8 vertex matrices so as to form a cube/cuboid?
Image Analyst
Image Analyst 2021 年 8 月 6 日
@Reana Taylor, I've never done it before so I'd have to figure it out just as you'll have to. But good luck with it.

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


darova
darova 2021 年 8 月 8 日
What about cylinder?
r = sqrt(2);
t = linspace(0,2*pi,5)+pi/4;
z = [0 0 1 1];
[T,Z] = ndgrid(t,z);
[X,Y] = pol2cart(T,r);
X(:,[1 end]) = 0;
Y(:,[1 end]) = 0;
surf(X,Y,Z,'facecolor','g','edgecolor','none')
axis equal
light

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by