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!