Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

% Initial Position of Cube

Ax = 0; % X Coordinate of Point A

Ay = 0; % Y Coordinate of Point A

Az = 0; % Z Coordinate of Point A

Bx = 0; % X Coordinate of Point B

By = 1; % Y Coordinate of Point B

Bz = 0; % Z Coordinate of Point B

Cx = 1; % X Coordinate of Point C

Cy = 1; % Y Coordinate of Point C

Cz = 0; % Z Coordinate of Point C

Dx = 1; % X Coordinate of Point D

Dy = 0; % Y Coordinate of Point D

Dz = 0; % Z Coordinate of Point D

Ex = 0; % X Coordinate of Point E

Ey = 0; % Y Coordinate of Point E

Ez = 1; % Z Coordinate of Point E

Fx = 0; % X Coordinate of Point F

Fy = 1; % Y Coordinate of Point F

Fz = 1; % Z Coordinate of Point F

Gx = 1; % X Coordinate of Point G

Gy = 1; % Y Coordinate of Point G

Gz = 1; % Z Coordinate of Point G
Hx = 1; % X Coordinate of Point H

Hy = 0; % Y Coordinate of Point H

Hz = 1; % Z Coordinate of Point H

Plot Initial Position of Cube


plot3([Ax,Bx], [Ay,By],[Az,Bz],sbe) % Line between point A and B %axis
( [0 3 0 2 0 2 3)
hold on % To hold figure handle on same figure
plot3([13x,Cx], [By,Cy],[13z,Cz],'W) % Line between point B and C hold
on
plou3([Cx,Dx], [Cy,Dy],[Cz e Dz],lb.) Is Line between point C and D hold
on
plot3([Dx s Ex], [Dy,Ay] e [Dz,Az]„'br) % Line between point D and A hold
on
plot3([Ex,Fx], [Ey,Fy],[Ez,Fz],lb.) 1 Line between point E and F hold
on
plot3((Fx,Gx), (Fy,Gy),(Fz,GzJ,'b') 1 Line between point F and G hold
on
plot3((Gx,Hx], [Gy,Hy],[Gz,Hz],'W) 1 Line between point G and H hold
on
plot3([Hx,Ex], [Hy,Ey],[Hz,Ez],'12 1 ) 1 Line between point H and E hold
on
plot3([Ex,Ax], [Ey,Ay],[Ez,Az], 1 b 1 ) E Line between point E and A hold
on
plot.3([Fx,Bx], [Fy,By],[Fz,Bz],'W) E Line between point F and B hold
on
plot3([Gx,Cx], [Gy,Cy],[Gz,Cz],'W) 1 Line between point G and C hold
on
plou3([Hx,Dx], [Hy,Dy],[Hz,Dz],lbs) 1 Line between point H and D hold
on
text(Ax,Ay,Az, 'A','fontsize',16)
text(Bx,By,Bz, 'B','fontsize',16)
text(Cx,Cy,Cz, 'C','fontsize',16)
text (Dx, Dy, Dz, 'D','fontsize',16)
text(Ex,Ey,Ez, 'E', 1 fontsize',16)
text (Fx, Fy, Fz, 'F','fontsize',16)
text(Gx,Gy,Gz, 'G','fontsize',16)
text(Hx,Hy,Hz, 'H','fontsizel,16)

% Transformation of all points of cube


Aold = [Ax;Ay;Az;1]; Bold =
[Bx;By;Bz;1]; Cold =
[Cx;Cy;Cz;1]; Dold =
[Dx;Dy;Dz;1]; Eold =
[Ex;Ey;Ez;1]; Fold =
[Fx;Fy;Fz;1]; Gold =
[Gx;Gy;Gz;1]; Hold =
[Hx;Hy;Hz;1];

OldPos = [Aold,Bold,Cold,Dold,Eold,Fold,Gold,Hold]; NewPos=


trans3d(3,01dPos);
% OldPos = NewPos;
% NewPos= trans3d(2,01dPos); % OldPos
= NewPos;
% NewPos= trans3d(3,01dPos);

Axnew = NewPos(1,1);
Aynew - NewPos(2,1);
Aznew = NewPos(3,1);

Bxnew . NewPos(1,2);
Bynew a
NewPos(2,2);
Bznew . NewPos(3,2);

Cxnew = NewPos(1,3):
Cynew = NewPos(2,3);
Cznew = NewPos(3,3):

Dxnew = NewPos(1,4):
Dynew = NewPos(2,4):
Dznew = NewPos(3,4):

Exnew - NewPos(1,5):
Eynew = NewPos(2,5):
Eznew . NewPos(3,5):

Fxnew = NewPos(1,6):
Fynew = NewPos(2,6):
Fznew = NewPos(3,6):

Gxnew = NewPos(1,7):
Gynew . NewPos(2,7):
Gznew = NewPos(3,7):
Hxnew = NewPos(1,8):
Hynew = NewPos(2,8):
Hznew = NewPos(3,8):

% Plot Final Position of Cube

plot3 ([Axnew,Bxnew], [Aynew,Bynew], [Aznew,Bznew],’r’) % Line between point A and B

%axis ([0 3 0 2 0 2 1])

hold on % To hold figure handle on same figure

plot3 ([Bxnew,Cxnew], [Bynew,Cynew], [Bznew,Cznew],’r’) % Line between point B and C

hold on

plot3 ([Cxnew,Dxnew], [Cynew,Dynew], [Cznew,Dznew],’r’) % Line between point C and D

hold on

plot3 ([Dxnew,Exnew], [Dynew,Aynew], [Dznew,Aznew],’r’) % Line between point D and A

hold on

plot3 ([Exnew,Fxnew], [Eynew,Fynew], [Eznew,Fznew],’r’) % Line between point E and F

hold on

plot3 ([Fxnew,Gxnew], [Fynew,Gynew], [Fznew,Gznew],’r’) % Line between point F and G

hold on

plot3 ([Gxnew,Hxnew], [Gynew,Hynew], [Gznew,Hznew],’r’) % Line between point G and H

hold on

plot3 ([Hxnew,Exnew], [Hynew,Eynew], [Hznew,Eznew],’r’) % Line between point H and E

hold on

plot3 ([Exnew,Axnew], [Eynew,Aynew], [Eznew,Aznew],’r’) % Line between point E and A

hold on

plot3 ([Fxnew,Bxnew], [Fynew,Bynew], [Fznew,Bznew],’r’) % Line between point F and B

hold on

plot3 ([Gxnew,Cxnew], [Gynew,Cynew], [Gznew,Cznew],’r’) % Line between point G and C

hold on

plot3 ([Hxnew,Dxnew], [Hynew,Dynew], [Hznew,Dznew],’r’) % Line between point H and D

hold on
text(Axnew,Aynew,Aznew,'AI,'fontsizes,16)
text(Bxnew,Synew,Sznew,93',•fontsizes,16)
text(Cxnew.Cynew.Cznew,sC.,1fonisizel,16)
text(Dxnew,Dynew,Dznewe'D','fontsizel,16)
text(Exnew,Eynew,Eznew,,E1,1fontsizes,16)
text(Fxnew,Fynew,Finew,'F',1fontsizes,16)
text(Gxnew,Gynew,Gznew,'W,ifontnizel,16)
cexc(Hxnew,Hynew,Hznew,'H•,Ifontsizei,16)

You might also like