# How can you calculate the angle required to line up the teeth of cogs if you know all their attributes

Cog $A$ is at position: $Ax$, $Ay$, rotation: $Ar$ and number of teeth: $At$

Cog $B$ is at position: $Bx$, $By$ and number of teeth $Bt$. What is Cog $B$'s rotation such that teeth between Cog $A$ and Cog $B$ line up. There will be the same number of answers as there are teeth, but a 'base angle' is desired.

-
Image here: i.imgur.com/ICrhs.jpg –  sq2 Jul 15 '12 at 3:50

You can calculate the angle $\alpha$ of the line from $A$ to $B$ as $\alpha=\arctan\frac{By-Ay}{Bx-Ax}$. You want the phases to be opposite at this angle, so $(\alpha-Ar)At=(\alpha+\pi-Br)Bt+\pi+ 2\pi n$, with $n$ an integer; you can solve this for $Br$ to determine $Br$ up to integer multiples of $2\pi/Bt$.

-
@sq2: Then it would be great if you'd write it up as an answer; then your question wouldn't remain unanswered, and we could compare our solutions. –  joriki Jul 17 '12 at 11:41