Gear Placement - Matlab Code
%% Shaft Heights
% Imagine the clock lying with the face up and you're looking at the gears from the side so that the "width" of the gear is, in this model, the height.
GTH=(1) % Gear Thickness.
WBG=(1/4) % Width Between Gears.
T=8 % Number of teeth of the smallest gear. In this model, T is represented by the horizontal width.
d=GTH+WBG % A combination for ease
cla
axis([-15*T 15*T 0 (GTH+WBG)*10])
for i=1:9
var=[1,2,2,3,5,4,5,6,6,4,3.5,2,2]; % This matrix gives the ratios for the gear sizes
yvals = [0 0 GTH GTH]; % Y values are constant; all gears are the same width
xvals = [0 var(i)*T var(i)*T 0]; % X values vary by the ratio of the gear size
xtrans=[0,T,2.5*T,4*T,6*T,-4*T,-7.5*T,-11.5*T,-8*T,-4.5*T,-6.5*T,-4.25*T,-5.75*T]
ytrans=[d*(i-1),d*(i-2),d*(i-2),d*(i-2),d*(i-2),d*(i-6),d*(i-6),d*(i-6),d*(i-5),d*(i-5),d*(i-5),d*(i-5),d*(i-5),d*(i-5)]
Gear = patch(xvals+xtrans(i),WBG+yvals+ytrans(i),[1 1 0]);
end
for j=1:7
xvals2 = [0 T T 0]
yvals2 = [0 0 GTH GTH];
xtrans2=[1.5*T,3*T,5*T,-2.5*T,-5.5*T,-9*T,-9*T,-5.5*T,-4*T,-5.25*T,-3.75*T];
ytrans2=[d*j,d*j,d*j,d*(j-3),d*(j-3),d*(j-3),d*(j-3),d*(j-3),d*(j-3),d*(j-3),d*(j-3),d*(j-3)]
Backing=patch(xvals2+xtrans2(j),WBG+yvals2+ytrans2(j),[1 0 0]);
end
%% Shaft Locations
cla;
r=.25; % radius of the first (smallest) gear
% First, all the x values will be generated
ax=0; %Center (second hand)
bx=3*r*cosd(60); %Blue Circles (minute hand); ex is centered
cx=6*r*cosd(60);
dx=6*r*cosd(60-acosd(7/9));
ex=0;
fx=-5*r*cosd(45-acosd(87/(10*sqrt(98)))); %Green circles (hour hand); ix is centered
gx=-7*r;
hx=0;
ix=0;
% Then, all the y values will be generated
ay=0; %Center (second hand)
by=-3*r*sind(60); %Blue circles (minute hand); ey is centered
cy=-6*r*sind(60);
dy=-6*r*sind(60-acosd(7/9));
ey=0;
fy=5*r*sind(45-acosd(-87/(-10*sqrt(98)))); %Green circles (hour hand);iy is centered
gy=7*r;
hy=7*r;
iy=0;
% Create matrices for the x and y values calculated above
xvals=[ax,bx,cx,dx,ex,fx,gx,hx,ix];
yvals=[ay,by,cy,dy,ey,fy,gy,hy,iy];
% Plot the values on a graph
plot(xvals,yvals,'ro');
axis(r*15*[-1 1 -1 1]);
grid on;