Avoiding buggy/jerky animation
조회 수: 2 (최근 30일)
이전 댓글 표시
I have this code here below. It basically rotates a box in 3D. I know I can rotate the camera using camorbit but I actually want to rotate the object, not the camera around it. So the strategy is to create an element in so(3) and take the exponential map to SO(3) as the element is varied continuously over time.
% Create object
yo = unique([-1 -1 -1; perms([1 1 -1]); perms([1 -1 -1]); 1 1 1], 'rows');
yo2 = delaunay(yo(:,1), yo(:,2), yo(:,3));
box=tetramesh(yo2, yo);
% Create prescribed rotation
seedMat=skewdec(3,1)*skewdec(3,2)*skewdec(3,3); % so(3)
t=linspace(0,20,500);
r=zeros(1,4,length(t));
reqTraj=zeros(3,3,length(t));
for i=1:length(t)
reqTraj(:,:,i)=expm(seedMat*t(i)); % SO(3)
r(:,:,i) = vrrotmat2vec(expm(seedMat*t(i))); %Axis angle form
end
% Freeze axis
axis vis3d
axis([ -2 2 -2 2 -2 2])
% Rotate
for i=1:length(t)
rotate(box,r(1,1:3,i),r(1,4,i))
pause(0.001)
end
My question is why is this animation jerky? Is there something that I can do to fix it?
EDIT: Changing the last part as follows, made the buggy/jerky behavior go away, but resulted in an entirely new rotation behavior. So i am not sure if it is the correct approach or not. Can someone comment?
% Rotate
for i=2:length(t)
rotate(box,r(1,1:3,i),r(1,4,i-1)-r(1,4,i))
pause(0.001)
end
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!