Given a circle (for simplicity, $x^2 + y^2 = 1$) and a chord on this circle parallel to the $x$ axis $y = p - 0.5$ ($p \in [0,1]$ being the only parameter I control), how can I estimate the relationship between $p$ and the ratio between the circular segment determined by the circle and the chord and the point $(0,-1)$?

I do not require full precision (I only have coarse control over $p$, after all), but if no readily available approximation is available, I'll take the full formula.

In English — I have a circular shape in Powerpoint; I want to color a portion of its area with a given color. Powerpoint doesn't let me color a circular sector using the gradient fill tool, so I have to resort to a gradient section. The alternative is complicating the drawing with the arc tool and its fiddly controls. Thus, I'd like to know what portion of the circle I'd color if I color what's below a chord placed at $p$% height of the circle with red and the remainder in white.

Your circle has radius 1, so if you want to fill it to a percentage of its height $p$ the resulting $d$ distance on the Wikipedia picture should be $1-2p$, not $0.5-p$. Edit : and by the way if you make that change your formula does give the answer $0$ for $p=0$.
–
VhailorMay 29 '11 at 16:06

3 Answers
3

Edit: I was wrong about the number of times you have to apply $f$ in each case. Corrected below.

If you want to "fill" the area $D$ in a circle of radius $1$, then you want to solve the equation:

$$\cos^{-1} q - q\sqrt{1-q^2} = D$$

Which is the same as:

$$q = \cos(D+q\sqrt{1-q^2})$$

Letting $f(q)=\cos(D+q\sqrt{1-q^2})$, you can use the sequence $0, f(0), f(f(0)), f(f(f(0))), ...$ For the most part you only need to compute $f^{20}(0)$ to get the result you want. You can get a better convergence if you start with $q_0=1-\frac{2D}{\pi}$. Then $f^{12}(q_0)$ is usually close enough.

[This is actually somewhat slower than a binary search for solution $q$, so binary search might be the way to go.]

You're making a few trivial errors. Aside from an inconsistent definition of $p$ - the relationship (the equation for the horizontal line) is $y=p-0.5$ at the beginning of your question but $d\equiv y = 1-2p$ at the end of the question, you forgot the coefficient $2$ inside the sine. With this fix, you will get $\pi/2$ for the half-circle.

If anybody cares, the function can be approximated by $y = 1.27p - 0.135$ for $p \to 0.5$.

In reality, the colored percentage is less than that because of that thick border covering the bottom and top edge of the circle; indeed I initially believed that the relationship was sublinear for low values of $p$, while it's not. I'm afraid accounting for this factor analytically would make the calculations prohibitively expensive for my simple use case, however.