## Bike trig: distance b/w sprockets connected by a chain

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

TheSkyMovesSideways
Posts: 589
Joined: Thu Oct 02, 2008 8:36 am UTC
Location: Melbourne, Australia
Contact:

### Bike trig: distance b/w sprockets connected by a chain

I'm trying to build an application to perform some various calculations relating to bicycle gearing, and there's one problem I'm stuck on - how to calculate the distance between the rear wheel axle and the crankset/bottom bracket axle for a chain of known length and sprockets of known size. (It is possible on some bikes to adjust the position of the rear axle.)

Firstly, a little nomenclature and background:
- The distance between the two axles is often called the "chainstay length", named after the structural members running between the them.
- The rear sprocket is normally called "sprocket" and the front one is called "chainring".
- Sprockets and chainrings are measured by the number of teeth they possess, and their circumference (where the chain rests) can easily be calculated by multiplying the number of teeth by the chain pitch (which is almost always a half inch).

Here's the maths I've done so far (including a diagram showing the problem), which can be used to calculate the chain length given the size of the sprocket and chainring, and the distance between their centres.
Spoiler:
lcs : The chainstay length, or distance between the two axles.
rs : Radius of the sprocket (to where the chain sits).
rc : Radius of the chainring (to where the chain sits).
αs : Angle between chainstay line and point where the chain contacts the sprocket.
αc : Angle between chainstay line and point where the chain contacts the chainring.
lt : Length of either section of taut chain, where it is not containing chainring or sprocket.
ccs : Circumference of the sprocket in contact with the chain (or length of the chain in contact with the sprocket).
ccc : Circumference of the chainring in contact with the chain (or length of the chain in contact with the chainring).

So we can calculate the chain length as follows:
\begin{align} l_c &= 2l_t + c_{cs} + c_{cc} \\ &= 2\sqrt{l_{cs}^2 - (r_c-r_s)^2} + r_c(2\pi-2\arccos \frac{r_c-r_s}{l_{cs}}) + r_s(\pi-2\arcsin \frac{r_c-r_s}{l_{cs}}) \\ \end{align}

Now, when it comes to calculating the distance between the axles from the length of the chain, it gets a bit tricky. I don't know of any way to rearrange the above (spoilered) equation to form a function for lcs, and I can see any other way to solve it from the diagram. I'm tempted to just do it numerically, obtaining a starting point by assuming αs and αc to both be 90°, simplifying the problem to just subtracting a couple of half circumferences and (twice) a Pythagorean calculation, then iteratively feeding this approximate value into the formula above and adjusting based on how the result deviates from the expected chain length. However, if anyone has any other ideas, I'd be very interested to hear them.

Actually, after writing this, I've just realised that it can be simplified a little, using the following:
Spoiler:
\begin{align} \alpha_s &= \pi - \alpha_c \\ l_c &= 2\sqrt{l_{cs}^2 - (r_c-r_s)^2} + r_c(2\pi-2\arccos \frac{r_c-r_s}{l_{cs}}) + 2r_s\arccos \frac{r_c-r_s}{l_{cs}} \\ &= 2\sqrt{l_{cs}^2 - (r_c-r_s)^2} + 2\pi r_c + 2(r_s-r_c)\arccos \frac{r_c-r_s}{l_{cs}} \\ \end{align}

Still doesn't help me any, however.

Thanks! (Also, INB4 homework. It isn't.)
I had all kinds of plans in case of a zombie attack.
I just figured I'd be on the other side.
~ASW

TheSkyMovesSideways
Posts: 589
Joined: Thu Oct 02, 2008 8:36 am UTC
Location: Melbourne, Australia
Contact:

### Re: Bike trig: distance b/w sprockets connected by a chain

Having thought about it a bit more, the problem can be simplified by calculating lc in terms of αc instead of lcs. However, it still looks to be unsolvable algebraically (getting αc in terms of lc).

Spoiler:
\begin{align} l_c &= 2l_t + c_{cs} + c_{cc} \\ &= 2(r_c-r_s)\tan{\alpha_c} + (2\pi-2\alpha_c)r_c + 2\alpha_cr_s \\ &= 2(r_c-r_s)\tan{\alpha_c} + 2\pi r_c - 2(r_c-r_s)\alpha_c \\ &= 2(r_c-r_s)(\tan{\alpha_c}-\alpha_c)+2\pi r_c \\ \end{align}
I had all kinds of plans in case of a zombie attack.
I just figured I'd be on the other side.
~ASW

lamemaar
Posts: 13
Joined: Wed Dec 29, 2010 9:52 am UTC

### Re: Bike trig: distance b/w sprockets connected by a chain

Just for fun, I wrote an iterative program to compute the distance between the two axles, with given radius of each wheel and the length of the chain (or belt). I wrote this in C++. Can you handle the source code of this? If so, I can publish it here. If not, please let me know so I can help you.