Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images:
In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain will be the base circles of another iteration of chains:
Write a program/function that accepts image dimensions and a list of integers denoting the level of circles in each successive iteration of chains, and output an image with the recursive Steiner chains drawn to it.
Your program/function will accept 2 arguments:
s- width and height of image
ls- list of positive integers denoting the number of circles present in each successive iteration of chains, ordered from the top-most chain to the bottom-most chain
Your program/function will output an image of dimension
s displaying the recusive Steiner chain.
- The top level base circle will be as large as the image with a diameter of
s, centered inside the image
- To make things easy, the 2 base circles of a Steiner chain will be concentric, that is, the centerpoints of the 2 baseline circles will be the same
- Given an outer radius,
R, and the number of circles in a chain,
N, the formula for the inner radius
R' = (R-R*sin(pi/N))/(sin(pi/N)+1)
- Circles of the chain as well as the inner base circle will be the outer base circles of the next iteration of chains
- While recursing through the chain circles, the order of the next chain should correspond to the next value in
- While recursing through the inner circle of a chain, the order should be the same as its parents order (example [5,2]):
- All chains should end recursion at a depth of the length of
- The rotation of the chains doesn't matter:
- However, the rotations of recursive chains relative to their parents centerpoint should be the same:
- All circles should be drawn with an outline or solid fill
- Color choice is left to the implementation, save for loopholes (for example, filling everything with the same color)
In the following examples, color is determined by
(depth of the recursion)^4.
You can find source here.