I.Watch out, here comes some high-school word-problem-style math!
Suppose you have a body T (which you intend to be the "rack" part of a rack and pinion) heading left at a constant rate towards a spinny gear thing rotating about the origin. The spinny gear thing has some part P, which you want to eventually strike T at a selected point E. (E being the place where that point right now).
The question we eventually want to answer is:
Where on the gear right now should we put some speck of mass in P in order to eventually strike body T at our chosen point E by the time it arrives in a suitable place near the gear?We'll call the position of that point at the time of contact "C". You might feel like the problem is underspecified, since maybe P could be free to strike T somewhat earlier or later - it turns out it's not. The important assumptions are that the spinny gear thing is spinning at a constant rate, and the rack is moving to the left at a constant rate.
That constant-rate-of-motion-to-the-left of body T must be R distance units per radian of spin for the rack-and-pinion system to behave like the idealized line-and-circle system consisting of the line EB and the radius-R circle centered at the origin. So we know VT, the velocity of T, (considered as a rate of distance per radian of gear-turn) is the vector (-R, 0). The velocity at the point C on the body P is, well, the standard thing you get from rotational motion; the velocity vector is perpendicular to the line connecting it to the origin of the circle. It's VP = (yc, -xc).
II.A critical mechanical constraint about P pushing T around is the following:
When P contacts T at point C, the velocity of P relative to T has to be parallel to the tangent line of the two surfaces of P and T along which they are in contact.
(The tangent to T at E is depicted in the diagram by the line EY; the tangent line at the moment of contact is not pictured, but it's parallel to EY and passes through C)
Why does this constraint hold? If VP - VT had any velocity perpendicular to the common surface of P and T at the time of contact, then either a split second later (or a split second ago, depending on the sign of the velocity) it would be penetrating the solid body T, and we can't have that. What it means for the relative velocity to be nonzero but parallel to the surface is just that P is (while pushing against T) also slipping in one direction or another. This is mechanically possible and acceptable.
III.Q: For which points of contact between P and T can this constraint be satisfied?
A: On and only on the line YB, the line that passes through the bottom of the gear's "pitch circle", and which is perpendicular to the slope of body T at the point of contact .
We can see this algebraically: let m be the slope of the body T at the chosen point E. Compute the relative velocity
VP - VT = (yc, -xc) - (-R, 0)
= (yc + R, -xc)
The slope of this velocity vector is -xc/(yc + R). If we set it equal to m, we find
m = -xc/(yc + R)
yc + R = (-1/m) xc
yc = (-1/m) xc - R
which is the result we claimed above.
We can also see it to be true geometrically: stare at the diagram and observe that the triangle OCB is related to CVPVT by a 90-degree rotation, so the relative velocity vector VPVT is perpendicular to the line BC.
What do we now know? Given any point-with-derivative (xE, xE, m) off in the distance, we know that it must contact the gear at a point on the line
yc = (-1/m) xc - R
But clearly yc = yE since the rack is just moving horizontally. So we can look back up above at our observation in the previous section that m = -xc/(yc + R) and deduce that xc = -m(yE + R) so we know the contact point C is
(-m(yE + R), yE)
Since the rack is moving at a constant rate of R distance per radian, we can find the time of future contact by just computing (xE - xC) / R = (xE + m(yE + R)) / R
radians in the future.
Therefore, to answer the original question, where we should plop some mass down onto the gear right now is whatever you get by taking the contact point (-m(yE + R), yE) and rotating it backwards by (xE + m(yE + R)) / R radians.
We somewhat arbitrarily decide that our rack should look like a series of trapezoids where the angle of the slopey bits is chosen arbitrarily, and the height is chosen to be one-half of the "rack pitch", i.e. the period of the periodic function whose graph is the rack.
If we simply take every point of the rack, and apply the above procedure to find a corresponding point on the gear, we get... a gear!
(image link goes to jsfiddle animated rotating gear)
VI.But wait, what are the seafoam-green bits?
They are for the non-differentiable vertices of the rack shape: for those, we apply the above procedure over just the one point at that vertex, but using all of the slopes intermediate between the slope of the previous line segment, and the slope of the next line segment. These aren't actually involute curves, but they look just like the smooth fillets I'm used to seeing in gear drawings, so I assume I did the right thing there.