Clear Filters
Clear Filters

Plotting path of rods on a circular disk along a surface to deduce rack gear profile.

1 view (last 30 days)
I am trying to design a custom rack gear similar to ones used in a rack and pinion gear system. Instead of a pinion i am using a disk with 4 rods equally spaced on the disk that almost act as the teeth. I want to be able to plot the path of the rods as the disk rotates over a flat surface by simulating the movement. With this path I can design the rack.

Accepted Answer

Mathieu NOE
Mathieu NOE on 5 Jul 2024
ok, I had some fun today with your exercise ...
time to grind a bit the sharp edges though !
% a disk fitted with 4 rods
d = 2; % central disk diameter
% rods
w = 0.75; % width
l = 1.5; % length
%% main code
N = 100; % disk geometry is created with 4N points, rods with N/2 points for each side segment
[xx,yy] = geometry(d,w,l,N);
% let's plot the geometry once
figure(1)
plot(xx,yy,'*-');
title('The disk / rods geometry');
axis square
% let it roll half a turn (in the x positive direction
figure(2)
plot(xx,yy,'-');
hold on
N = 100; % iterations
% store all points for future use (boundary)
xx_all = [xx];
yy_all = [yy];
for k = 1:N
alpha = -pi*k/N;
[xxr,yyr] = roll(xx,yy,alpha,d,l);
plot(xxr,yyr,'-');
% pause(0.05)
% store all points for future use (boundary)
xx_all = [xx_all xxr];
yy_all = [yy_all yyr];
end
% axis square
% extract now the rack profile using
k = boundary(xx_all(:),yy_all(:),1);
x_rack = xx_all(k);
y_rack = yy_all(k);
% remove some points that shall not belong to the rack
% remove points above the top flat sections of the rack
ind = y_rack>-d/2*0.9;
x_rack(ind) = [];
y_rack(ind) = [];
% remove negative x points
ind = x_rack<0;
x_rack(ind) = [];
y_rack(ind) = [];
% remove trailing x points
ind = find(y_rack<=y_rack(1),1,'last');
x_rack(ind:end) = [];
y_rack(ind:end) = [];
plot(x_rack,y_rack,'r*-');
title('rolling !');
hold off
figure(3)
% shift the y coordinates so the bottom appears at y = 0
y_rack = y_rack - min(y_rack);
plot(x_rack,y_rack,'r*-');
title('The rack geometry');
% % smooth a bit the top of the rack
% y_racks = smoothdata(y_rack,'movmean',5);
% plot(x_rack,y_rack,'r*-',x_rack,y_racks,'b*-');
%%%%%%%%%%%%%%%%%%%%%%%%
function [xxr,yyr] = roll(xx,yy,alpha,d,l)
% rotation
% alpha = -pi/10;
c = cos(alpha);
s = sin(alpha);
R = [c -s;s c];
tmp = R*[xx;yy];
xxr = tmp(1,:);
yyr = tmp(2,:);
% and x translation as if the disk is rolling to the right
xshift = -(d/2 + l)*alpha;
xxr = xxr + xshift;
end
%%
function [xx,yy] = geometry(d,w,l,N)
% disk
% d = 2;
n = 4*N;
theta = (0:n-1)/n*2*pi;
xd = d/2*cos(theta);
yd = d/2*sin(theta);
% add the four legs (rods)
% for more control over the rectangle shape , you can use this fex submission :
% https://fr.mathworks.com/matlabcentral/fileexchange/85418-rectangle2?s_tid=ta_fx_results
% first rod at position 3 o' clock
x1 = xd(1);
x2 = x1 + l;
y1 = yd(1)-w/2;
y2 = y1 + w;
% create some dots for the rods
k = round(N/2);
xx = linspace(x1,x2,k);
yy = linspace(y1,y2,k);
xBox = [xx x2*ones(1,k) xx(end:-1:1)];
yBox = [y1*ones(1,k) yy y2*ones(1,k)];
% remove some points of the circle
ind = (abs(xd)<w/2) | (abs(yd)<w/2);
xd(ind) = [];
yd(ind) = [];
% concatenate all coordinates
xx = [xd xBox yBox -xBox -yBox];
yy = [yd yBox xBox -yBox -xBox];
% put all those points in ascending theta order
[TH,R] = cart2pol(xx,yy);
[TH,ind] = sort(TH);
R = R(ind);
[xx,yy] = pol2cart(TH,R);
% close the curve
xx(end+1) = xx(1);
yy(end+1) = yy(1);
end
  8 Comments
Mathieu NOE
Mathieu NOE on 16 Jul 2024
hello again
simple modification below so you can now slect any number of rods you want
% a disk fitted with Nr rods
d = 3; % central disk diameter
rd = 0.75; % rods diameter
Nr = 8; % number of rods
%% main code
N = 30; % geometry is created with N points
[xx,yy] = geometry(d,rd,N,Nr);
% let's plot the geometry once
figure(1)
plot(xx,yy,'*-');
title('The disk / rods geometry');
axis square
% let it roll half a turn (in the x positive direction
figure(2)
plot(xx,yy,'-');
hold on
N = 100; % iterations
% store all points for future use (boundary)
xx_all = [xx(~isnan(xx))];
yy_all = [yy(~isnan(yy))];
for k = 1:N
alpha = -pi*k/N;
[xxr,yyr] = roll(xx,yy,alpha,d,rd);
plot(xxr,yyr,'-');
% store all points for future use (boundary)
xx_all = [xx_all xxr(~isnan(xxr))];
yy_all = [yy_all yyr(~isnan(yyr))];
end
% extract now the rack profile using boundary
k = boundary(xx_all(:),yy_all(:),1);
x_rack = xx_all(k);
y_rack = yy_all(k);
% select only the bottom section of the boundary
tf = find(islocalmin(y_rack, 'MinSeparation', 10) & (y_rack<min(y_rack)*0.9));
ind = tf(1):tf(end);
x_rack = x_rack(ind);
y_rack = y_rack(ind);
plot(x_rack,y_rack,'r*-');
axis equal
title('rolling !');
hold off
figure(3)
% shift the y coordinates so the bottom appears at y = 0
y_rack = y_rack - min(y_rack);
plot(x_rack,y_rack,'r-');
title('The rack geometry');
axis equal
%%%%%%%%%%%%%%%%%%%%%%%%
function [xxr,yyr] = roll(xx,yy,alpha,d,rd)
% rotation
c = cos(alpha);
s = sin(alpha);
R = [c -s;s c];
tmp = R*[xx;yy];
xxr = tmp(1,:);
yyr = tmp(2,:);
% and x translation as if the disk is rolling to the right
xshift = -(d/2 + rd/2)*alpha;
xxr = xxr + xshift;
end
function [xx,yy] = geometry(d,rd,N,Nr)
% one peg
theta = (0:N)/N*2*pi;
xd = rd/2*cos(theta)+d/2;
yd = rd/2*sin(theta);
xx = [xd NaN];
yy = [yd NaN];
% add the remaining pegs
% peg are positioned on the pitch circle of diameter d
% first peg at position 3 o'clock
for k = 1:Nr-1
alpha = k*2*pi/Nr;
c = cos(alpha);
s = sin(alpha);
R = [c -s;s c];
tmp = R*[xd;yd];
xxr = tmp(1,:);
yyr = tmp(2,:);
xx = [xx xxr NaN];
yy = [yy yyr NaN];
end
end
%%

Sign in to comment.

More Answers (0)

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!