# May 2017 Community Challenge

The April 2017 has just been selected as simulating a multi-way intersection, so let's get started on picking one for May 2017.

It's time to choose a for May 2017.

• Post your challenge as an answer to this question. Feel free to resubmit non-winning ideas from previous months.
• Vote for those answers which interest you.
• At the end-of-day on Sunday, April 30th, the top-voted post will become the next challenge.

Once the challenge topic is decided, post your solution as a question on the main site and tag it with . The challenge runs throughout May (but nothing stops you from posting an entry later on).

• Come on, it's already June, this is still featured? – EKons Jun 2 '17 at 10:47

(re-submit of an idea from last round and the one before that because 3rd time's the charm?)

# Chain (or belt) drive system

I propose a variation on this challenge by Ell over on PCG - minus the golfing requirement, of course. (Disclosure: I've already done this challenge in JavaScript)

To quote the original:

Your program will be given a list of sprockets, specified as (x, y, radius) triplets. The resulting chain drive system is comprised of these sprockets, connected together by a closed taut chain passing over each of them, in order. [...]

For example, given the input

(0, 0, 16),  (100, 0, 16),  (100, 100, 12),  (50, 50, 24),  (0, 100, 12)


the output should look something like

(Please do check out the original challenge in its entirety, as it includes plentiful examples of input and output, and goes into a lot more detail, all of which Ell explains better than I can hope to do here.)

The original challenge is to generate a fully animated chain drive system, but that's quite a mouthful, so I propose that it can be solved to different degrees:

• Analysis without visual output (for example some or all of: calculating the total chain length, whether the chain crosses itself, the rotational offset from one sprocket to the next that's necessary for the chain to mesh, time taken for a link in the chain to make one full circuit, etc.)

• Simplified, static visualization showing the spatial layout and chain path

• Full-on animation, as per the original challenge

• Interactive visualization (animated or not), e.g. with customizable settings or even click and drag sprockets

And the chain doesn't need to be a chain nor do the sprockets need to be sprockets; it could just be a belt drive system, i.e. plain circles and lines. This would add a lot of flexibility as things won't need to mesh (and radii and placements won't be constrained), but you'd still be calculating tangent points etc.. Animation wouldn't be as fun, but one could add indicators to the wheels and belt to show the movement.

Or one could go the other way, and have the chain be properly segmented into rigid links like a bike chain, instead of drawing a smooth arc around the sprockets.

I admit that the challenge appears a little daunting, but it's actually not that bad. If the goal is simply to do that analysis part (i.e. no animation or graphical output), it can be done in pretty much any language. All that's needed is a bit of math; trigonometry and basic geometry (to work out tangent points and arc lengths).

Still, the task does look daunting, which presents a bit of a barrier to entry so I don't know if it's the best fit for a community challenge. But personally I found it to be an interesting (and fun!) task, with plenty of "meat" on its bones.

• Looks like this one is going to win by default this time around. :) – Der Kommissar Apr 29 '17 at 23:56
• @EBrown Aw, that's not what I wanted either. Honestly, if there's no real competition, I'd be fine with the selection being postponed/redone. I admit I'd like to see this win, but me saying that doesn't count for anything. If there's no great interest, well, shucks, that's no fun. There were a ton of other great entries last round - where're they at? – Flambino Apr 30 '17 at 0:30
• I ran the last selection extra long and advertised it a bunch in our chat, I'll do the same for the round I post tomorrow night. – Der Kommissar Apr 30 '17 at 0:30
• @EBrown Cool - and thanks for running these things! I admit to being a little sour last time, only because it was neck-a-neck for so long and ended up ±1, but now I'm hoping for some competition – Flambino Apr 30 '17 at 0:33
• Is it correct that the chain may not exactly fit between the teeth of the sprocket, since the segment length is only approximately 4π ? – Martin R May 16 '17 at 12:21
• @MartinR Yes, it takes some liberties here and there; if the end result looks good, it's fine. With the input examples in the original challenge, things look pretty good overall - at worst it's off by a fraction of a pixel, or something. Nothing you really notice. I mean, you're free to do some constraint-solving to find the exact radii and positions that'll make the chain mesh perfectly, buuuut... :) By the way, for my solution on PCG, I divided the chain into N segments for N gears, and drew each segment to avoid accumulating rounding errors over the full length. – Flambino May 16 '17 at 12:30