Cube movement in X - Direction.?
2 次查看(过去 30 天)
显示 更早的评论
if P == 1
A = [0 0 0];
B = [1 0 0];
C = [0 1 0];
D = [0 0 1];
E = [0 1 1];
F = [1 0 1];
G = [1 1 0];
H = [1 1 1];
P = [A;B;F;H;G;C;A;D;E;H;F;D;E;C;G;B];
axis([-2 2 -2 2 -2 2])
plot3(P(:,1),P(:,2),P(:,3),'g'), hold on
roll = 2*pi; pitch = 2*pi; yaw = 2*pi;
dcm = angle2dcm(yaw, pitch, roll);
P = P*dcm;
axis([-2 2 -2 2 -2 2])
plot3(P(:,1),P(:,2),P(:,3)) % rotated cube
axis([-2 2 -2 2 -2 2])
plot3(0,0,0,'or')
xlabel('X')
ylabel('Y')
zlabel('Z')
grid on
elseif P==2
.
.
.
I am creating a cube with this code, and as P changes, i want to move cube in x direction with increment of 1. How to perform this operation.? I tried to move, but previous lines remains as it is, and it becomes rectangle..!
0 个评论
回答(2 个)
Walter Roberson
2016-4-4
编辑:Walter Roberson
2016-4-4
Create a hgtransform() and parent everything to be moved to it. Then when it is time to move it, set its transform matrix, which you can do directly or you can use (for example)
Txy = makehgtform('translate',[-1.5 -1.5 0]);
set(t2,'Matrix',Txy)
alejandro perez
2020-2-2
In the description of this video is the code of a cube which rotates, moves and grows up.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!