File:Rotating line sections.gif

Summary

Description
English: Rotating line sections. All section have the same length of π and the same speed. The inner most circle has a diameter of 1. The second of diameter 2 has two sections. The third of diameter 3 has three sections. And so on.
Date
Source Own work
Author Jahobr
GIF development
InfoField
Source code
InfoField

MATLAB code

function rotating_line_sections()
% source code for drawing a GIF
%
% 2017-09-16 Jahobr


[pathstr,fname] = fileparts(which(mfilename)); % save files under the same name and at file location

figHandle = figure(15674455);
clf
axesHandle = axes;
hold(axesHandle,'on')
set(figHandle, 'Units','pixel');
set(figHandle, 'position',[1 1 700 700]); % big start image for antialiasing later [x y width hight]
set(axesHandle,'position',[-0.06 -0.06 1.12 1.12]); % stretch axis bigger as figure, easy way to get rid of ticks [x y width height]
set(figHandle,'GraphicsSmoothing','on') % requires at least version 2014b

axis equal; drawnow;

nRings = 30;

% % % variants
% offset = zeros(1,30);
% offset = rand(1,30)*pi;
% offset = ones(1,30)*0.5;
offset = linspace(0,2,nRings);
% offset = log(linspace(1,7,30));
% offset = linspace(0,1,30).^2;

xlim([-35 35]); % default
ylim([-35 35]); % default

nFrames = 100;
angleP = -linspace(0,pi*2,nFrames+1); % define gear position in frames
angleP = angleP(1:end-1); % remove last frame, it would be double

for iFrame = 1:nFrames
    
    cla(axesHandle) % fresh frame

    for iRings = 1:nRings
        ang = linspace(0,pi*2,iRings+1); % define gear position in frames
        for iSection = 1:iRings
            
            wedge = linspace(0,pi/iRings,22); % define gear position in frames
            [X,Y] = pol2cart(wedge +offset(iRings)+angleP(iFrame)/iRings + ang(iSection),iRings*ones(1,22));
            plot(X,Y,'k-','linewidth',7)
        end
    end

    %% save animation
    drawnow
    % pause(0.01)
    
    f = getframe(figHandle);
    if iFrame == 1 % create colormap
        map = gray(8); % create own color map %
        im = rgb2ind(f.cdata,map,'nodither'); %
        im(1,1,1,nFrames) = 0; % allocate
    else
        imtemp = rgb2ind(f.cdata,map,'nodither');
        im(:,:,1,iFrame) = imtemp;
    end

end
imwrite(im,map,fullfile(pathstr, [fname '.gif']),'DelayTime',1/30,'LoopCount',inf) % save gif
disp([fname '.gif  has ' num2str(numel(im)/10^6 ,4) ' Megapixels']) % Category:Animated GIF files exceeding the 50 MP limit

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Category:CC-Zero#Rotating%20line%20sections.gif
Category:Self-published work Category:Animations on white background Category:Animated black and white patterns Category:Animated rotating throbbers Category:Animations of infinity Category:Seamless animations Category:Animated GIF throbbers
Category:Animated GIF throbbers Category:Animated black and white patterns Category:Animated rotating throbbers Category:Animations of infinity Category:Animations on white background Category:CC-Zero Category:PNG created with MATLAB code Category:Seamless animations Category:Self-published work