Calculate max size of rectangle in pie chart I'm trying to get the maximum possible width and height of a rectangle inside a pie chart. All fields have the same angle. $\alpha$ is never bigger than $90^{\circ}$.
I have the variables $\alpha$, $r$, $b$ and I know that $w = 3h$. 
I'm searching for $w$, $h$ and $P_1 (x_1, y_1)$.
I'm a programmer, so I'm not that good with math and I have to translate this to Code afterwards. Thanks for your help!

Edit:
I'm using Javascript. Thanks to Paul. He explained me, that I have to use radians instead of degree using Math.tan. In addition, there is no Math.cot in Javascript. That's why I had to create two more functions.
const tan = (deg) => Math.tan(deg * Math.PI / 180);
const cot = (value) => 1 / tan(value);

 A: Here's a possible answer, based on the truth of my comment.
No way to draw a picture now.
In your figure, let $z$ be the distance from the center to the top edge of the rectangle. Then
$$.
z = (w/2)\cot(\alpha/2).
$$
Then the distance to the bottom edge of the rectangle is
$$
z+ h = z + (w/3)
$$
... will finish later ...
A: Using the figure as our guide, and placing the origin at the center.
Your rectangle is symmetric about the line $x = 0$
It is bound on the upper-left corner by the line $y=x$
It is bound on the lower left corner by the circle $x^2 + y^2 = R^2$
Where $R$ is the radius of the circle that bounds the rectangle.
We can call these two coordinates $(x,x), (x,y)$
$x<0, y<0, |x|<|y|$
$H = x-y\\
W = -2x$
$W = 3H\\
-2x = 3x-3y\\
y = \frac 53 x$
$x^2 + (\frac 53 x)^2 = R^2\\
\frac {34}{9} x^2=  R^2\\
x = - \frac {3}{\sqrt {34}} R$
the 4 corners are:
$(- \frac {3}{\sqrt {34}} R, - \frac {3}{\sqrt {34}} R) , ( \frac {3}{\sqrt {34}} R, - \frac {3}{\sqrt {34}} R), (\frac {3}{\sqrt {34}} R,- \frac {5}{\sqrt {34}} R), (-\frac {3}{\sqrt {34}} R,- \frac {5}{\sqrt {34}} R)$
the area  $= \frac 43 x^2 = \frac {12}{34} r^2$
A: @DougM almost had the correct approach but he treated the diagonal line as if it has the equation $y=x$ which is not the case.
Taking the centre of the circle to be the origin we know that the inner-most circle has the equation $R^2=x^2+y^2$ where $R=r-2b$
The diagonal line which touches the top-right corner of the square makes a nangle $\frac{\alpha}{2}-90$ with the x-axis and it passes through the origin so it has an equation $y=tan(\frac{\alpha}{2}-90)x$
The bottom right corner on the rectangle is clearly $1.5w$ to the right of the centre of the circle so it has a coordinate $(1.5w,y_1)$. Because this point passes through the circle we can substitute it into the equation of the circle so we get $R^2=(1.5w)^2+y_1^2$
The top right corner on the rectangle is just $h$ above the bottom right corner so it has a coordinate $(1.5w,y_1+h)$. Putting this into the equation of the line we get $y_1+h=tan(\frac{\alpha}{2}-90)(1.5w)$
Using these two equations we can eliminate $y_1$
$R^2=(1.5w)^2+((tan(\frac{\alpha}{2}-90)(1.5w)-h)^2$
Use the fact that $w=3h$
$R^2=(4.5h)^2+((tan(\frac{\alpha}{2}-90)(4.5h)-h)^2$
You can rearrange this to get $h$ in terms of $\alpha$ and $R$. The solution is:
$$h=\frac{2R}{\sqrt{81tan^2(\frac{\alpha}{2}-90)-36tan(\frac{\alpha}{2}-90)+85}}$$
This approach gives you $h$ and $w$. Perhaps you can use this to find the point $P_1$. Keep in mind that in my solution I take the centre of the circle as the origin, you will have to make a slight adjustment to get the answer into your coordinate system.
