如何使齿轮啮合

发布于 2024-12-04 13:50:36 字数 552 浏览 13 评论 0原文

(我不知道很多齿轮类型术语...)

我有两个齿轮(齿轮 A 和 B),我正在尝试使其啮合。

有用的东西
我已经成功编写了代码,确保齿轮之间的距离正确,并根据该数字以适当的速度旋转具有不同数量齿轮的齿轮。

问题
当齿轮 B 放置在齿轮 A 旁边时,我无法计算齿轮 B 的旋转角度,以便齿轮上的齿轮啮合在一起(两个齿轮上的齿轮尺寸相同)。

齿轮 A 以 x1,y1 为中心并旋转 q 度。齿轮 B 的中心位于 x2,y2,距齿轮 A 的距离为 d。齿轮上两个齿轮之间的距离为 c

我使用 Math.atan2(y2-y1, x2-x1) *(180/Math.PI); 来计算两个齿轮相对于原点的角度,但并不总是得到好的结果(可能是我其他地方的代码中的问题,不确定......)我的想法是使用这个角度和q来计算齿轮B的旋转值。

我可能可以使用q %c 获得更多齿轮 B 的精确/较小的旋转值,但不确定如何进行。

(I don't know a lot of gear type terminology...)

I have two gears (Gear A and B) that I'm trying to get to mesh.

Things That Work
I've successfully written code that makes sure the gears are the correct distance apart and that rotates gears with varying numbers of cogs at the appropriate speed based on this number.

The Problem
I am having trouble calculating at what rotation gear B should be when it's placed next to Gear A so that the cogs on the gears mesh together (the cog size is the same on both gears).

Gear A is centered at x1,y1 and is rotated at q degrees. Gear B is centered at x2,y2 and is d distance from Gear A. The distance between two cogs on a gear is c.

I use Math.atan2(y2-y1, x2-x1) *(180/Math.PI); to calculate the angle between the two gears relative to the origin but don't always get good results (may be an issue in my code somewhere else, not sure...) My thought was to use this angle and q to compute a rotational value for gear B.

I could probably use q%c to get a more precise/smaller rotation value for gear B, but not sure quite how to proceed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-12-11 13:50:36

考虑一个有 n 个齿轮的齿轮。如果 n 是偶数,则每个齿轮对面都有另一个齿轮。如果 n 是奇数,则相反的每个齿轮都是一个凹口(或任何正确的术语)。无论哪种情况,如果将齿轮旋转 2π/n 弧度,它看起来都会和以前一样——每个齿轮都“移动了”。所以角度只以 2π/n 为模重要。

考虑两个相同的齿轮,啮合,都以 x 轴 (y=0) 为中心。如果 n 是奇数,那么它们的角度可以相等(当齿轮指向 x 方向时,我们可以称该角度为 0),并且一般来说,如果一个齿轮处于角度 a ,那么另一个将处于角度-a。如果 n 为偶数,则当一个档位为 0 时,另一个档位将位于 π/n,一般来说,当一个档位位于 a 时,另一个档位将位于 π/na

现在假设左边的齿轮(“齿轮 A”)有 n 个齿,右边的齿轮(“齿轮 B”)有 m 个齿。如果m为奇数,则当齿轮B位于am时,齿轮A位于-an。如果m为偶数,则当B档在am时,A档在π/n-an

现在假设它们的中心不在同一 y 值,因此从齿轮 A 的中心看,齿轮 B 的中心处于角度 b。现在从旋转角度中减去该角度每个档位,然后您将问题减少到前一个档位。

Consider a gear with n cogs. If n is even, then opposite every cog is another cog. If n is odd then opposite every cog is a notch (or whatever the correct term is). In either case, if you rotate the gear by 2π/n radians, it will look the same as it did before-- each cog has "moved over". So angle matters only modulo 2π/n.

Consider two identical gears, meshing, both centered on the x-axis (y=0). If n is odd, then their angle can be equal (we can call that angle 0, when a cog is pointing in the x direction), and in general if one gear is at angle a, then the other will be at angle -a. If n is even then when one gear is at 0, the other will be at π/n, and in general when one is at a the other will be at π/n-a.

Now suppose that the gear on the left ("gear A") has n cogs and the gear on the right ("gear B") has m cogs. If m is odd then when gear B is at am, gear A is at -an. If m is even, when gear B is at am, gear A is at π/n-an.

Now suppose that their centers are not at the same y value, so that the center of gear B is at angle b as seen from the center of gear A. Now the subtract that angle from the angle of rotation of each gear, and you reduce the problem to the previous one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文