File:Tusi couple vs Paper strip plus Ellipses vertical.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Tusi_couple_vs_Paper_strip_plus_Ellipses_vertical.gif (500 × 500 pixels, file size: 1.91 MB, MIME type: image/gif, looped, 170 frames, 6.8 s)
File information
Structured data
Captions
Summary[edit]
DescriptionTusi couple vs Paper strip plus Ellipses vertical.gif |
English: Equivalence between "Tusi couple" and "Paper strip method". Two example ellipses are drawn in red and cyan. |
Date | |
Source | Own work |
Author | Jahobr |
Other versions |
|
GIF development InfoField | |
Source code InfoField | MATLAB codefunction Tusi_couple_vs_Paper_strip()
% source code for drawing Tusi_couple_vs_Paper_strip
% produces a GIF and a SVG
%
% 2017-04-10 Jahobr
p = 1;
nFrames = 170;
angleSmall = linspace(0,2*pi,nFrames+1); % define gear position in frames
angleSmall = angleSmall(1:end-1); % remove last frame, it would be double
figHandle = figure(15674455);
clf
axesHandle = axes;
hold(axesHandle,'on')
set(figHandle, 'Units','pixel');
set(figHandle, 'position',[1 1 1000 1000]); % big start image for antialiasing later [x y width hight]
set(axesHandle,'position',[-0.05 -0.05 1.1 1.1]); % stretch axis bigger as figure, easy way to get rid of ticks [x y width height]
xlim(p*[-1.2 1.2]);
ylim(p*[-1.2 1.2]);
axis equal; drawnow;
for iFrame = 1:nFrames;
currentAngle = angleSmall(iFrame);
cla(axesHandle) % fresh frame
barCol = [0.5 0.5 0.5]; % color of trammel bar
plot([p*cos(currentAngle) 0],[0 p*sin(currentAngle)],'.-','color',[0.5 0.5 0.5],'linewidth',35,'MarkerSize',100) % grey trammel bar
colHori = [0.1 0.7 0.1]; % green
plot([p,-p],[0 0],':','color',colHori,'linewidth',5) % horizontal line
plot([0 0],[p,-p],':b','linewidth',5) % vertical line
plot(p*cos(currentAngle),p*sin(currentAngle),'.m','MarkerSize',40) % touching point / Instant centre of rotation
circle(0,0,p) % outer circle
circle(cos(currentAngle)*0.5,sin(currentAngle)*0.5,p/2) % inner circle
plot(p*cos(currentAngle),0,'.','MarkerSize',30,'linewidth',4,'color',barCol) % overwrite line with trammel bar color
plot([p,-p],[0 0],'x','color',colHori,'MarkerSize',25,'linewidth',4) % mark end points
plot(p*cos(currentAngle),0,'.','color',colHori,'MarkerSize',40,'linewidth',4) % small dot to indicate the precise position
plot(0,p*sin(currentAngle),'.','MarkerSize',30,'linewidth',4,'color',barCol) % overwrite line with trammel bar color
plot([0 0],[p,-p],'bx','MarkerSize',25,'linewidth',4) % mark end points
plot(0,p*sin(currentAngle),'b.','MarkerSize',40,'linewidth',4) % small dot to indicate the precise position
%% save animation 1
drawnow
saveName1 = 'Tusi_couple_vs_Paper_strip';
f = getframe(figHandle);
f.cdata = imresize(f.cdata,0.5); % the size reduction: adds antialiasing
if iFrame == 1 % create colormap
[im1,map1] = rgb2ind(f.cdata,32,'nodither'); % 32 colors % create color map %% THE FIRST FRAME MUST INCLUDE ALL COLORES !!!
% FIX WHITE, rgb2ind sets white to [0.9961 0.9961 0.9961], which is annoying
[~,wIndex] = max(sum(map1,2)); % find "white"
map1(wIndex,:) = 1; % make it truly white
im1(1,1,1,nFrames) = 0; % allocate
end
imtemp = rgb2ind(f.cdata,map1,'nodither');
im1(:,:,1,iFrame) = imtemp;
if iFrame == 10
plot2svg([saveName1 '.svg'],figHandle) % by Juerg Schwizer, See http://www.zhinst.com/blogs/schwizer/
end
%% draw 2 example ellipses vertical
col1 = [0 0.9 0.9]; % cyan
ellOneOffset = 0.15;
h(1) = ellipse(0,0,ellOneOffset,p-ellOneOffset,col1,4);
uistack(h(1),'bottom');
h(2) = ellipse(0,0,ellOneOffset,p-ellOneOffset,col1,2.5);
h(3) = plot(ellOneOffset*cos(currentAngle),(p-ellOneOffset)*sin(currentAngle),'.','MarkerSize',40,'linewidth',4,'color',col1);
col2 = [1 0 0]; % red
ellTwoOffset = 0.35;
h(4) = ellipse(0,0,ellTwoOffset,p-ellTwoOffset,col2,4);
uistack(h(4),'bottom');
h(5) = ellipse(0,0,ellTwoOffset,p-ellTwoOffset,col2,2.5);
h(6) = plot(ellTwoOffset*cos(currentAngle),(p-ellTwoOffset)*sin(currentAngle),'.','MarkerSize',40,'linewidth',4,'color',col2);
%% save animation 2
drawnow
pause(0.01)
saveName2 = [saveName1 '_plus_Ellipses_vertical'];
f = getframe(figHandle);
f.cdata = imresize(f.cdata,0.5); % the size reduction: adds antialiasing
if iFrame == 1 % create colormap
[im2,map2] = rgb2ind(f.cdata,32,'nodither'); % 32 colors % create color map %% THE FIRST FRAME MUST INCLUDE ALL COLORES !!!
% FIX WHITE, rgb2ind sets white to [0.9961 0.9961 0.9961], which is annoying
[~,wIndex] = max(sum(map2,2)); % find "white"
map2(wIndex,:) = 1; % make it truly white
im2(1,1,1,nFrames) = 0; % allocate
end
imtemp = rgb2ind(f.cdata,map2,'nodither');
im2(:,:,1,iFrame) = imtemp;
if iFrame == 12
plot2svg([saveName2 '.svg'],figHandle) % by Juerg Schwizer, See http://www.zhinst.com/blogs/schwizer/
end
%% draw 2 example horizontal
delete(h); % delete vertical ellipses
h(1) = ellipse(0,0,p-ellOneOffset,ellOneOffset,col1,4);
uistack(h(1),'bottom');
h(2) = ellipse(0,0,p-ellOneOffset,ellOneOffset,col1,2.5);
h(3) = plot((p-ellOneOffset)*cos(currentAngle),ellOneOffset*sin(currentAngle),'.','MarkerSize',40,'linewidth',4,'color',col1);
h(4) = ellipse(0,0,p-ellTwoOffset,ellTwoOffset,col2,4);
uistack(h(4),'bottom');
h(5) = ellipse(0,0,p-ellTwoOffset,ellTwoOffset,col2,2.5);
h(6) = plot((p-ellTwoOffset)*cos(currentAngle),ellTwoOffset*sin(currentAngle),'.','MarkerSize',40,'linewidth',4,'color',col2);
%% save animation 3
drawnow
pause(0.01)
saveName3 = [saveName1 '_plus_Ellipses_horizontal'];
f = getframe(figHandle);
f.cdata = imresize(f.cdata,0.5); % the size reduction: adds antialiasing
if iFrame == 1 % create colormap
[im3,map3] = rgb2ind(f.cdata,32,'nodither'); % 32 colors % create color map %% THE FIRST FRAME MUST INCLUDE ALL COLORES !!!
% FIX WHITE, rgb2ind sets white to [0.9961 0.9961 0.9961], which is annoying
[~,wIndex] = max(sum(map3,2)); % find "white"
map3(wIndex,:) = 1; % make it truly white
im3(1,1,1,nFrames) = 0; % allocate
end
imtemp = rgb2ind(f.cdata,map3,'nodither');
im3(:,:,1,iFrame) = imtemp;
if iFrame == 30
plot2svg([saveName3 '.svg'],figHandle) % by Juerg Schwizer, See http://www.zhinst.com/blogs/schwizer/
end
end
imwrite(im1,map1,[saveName1 '.gif'],'DelayTime',1/25,'LoopCount',inf) % save gif1
imwrite(im2,map2,[saveName2 '.gif'],'DelayTime',1/25,'LoopCount',inf) % save gif2
imwrite(im3,map3,[saveName3 '.gif'],'DelayTime',1/25,'LoopCount',inf) % save gif3
disp([saveName3 '.gif has ' num2str(numel(im3)/10^6 ,4) ' Megapixels']) % Category:Animated GIF files exceeding the 50 MP limit
return
%%
function circle(x,y,r)
% x coordinates of the center
% y coordinates of the center
% r is the radius of the circle
angleOffPoints = linspace(0,2*pi,300);
xc = x + r*cos(angleOffPoints);
yc = y + r*sin(angleOffPoints);
plot(xc,yc,'k','linewidth',5);
function h = ellipse(x,y,a,b,col,linw)
% x coordinates of the center
% y coordinates of the center
% a radius1
% b radius2
angleOffPoints = linspace(0,2*pi,300);
xe = x + a*cos(angleOffPoints);
ye = y + b*sin(angleOffPoints);
h = plot(xe,ye,'-','linewidth',linw,'color',col);
|
Licensing[edit]
I, the copyright holder of this work, hereby publish it under the following license:
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.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 07:46, 12 April 2017 | 500 × 500 (1.91 MB) | Jahobr (talk | contribs) | {{Information |Description ={{en|1=Tusi couple vs Paper strip method plus Ellipses }} |Source ={{own}} |Author =Jahobr |Date = |Permission = |other_versions = }} Category:Tusi-couple |
You cannot overwrite this file.
File usage on Commons
The following 3 pages use this file: