Skip to content
Snippets Groups Projects
Commit fe4b6c99 authored by la_29's avatar la_29
Browse files

rotate a 3D figure

parent dfc9a245
No related branches found
No related tags found
No related merge requests found
% this code can be functionalized
% can also add features:
% periodicity toggle? if true remove final frame
% changing number of inbetweens to speed up or slow down the animation
fileName = 'ssfClustering'; % name of movie generated
frameRate = 30; % desired frame rate
duration = 30; % desired length of movie in seconds
azimuthList = [-20,-110,-190,-290,-380]; % camera pan angle at key frames
elevationList = [10,10,10,10,10]; % camera tilt angle at key frames
v = VideoWriter(fileName,'MPEG-4');
v.FrameRate = frameRate;
open(v);
% interpolate viewing angles between key frames to match the specified duration
keyFrameList = [azimuthList;elevationList]';
numFrames = round(duration * frameRate);
intervalLength = (numFrames - 1) / (size(keyFrameList,1) - 1);
% initialize the angleList
angleList = zeros(numFrames,2);
for numKeyFrame = 1:size(keyFrameList,1) - 1
firstRow = round(intervalLength * (numKeyFrame - 1) + 1); % first row of the interval between key frames
lastRow = round(intervalLength * numKeyFrame + 1); % last row of the interval between key frames
a = keyFrameList(numKeyFrame,1); % initial key frame azimuth angle
b = keyFrameList(numKeyFrame + 1,1); % ending key frame azimuth angle
c = keyFrameList(numKeyFrame,2); % initial key frame elevation angle
d = keyFrameList(numKeyFrame + 1,2); % ending key frame elevation angle
n = round(intervalLength * numKeyFrame) - round(intervalLength * (numKeyFrame - 1)) + 1; % number of angles to add
angleList(firstRow:lastRow,:) = [linspace(a,b,n).' , linspace(c,d,n).'];
end
% capture frames and write to the movie file
for frame = 1:size(angleList,1)
view(angleList(frame,:));
drawnow;
writeVideo(v,getframe(gcf));
end
close(v);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment