本帖最后由 雷欧库珀 于 2021-7-3 10:07 编辑
[C++] 纯文本查看 复制代码 clear;
%1.输入已知参数和计算基本尺寸
z = input('请输入齿数 z=');
m = input('请输入模数 m=');
x = input('请输入变位系数 x=');
ditay = input('请输入齿顶高变位系数=');
hd = pi / 180; N = 10;
rb = z * m * cos(20 * hd) / 2;
ra = (z / 2 + 1 + x - ditay) * m;
rf = (z / 2 - 1.25 + x) * m;
rw = (z / 2 - 1 + x) * m;
theta20 = tan(20 * hd) - 20 * hd;
alpha_A = acos(rb / ra);
theta_A = tan(alpha_A) - alpha_A;
beta_A = (pi + 4 * x * tan(20 * hd)) / (2 * z) - (theta_A - theta20);
alpha_W = acos(rb / rw);
theta_W = tan(alpha_W) - alpha_W;
beta_W = (pi + 4 * x * tan(20 * hd)) / (2 * z) - (theta_W - theta20);
%2.计算渐开线齿廓左侧各点的坐标
r = rw:(ra - rw) / N:ra; %计算渐开线齿廓左侧各点的矢径
for i = 1:(N + 1)
alpha(i) = acos(rb / r(i)); %计算渐开线齿廓左侧各点的压力角
theta(i) = tan(alpha(i)) - alpha (i); %计算渐开线齿廓左侧各点的展角
beta(i) = (pi + 4 * x * tan(20 * hd)) / (2 * z) - (theta(i) - theta20);
x1(i) = -r(i) * sin(beta(i)); %计算渐开线齿廓左侧各点的坐标
y1(i) = r(i) * cos(beta(i));
end
%3.计算渐开线齿廓左侧其他各点的坐标
xf = -rf * sin(beta_W); %计算左侧齿根曲线上F点的坐标
yf = rf * cos(beta_W);
xe = -rf * sin(pi / z); %计算左侧齿根曲线上E点的坐标
ye = rf * cos(pi / z);
xc = 0; %计算齿顶曲线上c点的坐标
yc = ra;
x1 = [xe, xf, x1, xc];
y1 = [ye, yf, y1, yc];
%4.计算渐开线齿廓右侧各点的坐标
x2 = -x1;
y2 = y1;
y2 = rot90(y2); %将右侧各段曲线的坐标的次序倒置
y2 = rot90(y2);
x2 = rot90(x2);
x2 = rot90(x2);
x = [x1, x2];
y = [y1, y2];
plot(x, y); hold on; %绘制齿轮
%5.通过坐标变换将齿轮曲线绕中心依次旋转得到其他各齿形
for i = 1:(z - 1)
delta(i) = i * 2 * pi / z; %齿轮转角
xy =[x',y']; %齿轮曲线坐标
A1 = [cos(delta(i)), sin(delta(i));-sin(delta(i)), cos(delta(i))]; %齿轮坐标旋转矩阵
A1 = repmat(A1,14,1);
xy = xy .* A1;
plot(xy(:,1),xy(:,2)); hold on; %绘制齿轮
end
axis equal;
grid on;
title('渐开线变位直齿圆柱齿轮');
救命啊 |